-
Notifications
You must be signed in to change notification settings - Fork 7
All/task/devopsdsc 868 use work dir #530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
b8a4b1e
829f6fd
84a2ff8
0611086
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |||||
|
|
||||||
| import multiprocessing | ||||||
| import os | ||||||
| import shutil | ||||||
| import sys | ||||||
| from abc import ABC, abstractmethod | ||||||
| from datetime import datetime, timedelta | ||||||
|
|
@@ -23,7 +24,7 @@ | |||||
| from src.suite.test_bench_settings import TestBenchSettings | ||||||
| from src.suite.test_case import TestCase | ||||||
| from src.suite.test_case_result import TestCaseResult | ||||||
| from src.utils.common import log_header, log_separator, log_sub_header | ||||||
| from src.utils.common import delete_directory, log_header, log_separator, log_sub_header | ||||||
| from src.utils.errors.test_bench_error import TestBenchError | ||||||
| from src.utils.handlers.handler_factory import HandlerFactory | ||||||
| from src.utils.handlers.resolve_handler import ResolveHandler | ||||||
|
|
@@ -240,8 +241,8 @@ def run_test_case( | |||||
| logger.info("Testcase not executed (ignored)...\n") | ||||||
|
|
||||||
| # Check for errors during execution of testcase | ||||||
| if len(testcase.getErrors()) > 0: | ||||||
| errstr = ",".join(str(e) for e in testcase.getErrors()) | ||||||
| if len(testcase.get_errors()) > 0: | ||||||
| errstr = ",".join(str(e) for e in testcase.get_errors()) | ||||||
| logger.error("Errors during testcase: " + errstr) | ||||||
| raise TestCaseFailure("Errors during testcase: " + errstr) | ||||||
|
|
||||||
|
|
@@ -559,6 +560,9 @@ def __process_test_case_locations(self, config: TestCaseConfig, logger: ILogger) | |||||
| remote_path = self.__build_remote_path(config, location) | ||||||
| local_path = self.__build_local_path(config, location) | ||||||
| self.__download_location_with_retries(config, location, remote_path, local_path, logger) | ||||||
| if location.type == PathType.INPUT: | ||||||
| self.__copy_to_work_folder(local_path, logger) | ||||||
|
|
||||||
| self.__set_absolute_paths(config, location.type, local_path) | ||||||
|
|
||||||
| def __validate_location(self, config: TestCaseConfig, location: Location) -> None: | ||||||
|
|
@@ -637,6 +641,25 @@ def __download_location_with_retries( | |||||
| error_message = f"Unable to download testcase: {error}" | ||||||
| raise TestBenchError(error_message) from e | ||||||
|
|
||||||
| def __copy_to_work_folder(self, local_path: str, logger: ILogger) -> None: | ||||||
| """Copy downloaded files to work folder if needed.""" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that |
||||||
| copy_path = local_path + "_work" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| if not os.path.exists(local_path): | ||||||
| logger.warning(f"Work path does not exist, cannot create work copy: {local_path}") | ||||||
| return | ||||||
|
|
||||||
| # Clean work directory if it exists | ||||||
| if os.path.exists(copy_path): | ||||||
| delete_directory(copy_path, logger) | ||||||
|
|
||||||
| # Copy input to work directory | ||||||
| logger.debug(f"Copying input from {local_path} to {copy_path}") | ||||||
| if os.path.isdir(local_path): | ||||||
| shutil.copytree(local_path, copy_path, symlinks=False, ignore_dangling_symlinks=True) | ||||||
| else: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can rule out that |
||||||
| os.makedirs(os.path.dirname(copy_path) or ".", exist_ok=True) | ||||||
| shutil.copy2(local_path, copy_path) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why |
||||||
|
|
||||||
| def __download_single_location( | ||||||
| self, config: TestCaseConfig, location: Location, remote_path: str, local_path: str, logger: ILogger | ||||||
| ) -> None: | ||||||
|
|
@@ -655,7 +678,7 @@ def __get_destination_directory(self, location_type: PathType) -> Optional[str]: | |||||
| def __set_absolute_paths(self, config: TestCaseConfig, location_type: PathType, local_path: str) -> None: | ||||||
| """Set absolute paths on the config based on location type.""" | ||||||
| if location_type == PathType.INPUT: | ||||||
| config.absolute_test_case_path = local_path | ||||||
| config.absolute_test_case_path = local_path + "_work" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd advie to use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
local = Path(local_path)
config.absolute_test_case_path = str(local.parent / (local.name + "_work")) |
||||||
| elif location_type == PathType.REFERENCE: | ||||||
| config.absolute_test_case_reference_path = local_path | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand the point of this class. I see the data gets collected, but I don't see it being used anywhere. Could you explain the thought process behind it?