Skip to content

Commit

Permalink
extended test
Browse files Browse the repository at this point in the history
  • Loading branch information
burnout87 committed Oct 9, 2024
1 parent 0d30cc8 commit 8f088af
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
9 changes: 9 additions & 0 deletions cdci_data_analysis/pytest_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,15 @@ def remove_scratch_folders(job_id=None):
for d in dir_list:
shutil.rmtree(d)

@staticmethod
def remove_lock_files(job_id=None):
if job_id is None:
lock_files = glob.glob('.lock_*')
else:
lock_files = glob.glob(f'.lock_{job_id}')

Check warning on line 1576 in cdci_data_analysis/pytest_fixtures.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/pytest_fixtures.py#L1576

Added line #L1576 was not covered by tests
for f in lock_files:
os.remove(f)

@staticmethod
def remove_download_folders(id=None):
if id is None:
Expand Down
16 changes: 9 additions & 7 deletions tests/test_job_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -2605,6 +2605,7 @@ def test_email_t1_t2(dispatcher_long_living_fixture,
("hard_minimum_folder_age_days", 60)], indirect=True)
def test_free_up_space(dispatcher_live_fixture, number_folders_to_delete, soft_minimum_age_days):
DispatcherJobState.remove_scratch_folders()
DispatcherJobState.remove_lock_files()

server = dispatcher_live_fixture

Expand Down Expand Up @@ -2635,11 +2636,11 @@ def test_free_up_space(dispatcher_live_fixture, number_folders_to_delete, soft_m
number_analysis_to_run = 8

for i in range(number_analysis_to_run):
ask(server,
params,
expected_query_status=["done"],
max_time_s=150
)
jdata = ask(server,

Check warning

Code scanning / CodeQL

Variable defined multiple times Warning test

This assignment to 'jdata' is unnecessary as it is
redefined
before this value is used.
params,
expected_query_status=["done"],
max_time_s=150
)

list_scratch_dir = sorted(glob.glob("scratch_sid_*_jid_*"), key=os.path.getmtime)

Expand All @@ -2662,7 +2663,6 @@ def test_free_up_space(dispatcher_live_fixture, number_folders_to_delete, soft_m
my_json_str = json.dumps(dict_analysis_parameters, indent=4)
dict_analysis_parameters_outfile.write(u'%s' % my_json_str)


params = {
'token': encoded_token,
'soft_minimum_age_days': soft_minimum_age_days
Expand All @@ -2677,7 +2677,9 @@ def test_free_up_space(dispatcher_live_fixture, number_folders_to_delete, soft_m

assert 'output_status' in jdata

assert jdata['output_status'] == f"Removed {number_folders_to_delete} scratch directories"
number_lock_files_deleted = 0 if number_folders_to_delete < number_analysis_to_run else 1
assert jdata['output_status'] == (f"Removed {number_folders_to_delete} scratch directories, "
f"and {number_lock_files_deleted} lock files.")

assert len(glob.glob("scratch_sid_*_jid_*")) == number_analysis_to_run - number_folders_to_delete

Expand Down

0 comments on commit 8f088af

Please sign in to comment.