Skip to content

Commit

Permalink
use a random id for client id to prevent conflicts between tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Apr 11, 2022
1 parent 34734fb commit b970c2d
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
from TestToolLibrary.skip import Python2VersionLowerThan
from TestToolLibrary.skip import Python3VersionLowerThan

CLIENT_ID_PUB = "integrationTestMQTT_ClientPub" + "".join(random.choice(string.ascii_lowercase) for i in range(4))
CLIENT_ID_SUB = "integrationTestMQTT_ClientSub" + "".join(random.choice(string.ascii_lowercase) for i in range(4))

# Callback unit
class callbackUnit:
Expand Down Expand Up @@ -148,9 +150,9 @@ def threadBRuntime(self, pyCoreClient, callback):

# Init Python core and connect
myMQTTClientManager = MQTTClientManager.MQTTClientManager()
clientPub = myMQTTClientManager.create_connected_mqtt_core("integrationTestMQTT_ClientPub", host, rootCA,
clientPub = myMQTTClientManager.create_connected_mqtt_core(CLIENT_ID_PUB, host, rootCA,
certificate, privateKey, mode=mode)
clientSub = myMQTTClientManager.create_connected_mqtt_core("integrationTestMQTT_ClientSub", host, rootCA,
clientSub = myMQTTClientManager.create_connected_mqtt_core(CLIENT_ID_SUB, host, rootCA,
certificate, privateKey, mode=mode)

if clientPub is None or clientSub is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
from TestToolLibrary.skip import Python2VersionLowerThan
from TestToolLibrary.skip import Python3VersionLowerThan

CLIENT_ID_PUB = "integrationTestMQTT_ClientPub" + "".join(random.choice(string.ascii_lowercase) for i in range(4))
CLIENT_ID_SUB = "integrationTestMQTT_ClientSub" + "".join(random.choice(string.ascii_lowercase) for i in range(4))

# Class that implements the publishing thread: Thread A, with network failure
# This thread will publish 3 messages first, and then keep publishing
Expand Down Expand Up @@ -287,9 +289,9 @@ def performConfigurableOfflinePublishQueueTest(clientPub, clientSub):

# Init Python core and connect
myMQTTClientManager = MQTTClientManager.MQTTClientManager()
clientPub = myMQTTClientManager.create_connected_mqtt_core("integrationTestMQTT_ClientPub", host, rootCA,
clientPub = myMQTTClientManager.create_connected_mqtt_core(CLIENT_ID_PUB, host, rootCA,
certificate, privateKey, mode=mode)
clientSub = myMQTTClientManager.create_connected_mqtt_core("integrationTestMQTT_ClientSub", host, rootCA,
clientSub = myMQTTClientManager.create_connected_mqtt_core(CLIENT_ID_SUB, host, rootCA,
certificate, privateKey, mode=mode)

if clientPub is None or clientSub is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import json

IOT_JOBS_MQTT_RESPONSE_WAIT_SECONDS = 5
CLIENT_ID = "integrationTestMQTT_Client" + "".join(random.choice(string.ascii_lowercase) for i in range(4))

class JobsMessageProcessor(object):
def __init__(self, awsIoTMQTTThingJobsClient, clientToken):
Expand Down Expand Up @@ -168,7 +169,7 @@ def _test_send_response_confirm(self, sendResult):

# Init Python core and connect
myMQTTClientManager = MQTTClientManager.MQTTClientManager()
client = myMQTTClientManager.create_connected_mqtt_client(mode, "integrationTestJobs_Client", host, (rootCA, certificate, privateKey))
client = myMQTTClientManager.create_connected_mqtt_client(mode, CLIENT_ID, host, (rootCA, certificate, privateKey))

clientId = 'AWSPythonkSDKTestThingClient'
thingName = 'AWSPythonkSDKTestThing'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
API_TYPE_SYNC = "sync"
API_TYPE_ASYNC = "async"

CLIENT_ID_PUB = "integrationTestMQTT_ClientPub" + "".join(random.choice(string.ascii_lowercase) for i in range(4))
CLIENT_ID_SUB = "integrationTestMQTT_ClientSub" + "".join(random.choice(string.ascii_lowercase) for i in range(4))



# Callback unit for subscribe
class callbackUnit:
Expand Down Expand Up @@ -95,9 +99,9 @@ def _performPublish(self, pyCoreClient, topic, qos, payload):

# Init Python core and connect
myMQTTClientManager = MQTTClientManager.MQTTClientManager()
clientPub = myMQTTClientManager.create_connected_mqtt_core("integrationTestMQTT_ClientPub", host, rootCA,
clientPub = myMQTTClientManager.create_connected_mqtt_core(CLIENT_ID_PUB, host, rootCA,
certificate, privateKey, mode=mode)
clientSub = myMQTTClientManager.create_connected_mqtt_core("integrationTestMQTT_ClientSub", host, rootCA,
clientSub = myMQTTClientManager.create_connected_mqtt_core(CLIENT_ID_SUB, host, rootCA,
certificate, privateKey, mode=mode)

if clientPub is None or clientSub is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def get_random_string(length):
ROOT_CA = "./test-integration/Credentials/rootCA.crt"
CERT = "./test-integration/Credentials/certificate.pem.crt"
KEY = "./test-integration/Credentials/privateKey.pem.key"
CLIENT_PUB_ID = "PySdkIntegTest_OfflineSubUnsub_pub"
CLIENT_SUB_UNSUB_ID = "PySdkIntegTest_OfflineSubUnsub_subunsub"
CLIENT_PUB_ID = "PySdkIntegTest_OfflineSubUnsub_pub" + get_random_string(4)
CLIENT_SUB_UNSUB_ID = "PySdkIntegTest_OfflineSubUnsub_subunsub" + get_random_string(4)
KEEP_ALIVE_SEC = 1
EVENT_WAIT_TIME_OUT_SEC = 5

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
from TestToolLibrary.skip import Python2VersionLowerThan
from TestToolLibrary.skip import Python3VersionLowerThan

CLIENT_ID_PUB = "integrationTestMQTT_ClientPub" + "".join(random.choice(string.ascii_lowercase) for i in range(4))
CLIENT_ID_SUB = "integrationTestMQTT_ClientSub" + "".join(random.choice(string.ascii_lowercase) for i in range(4))

# Class that implements all the related threads in the test in a controllable manner
class threadPool:
Expand Down Expand Up @@ -234,9 +236,9 @@ def verifyBackoffTime(answerList, resultList):

# Init Python core and connect
myMQTTClientManager = MQTTClientManager.MQTTClientManager()
clientPub = myMQTTClientManager.create_connected_mqtt_core("integrationTestMQTT_ClientPub", host, rootCA,
clientPub = myMQTTClientManager.create_connected_mqtt_core(CLIENT_ID_PUB, host, rootCA,
certificate, privateKey, mode=mode)
clientSub = myMQTTClientManager.create_connected_mqtt_core("integrationTestMQTT_ClientSub", host, rootCA,
clientSub = myMQTTClientManager.create_connected_mqtt_core(CLIENT_ID_SUB, host, rootCA,
certificate, privateKey, mode=mode)

if clientPub is None or clientSub is None:
Expand Down
6 changes: 4 additions & 2 deletions test-integration/IntegrationTests/IntegrationTestShadow.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

# Global configuration
TPS = 1 # Update speed, Spectre does not tolerate high TPS shadow operations...
CLIENT_ID_PUB = "integrationTestMQTT_ClientPub" + "".join(random.choice(string.ascii_lowercase) for i in range(4))
CLIENT_ID_SUB = "integrationTestMQTT_ClientSub" + "".join(random.choice(string.ascii_lowercase) for i in range(4))


# Class that manages the generation and chopping of the random string
Expand Down Expand Up @@ -163,9 +165,9 @@ def randomString(lengthOfString):

# Init Python core and connect
myMQTTClientManager = MQTTClientManager.MQTTClientManager()
clientPub = myMQTTClientManager.create_connected_mqtt_core("integrationTestMQTT_ClientPub", host, rootCA,
clientPub = myMQTTClientManager.create_connected_mqtt_core(CLIENT_ID_PUB, host, rootCA,
certificate, privateKey, mode=mode)
clientSub = myMQTTClientManager.create_connected_mqtt_core("integrationTestMQTT_ClientSub", host, rootCA,
clientSub = myMQTTClientManager.create_connected_mqtt_core(CLIENT_ID_SUB, host, rootCA,
certificate, privateKey, mode=mode)

if clientPub is None or clientSub is None:
Expand Down

0 comments on commit b970c2d

Please sign in to comment.