Skip to content

Commit

Permalink
upd refresh in env, utils and steps with query on table cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucaaccenture committed Sep 15, 2024
1 parent 7c57613 commit c97944f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
22 changes: 16 additions & 6 deletions src/integ-test/bdd-test/features/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,13 @@ def before_all(context):
elif dbRun == 'Oracle':
refresh_response = requests.get(utils.get_refresh_config_url(context), headers=headers, verify=False)

time.sleep(3)
#time.sleep(3)

#CHECK REFRESH ON DB
new_record_cache = utils.query_new_record_cache(conn, adopted_db, dbRun)
adopted_db.closeConnection(conn)
assert new_record_cache == True, f"New record cache not found!"

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

except Exception as e:
Expand Down Expand Up @@ -202,11 +208,9 @@ def before_scenario(context, scenario):

def after_scenario(context, scenario):
global execute_after_scenario

dbRun = getattr(context, "dbRun")

try:

if execute_after_scenario:
print(f"----> AFTER SCENARIO RESTORE EXECUTING...")

Expand Down Expand Up @@ -273,8 +277,8 @@ def after_scenario(context, scenario):

#time.sleep(3)


new_record_cache = utils.query_new_record_cache(conn, adopted_db)
#CHECK REFRESH ON DB
new_record_cache = utils.query_new_record_cache(conn, adopted_db, dbRun)
adopted_db.closeConnection(conn)
assert new_record_cache == True, f"New record cache not found!"

Expand Down Expand Up @@ -401,7 +405,13 @@ def after_all(context):
elif dbRun == "Oracle":
refresh_response = requests.get(utils.get_refresh_config_url(context), headers=headers, verify=False)

time.sleep(3)
#time.sleep(3)

#CHECK REFRESH ON DB
new_record_cache = utils.query_new_record_cache(conn, adopted_db, dbRun)
adopted_db.closeConnection(conn)
assert new_record_cache == True, f"New record cache not found!"

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

except AssertionError as e:
Expand Down
4 changes: 2 additions & 2 deletions src/integ-test/bdd-test/features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3342,15 +3342,15 @@ def step_impl(context, job_name, seconds):
refresh_response = requests.get(utils.get_refresh_config_url(context), headers=headers, verify=False)

setattr(context, job_name + RESPONSE, refresh_response)
print(f"wait for: {seconds} seconds")
#print(f"wait for: {seconds} seconds")
#time.sleep(int(seconds))
db_name = "nodo_cfg"
db_config = context.config.userdata.get("db_configuration")
db_selected = db_config.get(db_name)

adopted_db, conn = utils.get_db_connection(db_name, db, db_online, db_offline, db_re, db_wfesp, db_selected)

new_record_cache = utils.query_new_record_cache(conn, adopted_db)
new_record_cache = utils.query_new_record_cache(conn, adopted_db, dbRun)

adopted_db.closeConnection(conn)

Expand Down
9 changes: 7 additions & 2 deletions src/integ-test/bdd-test/features/steps/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1649,15 +1649,20 @@ def query_with_polling(conn, adopted_db, selected_query, size_record_expected):


###METODO PER EFFETTUARE QUERY ALLA CAHCE
def query_new_record_cache(conn, adopted_db):
def query_new_record_cache(conn, adopted_db, dbRun):
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 > trunc(SYSDATE - interval '10' second) order by TIME desc limit 1"
selected_query = ''

if dbRun == 'Postgres':
selected_query = "select * from cache c where c. time > trunc(SYSDATE - interval '10' second) order by TIME desc limit 1"
elif dbRun == 'Oracle':
selected_query = "select * from cache c where c.time > trunc(SYSDATE - (10 / (24 * 60 * 60))) order by c.time desc fetch first 1 row only"

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

0 comments on commit c97944f

Please sign in to comment.