Skip to content

Commit

Permalink
Increase test timeouts (#1046)
Browse files Browse the repository at this point in the history
* increase timeouts

* add sleep for eventhub listener start

* drop eventhub timeout to 15 minutes

* increase timeouts, make service_helper session scope

* remove extra sleep
  • Loading branch information
BertKleewein authored Aug 29, 2022
1 parent bc2575f commit 3da0780
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 26 deletions.
2 changes: 1 addition & 1 deletion dev_utils/dev_utils/service_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async def wait_for_eventhub_arrival(self, message_id, timeout=60):
timeout,
)

async def get_next_reported_patch_arrival(self, block=True, timeout=20):
async def get_next_reported_patch_arrival(self, block=True, timeout=240):
return await self._event_loop.run_in_executor(
self._executor,
self._inner_object.get_next_reported_patch_arrival,
Expand Down
4 changes: 2 additions & 2 deletions dev_utils/dev_utils/service_helper_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def send_c2d(self, payload, properties):
raise TypeError("sending C2D to modules is not supported")
self._registry_manager.send_c2d_message(self.device_id, payload, properties)

def wait_for_eventhub_arrival(self, message_id, timeout=600):
def wait_for_eventhub_arrival(self, message_id, timeout=900):
def get_event(inner_message_id):
with self.cv:
arrivals = self.incoming_eventhub_events
Expand Down Expand Up @@ -191,7 +191,7 @@ def get_event(inner_message_id):
else:
self.cv.wait()

def get_next_reported_patch_arrival(self, block=True, timeout=20):
def get_next_reported_patch_arrival(self, block=True, timeout=240):
try:
return self.incoming_patch_queue.get(block=block, timeout=timeout)
except queue.Empty:
Expand Down
5 changes: 2 additions & 3 deletions tests/e2e/iothub_e2e/aio/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def pytest_sessionfinish(session, exitstatus):
print("-----------------------------------")


@pytest.fixture(scope="module")
@pytest.fixture(scope="session")
def event_loop():
loop = asyncio.get_event_loop()
yield loop
Expand Down Expand Up @@ -100,7 +100,7 @@ async def client(brand_new_client):
yield client


@pytest.fixture(scope="module")
@pytest.fixture(scope="session")
async def service_helper(event_loop, executor):
service_helper = ServiceHelper(
iothub_connection_string=test_env.IOTHUB_CONNECTION_STRING,
Expand All @@ -109,7 +109,6 @@ async def service_helper(event_loop, executor):
event_loop=event_loop,
executor=executor,
)
await asyncio.sleep(3)
yield service_helper

logger.info("----------------------------")
Expand Down
41 changes: 24 additions & 17 deletions tests/e2e/iothub_e2e/aio/test_twin_stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ async def test_stress_serial_reported_property_updates(
received = False
while not received:
received_patch = await service_helper.get_next_reported_patch_arrival()
if received_patch[const.REPORTED][const.TEST_CONTENT] == patch[const.TEST_CONTENT]:
if (
const.REPORTED in received_patch
and received_patch[const.REPORTED][const.TEST_CONTENT]
== patch[const.TEST_CONTENT]
):
received = True
else:
logger.info(
"Wrong patch received. Expecting {}, got {}".format(
received_patch[const.REPORTED], patch
)
"Wrong patch received. Expecting {}, got {}".format(patch, received_patch)
)

leak_tracker.check_for_leaks()
Expand Down Expand Up @@ -129,20 +131,25 @@ async def test_stress_parallel_reported_property_updates(
received_test_content = received_patch[const.REPORTED][const.TEST_CONTENT] or {}
logger.info("received {}".format(received_test_content))

for key in received_test_content.keys():
logger.info("Received {} = {}".format(key, received_test_content[key]))
if key in props:
if received_test_content[key] == props[key]:
logger.info("Key {} received as expected.".format(key))
# Set the value to None so we know that it's been received
props[key] = None
count_received += 1
else:
logger.info(
"Ignoring unexpected value for key {}. Received = {}, expected = {}".format(
key, received_test_content[key], props[key]
if isinstance(received_test_content, dict):
# We check to make sure received_test_content is a dict because it may be
# a string left over from a previous test case.
# This can happen if if the tests are running fast and the reported
# property updates are being processed slowly.
for key in received_test_content.keys():
logger.info("Received {} = {}".format(key, received_test_content[key]))
if key in props:
if received_test_content[key] == props[key]:
logger.info("Key {} received as expected.".format(key))
# Set the value to None so we know that it's been received
props[key] = None
count_received += 1
else:
logger.info(
"Ignoring unexpected value for key {}. Received = {}, expected = {}".format(
key, received_test_content[key], props[key]
)
)
)

leak_tracker.check_for_leaks()

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/iothub_e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def transport():
return test_config.config.transport


@pytest.fixture(scope="module")
@pytest.fixture(scope="session")
def executor():
return concurrent.futures.ThreadPoolExecutor()

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/iothub_e2e/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[pytest]
timeout=60
timeout=120
testdox_format=plaintext
junit_logging=all
junit_family=xunit2
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/iothub_e2e/sync/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def client(brand_new_client):
yield client


@pytest.fixture(scope="module")
@pytest.fixture(scope="session")
def service_helper():
service_helper = ServiceHelperSync(
iothub_connection_string=test_env.IOTHUB_CONNECTION_STRING,
Expand Down

0 comments on commit 3da0780

Please sign in to comment.