Skip to content

Commit

Permalink
creating the archive file in the nfs file system
Browse files Browse the repository at this point in the history
  • Loading branch information
PhillipsOwen committed Apr 10, 2024
1 parent 1277c23 commit 93586be
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
18 changes: 14 additions & 4 deletions src/staging/staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,22 @@ def final_staging(self, run_id: str, run_dir: str, staging_type: StagingType) ->
# if all runs are complete
if run_status['Testing Jobs']['Total'] == run_status['Testing Jobs']['Complete']:
# get the full path to the test results archive file
archive_file: str = os.path.join(run_dir, f"{run_data['request_group']}.test-results")
k8s_archive_file: str = os.path.join(run_dir, f"{run_data['request_group']}.test-results")

self.logger.info('Creating archive: %s.zip', archive_file)
self.logger.info('Creating k8s archive: %s.zip', k8s_archive_file)

# compress the directory into the package directory
shutil.make_archive(archive_file, 'zip', run_dir)
# compress the directory into the k8s data directory
shutil.make_archive(k8s_archive_file, 'zip', run_dir)

# if the package directory is defined
if run_data['request_data']['package-dir']:
# get the full path to the test results archive file
nfs_archive_file: str = os.path.join(run_data['request_data']['package-dir'], f"{run_data['request_group']}.test-results")

self.logger.info('Creating nfs archive: %s.zip', k8s_archive_file)

# compress the directory into the package directory
shutil.make_archive(nfs_archive_file, 'zip', run_dir)

# remove all directories from the run (leaving the archive file)
[shutil.rmtree(data_dir, ignore_errors=True) for data_dir in glob.glob(f'{run_dir}/**/')]
Expand Down
4 changes: 2 additions & 2 deletions src/tests/test_staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ def test_final_staging_run():
staging = Staging()

# set a valid run ID
run_id: str = '1'
run_id: str = '12'

# set up the test directory
run_dir: str = os.path.join(os.getenv('TEST_PATH'), 'save-this-test-1')
run_dir: str = os.path.join(os.getenv('TEST_PATH'), 'save-this-test-12')

# make the call to do a final stage. this dir was created above so it should be removed
ret_val = staging.run(run_id, run_dir, StagingType.FINAL_STAGING)
Expand Down

0 comments on commit 93586be

Please sign in to comment.