Skip to content

Commit

Permalink
Fix the path join for running integ test (opensearch-project#3041)
Browse files Browse the repository at this point in the history
* Fix the path for integ test

Signed-off-by: Zelin Hao <[email protected]>

* Add unit test for the case of url with ending backslash

Signed-off-by: Zelin Hao <[email protected]>

Signed-off-by: Zelin Hao <[email protected]>
  • Loading branch information
zelinh authored Jan 5, 2023
1 parent 9ab0203 commit f6d5874
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/test_workflow/dependency_installer_opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ def install_build_dependencies(self, dependency_dict: dict, dest: str) -> None:
"""
os.makedirs(dest, exist_ok=True)
for dependency, version in dependency_dict.items():
path = f"{self.root_url}/builds/opensearch/plugins/{dependency}-{version}.zip"
path = os.path.join(self.root_url, f"builds/opensearch/plugins/{dependency}-{version}.zip")
local_path = os.path.join(dest, f"{dependency}-{version}.zip")
self.download_or_copy(path, local_path)
16 changes: 16 additions & 0 deletions tests/tests_test_workflow/test_dependency_installer_opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,19 @@ def test_install_build_dependencies_remote(self, mock_request: Mock, mock_copyfi
"https://ci.opensearch.org/x/y/builds/opensearch/plugins/opensearch-job-scheduler-1.1.0.0.zip",
os.path.realpath(os.path.join(os.path.dirname(__file__), "opensearch-job-scheduler-1.1.0.0.zip")),
)

@patch("os.makedirs")
@patch("shutil.copyfile")
@patch("urllib.request.urlretrieve")
def test_install_build_dependencies_remote_with_backslash_url(self, mock_request: Mock, mock_copyfile: Mock, mock_makedirs: Mock) -> None:
dependency_installer_url_with_backslash = DependencyInstallerOpenSearch(
"https://ci.opensearch.org/x/y/", BuildManifest.from_path(self.BUILD_MANIFEST), BundleManifest.from_path(self.DIST_MANIFEST_REMOTE)
)
dependencies = dict({"opensearch-job-scheduler": "1.1.0.0"})
dependency_installer_url_with_backslash.install_build_dependencies(dependencies, os.path.dirname(__file__))
mock_makedirs.assert_called_with(os.path.dirname(__file__), exist_ok=True)
mock_copyfile.assert_not_called()
mock_request.assert_called_once_with(
"https://ci.opensearch.org/x/y/builds/opensearch/plugins/opensearch-job-scheduler-1.1.0.0.zip",
os.path.realpath(os.path.join(os.path.dirname(__file__), "opensearch-job-scheduler-1.1.0.0.zip")),
)

0 comments on commit f6d5874

Please sign in to comment.