Skip to content

Commit

Permalink
upd sleep to 0.5 and add method in utils query cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucaaccenture committed Sep 13, 2024
1 parent c1fadf6 commit 946c65d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/integ-test/bdd-test/features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3333,6 +3333,7 @@ def step_impl(context, job_name, seconds):

print("Refreshing...")
refresh_response = None

if dbRun == "Postgres":
print(f"URL refresh: {utils.get_refresh_config_url(context)}")
refresh_response = requests.get(utils.get_refresh_config_url(context), headers=headers, verify=False, proxies = getattr(context,'proxies'))
Expand All @@ -3343,7 +3344,6 @@ def step_impl(context, job_name, seconds):
setattr(context, job_name + RESPONSE, refresh_response)
print(f"wait for: {seconds} seconds")
time.sleep(int(seconds))

assert refresh_response.status_code == 200, f"refresh status code expected: {200} but obtained: {refresh_response.status_code}"

print("Refresh Completed!")
Expand Down
39 changes: 37 additions & 2 deletions src/integ-test/bdd-test/features/steps/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,7 @@ def query_with_polling(conn, adopted_db, selected_query, size_record_expected):
###CHECK IF THE FIELD OF RECORDS CAN BE UPDATED

print(f"Check per 1 sec se ci sono aggiornamenti nel record")
time.sleep(1)
time.sleep(0.5)

exec_query_updated = adopted_db.executeQuery(conn, selected_query)

Expand All @@ -1644,4 +1644,39 @@ def query_with_polling(conn, adopted_db, selected_query, size_record_expected):
if polling_time == 0 and (exec_query is None or len(exec_query) == 0):
print("Polling timed out with no results.")

return exec_query_updated
return exec_query_updated



###METODO PER EFFETTUARE QUERY ALLA CAHCE
def query_new_record_cache(conn, adopted_db):
new_record_cache = False

wait_time = 15
print(f"Wait after refresh set to: {wait_time} seconds")
sec = 0

size_record_expected = 1
selected_query = "select * from cache c where c.time > SYSDATE - INTERVAL '10' SECOND ORDER BY TIME desc LIMIT 1"

while wait_time > 0:
exec_query = adopted_db.executeQuery(conn, selected_query)

if exec_query is not None and len(exec_query) != 0 and len(exec_query) == size_record_expected:
new_record_cache = True
print(f"New record found table cache after {sec} seconds!!!")
break
else:
print(f"New record cache search in progress...")

sec += 1
wait_time -= 1
print(f"{wait_time} seconds left before timeout...")
current_timestamp = datetime.datetime.now()
print(f"{current_timestamp} current timestamp")
time.sleep(1)

if wait_time == 0 and (exec_query is None or len(exec_query) == 0):
print("Wait timed out with no results.")

return new_record_cache

0 comments on commit 946c65d

Please sign in to comment.