|
| 1 | +from collections import namedtuple |
1 | 2 | from pathlib import Path
|
| 3 | +from typing import Tuple, Optional |
2 | 4 |
|
3 | 5 | import luigi
|
| 6 | +from exasol_integration_test_docker_environment.lib.config.docker_config import source_docker_repository_config, \ |
| 7 | + target_docker_repository_config |
| 8 | + |
4 | 9 | from exasol_script_languages_container_tool.lib.tasks.test.run_db_test_result import RunDBTestResult
|
5 | 10 | from exasol_script_languages_container_tool.lib.tasks.test.run_db_tests_parameter import RunDBTestParameter
|
6 | 11 | from exasol_integration_test_docker_environment.lib.base.flavor_task import FlavorBaseTask
|
@@ -60,11 +65,28 @@ def handle_test_result(self, bash_cmd, environment, exit_code, output):
|
60 | 65 | JsonPickleTarget(self.get_output_path().joinpath("test_result.json")).write(result, 4)
|
61 | 66 | self.return_object(result)
|
62 | 67 |
|
| 68 | + @staticmethod |
| 69 | + def _get_docker_credentials() -> Optional[namedtuple]: |
| 70 | + docker_credentials = namedtuple("DockerCredentials", "username password") |
| 71 | + if source_docker_repository_config().username is not None and \ |
| 72 | + source_docker_repository_config().password is not None: |
| 73 | + return docker_credentials(source_docker_repository_config().username, |
| 74 | + source_docker_repository_config().password) |
| 75 | + if target_docker_repository_config().username is not None and \ |
| 76 | + target_docker_repository_config().password is not None: |
| 77 | + return docker_credentials(target_docker_repository_config().username, |
| 78 | + target_docker_repository_config().password) |
| 79 | + return None |
| 80 | + |
63 | 81 | def run_test_command(self, bash_cmd, test_container):
|
64 | 82 | still_running_logger = StillRunningLogger(self.logger, "db tests")
|
65 | 83 | thread = StillRunningLoggerThread(still_running_logger)
|
66 | 84 | thread.start()
|
67 | 85 | environment = FrozenDictToDict().convert(self.test_environment_vars)
|
| 86 | + docker_credentials = self.__class__._get_docker_credentials() |
| 87 | + if docker_credentials is not None: |
| 88 | + environment["DOCKER_USERNAME"] = docker_credentials.username |
| 89 | + environment["DOCKER_PASSWORD"] = docker_credentials.password |
68 | 90 | environment["TEST_ENVIRONMENT_TYPE"] = self.test_environment_info.type.name
|
69 | 91 | environment["TEST_ENVIRONMENT_NAME"] = self.test_environment_info.name
|
70 | 92 | environment["TEST_DOCKER_NETWORK_NAME"] = self.test_environment_info.network_info.network_name
|
|
0 commit comments