I am using tenacity 9.0.0 with Python 3.9. My code is like below
@retry(stop=stop_after_attempt(6), wait=wait_fixed(5))
def assert_response():
logging.info("Retrying get flow logs")
es.indices.refresh(index='monitoring')
response = requests.get(url, headers=headers, json=data, params=params)
assert response.status_code == 200, f"Response status is {response.status_code} and body: {response.text}"
response_json = response.json()
logging.info("Response: " + str(response_json))
assert response_json['meta']['run_id'] == 1742403068092, "run_id does not match"
try:
assert_response()
except RetryError as e:
underlying_error = e.last_attempt.exception()
error_message = str(underlying_error)
logging.error(f"Failed to get flow logs after retries: {underlying_error}")
raise AssertionError(f"Failed to get flow logs after multiple retries: {error_message}") from underlying_error
I am seeing the error logs like below
integration-tests-1 | FAILED test_apps/monitoring_service/test_es_monitoring_dao.py::test - AssertionError: Failed to get flow logs after multiple retries: 'run_id'
integration-tests-1 | ====================== 1 failed, 130 deselected in 11.42s ======================
integration-tests-1 | Result of the pytest script: 1
How can I get the log run_id does not match