Skip to content

Commit

Permalink
Resolve Window IntegTest copy and startup issues (#2892)
Browse files Browse the repository at this point in the history
* Resolve Window IntegTest copy and startup issues

Signed-off-by: Your Name <[email protected]>

* Resolve http url downloading with wrong slash

Signed-off-by: Your Name <[email protected]>

* Resolve unittest failures on the checks linting

Signed-off-by: Your Name <[email protected]>

Signed-off-by: Your Name <[email protected]>
Co-authored-by: Your Name <[email protected]>
  • Loading branch information
peterzhuamazon and Your Name authored Nov 15, 2022
1 parent 9fbaa73 commit c7273f0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
15 changes: 10 additions & 5 deletions src/test_workflow/dependency_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import concurrent.futures
import logging
import os
import pathlib
import shutil
import urllib
from typing import List, Tuple
Expand Down Expand Up @@ -38,8 +39,8 @@ def download_dist(self, dest: str) -> str:
return self.download_or_copy(self.bundle_manifest.build.location, local_path)

def __source_dest(self, path: str, category: str, dest: str) -> Tuple[str, str]:
source = "/".join([self.root_url, category, self.build_manifest.build.filename, path])
dest = os.path.realpath(os.path.join(dest, "/".join(path.split("/")[1:])))
source = os.path.join(self.root_url, category, self.build_manifest.build.filename, path)
dest = os.path.realpath(os.path.join(dest, os.path.join(*pathlib.Path(path).parts[1:])))
return (source, dest)

def download(self, paths: List[str], category: str, dest: str) -> None:
Expand All @@ -54,9 +55,13 @@ def download(self, paths: List[str], category: str, dest: str) -> None:

def download_or_copy(self, source: str, dest: str) -> str:
os.makedirs(os.path.dirname(dest), exist_ok=True)
if validators.url(source):
logging.info(f"Downloading {source} into {dest} ...")
urllib.request.urlretrieve(source, dest)
# Required to make sure validators.url is checking an actual url with '/'
# else '\\' will fail the check even if it is a valid url format
# Ex: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.4.0/6452/windows/x64/zip\builds\opensearch\maven\org\opensearch\client\client-benchmarks\maven-metadata.xml
source_url = source.replace('\\', '/')
if validators.url(source_url):
logging.info(f"Downloading {source_url} into {dest} ...")
urllib.request.urlretrieve(source_url, dest)
else:
logging.info(f"Copying {source} into {dest} ...")
source = os.path.realpath(source)
Expand Down
4 changes: 2 additions & 2 deletions src/test_workflow/integ_test/distribution_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def install(self, bundle_name: str) -> None:
@property
def start_cmd(self) -> str:
start_cmd_map = {
"opensearch": "./opensearch-windows-install.bat",
"opensearch-dashboards": "./opensearch-dashboards.bat",
"opensearch": ".\\opensearch-windows-install.bat",
"opensearch-dashboards": ".\\opensearch-dashboards.bat",
}
return start_cmd_map[self.filename]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_install(self) -> None:
mock_zipfile_extractall.assert_called_with(self.work_dir)

def test_start_cmd(self) -> None:
self.assertEqual(self.distribution_zip.start_cmd, "./opensearch-windows-install.bat")
self.assertEqual(self.distribution_zip.start_cmd, ".\\opensearch-windows-install.bat")

@patch("subprocess.check_call")
def test_uninstall(self, check_call_mock: Mock) -> None:
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_install(self) -> None:
mock_zipfile_extractall.assert_called_with(self.work_dir)

def test_start_cmd(self) -> None:
self.assertEqual(self.distribution_zip.start_cmd, "./opensearch-dashboards.bat")
self.assertEqual(self.distribution_zip.start_cmd, ".\\opensearch-dashboards.bat")

@patch("subprocess.check_call")
def test_uninstall(self, check_call_mock: Mock) -> None:
Expand Down

0 comments on commit c7273f0

Please sign in to comment.