From 9c3c57aa6842e1fb67b610d7ed8614bdbc6a1349 Mon Sep 17 00:00:00 2001 From: Alfred Gedeon Date: Fri, 1 Dec 2023 14:16:19 -0800 Subject: [PATCH] Fix: retry for job availablity --- servicetests/test_cases/test_jobs_execution.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/servicetests/test_cases/test_jobs_execution.py b/servicetests/test_cases/test_jobs_execution.py index 12b39538c..2d35133f7 100644 --- a/servicetests/test_cases/test_jobs_execution.py +++ b/servicetests/test_cases/test_jobs_execution.py @@ -53,7 +53,22 @@ def main(): except Exception as e: print(f"ERROR: Failed to create IoT thing: {e}") sys.exit(-1) - time.sleep(5) + + thing_job = 'ERROR' + i = 0; + while 'ERROR' in thing_job and i <= 3: + try: + job_id = secrets_client.get_secret_value(SecretId="ci/JobsServiceClientTest/job_id")["SecretString"] + thing_job = iot_client.describe_job_execution(jobId=job_id, + thingName=thing_name, includeJobDocument=False) + print('thing job is {thing_job}'); + if 'ERROR' in thing_job: + i = i + 1; + else + break; + except Exception as e: + print(f"ERROR: Could not verify Job execution: {e}") + # Perform Jobs test. If it's successful, the Job execution should be marked as SUCCEEDED for the thing. try: test_result = run_in_ci.setup_and_launch(parsed_commands.config_file, input_uuid)