Skip to content

Commit

Permalink
test: add integ tests to test download func (aws-deadline#422)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Tran <[email protected]>
Signed-off-by: Cloud User <[email protected]>
  • Loading branch information
AlexTranAmz authored and Cloud User committed Aug 26, 2024
1 parent 39417ed commit 3ce32a9
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions test/integ/deadline_job_attachments/test_job_attachments.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from dataclasses import dataclass
from pathlib import Path
from unittest.mock import MagicMock
import sys

from deadline.job_attachments.models import JobAttachmentS3Settings

Expand Down Expand Up @@ -1533,3 +1534,90 @@ def test_download_outputs_windows_max_file_path_length_exception(
),
):
job_output_downloader.download_job_output()


@pytest.mark.integ
def test_download_outputs_no_outputs_dir(
job_attachment_test: JobAttachmentTest,
sync_outputs: SyncOutputsOutput,
):
"""
Test that if trying to download outputs but not specify a file path
Download will be saved to the current directory.
"""

download_path = Path(
os.path.normpath(Path("").absolute()) / sync_outputs.step0_task0_output_file
)

job_attachment_settings = get_queue(
farm_id=job_attachment_test.farm_id,
queue_id=job_attachment_test.queue_id,
deadline_endpoint_url=job_attachment_test.deadline_endpoint,
).jobAttachmentSettings

if job_attachment_settings is None:
raise Exception("Job attachment settings must be set for this test.")

job_output_downloader = download.OutputDownloader(
s3_settings=job_attachment_settings,
farm_id=job_attachment_test.farm_id,
queue_id=job_attachment_test.queue_id,
job_id=sync_outputs.job_id,
step_id=sync_outputs.step0_id,
task_id=sync_outputs.step0_task0_id,
)
job_output_downloader.set_root_path(str(job_attachment_test.ASSET_ROOT), "")

# WHEN
try:
job_output_downloader.download_job_output()
# THEN
# The output file should be downloaded to the current directory
assert download_path.exists()
finally:
shutil.rmtree(download_path.parent)


@pytest.mark.integ
@pytest.mark.skipif(
sys.platform != "win32",
reason="This test is for Windows file path length UNC, skipping this if os not Windows",
)
def test_download_outputs_windows_file_path_UNC(
job_attachment_test: JobAttachmentTest,
sync_outputs: SyncOutputsOutput,
):
"""
Test that if trying to download outputs to a file path that
longer than 260 chars in Windows but have UNC, the download is success.
"""
long_root_path = Path("\\\\?\\" + __file__).parent / str("A" * 135)

job_attachment_settings = get_queue(
farm_id=job_attachment_test.farm_id,
queue_id=job_attachment_test.queue_id,
deadline_endpoint_url=job_attachment_test.deadline_endpoint,
).jobAttachmentSettings

if job_attachment_settings is None:
raise Exception("Job attachment settings must be set for this test.")

job_output_downloader = download.OutputDownloader(
s3_settings=job_attachment_settings,
farm_id=job_attachment_test.farm_id,
queue_id=job_attachment_test.queue_id,
job_id=sync_outputs.job_id,
step_id=sync_outputs.step0_id,
task_id=sync_outputs.step0_task0_id,
)
job_output_downloader.set_root_path(str(job_attachment_test.ASSET_ROOT), str(long_root_path))

# WHEN
try:
job_output_downloader.download_job_output()
# THEN
# The output file should be downloaded to the current directory
assert Path(long_root_path / sync_outputs.step0_task0_output_file).exists()
finally:
shutil.rmtree(long_root_path)

0 comments on commit 3ce32a9

Please sign in to comment.