-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add windows integTest to OpenSearch Clusters (#2761)
* Add new setups Signed-off-by: Peter Zhu <zhujiaxi@amazon.com> * Add windows integTest to OpenSearch Clusters Signed-off-by: Your Name <you@example.com> Signed-off-by: Peter Zhu <zhujiaxi@amazon.com> * Restructure zip tests Signed-off-by: Peter Zhu <zhujiaxi@amazon.com> Signed-off-by: Peter Zhu <zhujiaxi@amazon.com> Signed-off-by: Your Name <you@example.com> Co-authored-by: Your Name <you@example.com>
- Loading branch information
1 parent
eadd668
commit 35bb902
Showing
8 changed files
with
149 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Copyright OpenSearch Contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
|
||
import logging | ||
import os | ||
import subprocess | ||
|
||
from system.zip_file import ZipFile | ||
from test_workflow.integ_test.distribution import Distribution | ||
|
||
|
||
class DistributionZip(Distribution): | ||
def __init__(self, filename: str, version: str, work_dir: str) -> None: | ||
super().__init__(filename, version, work_dir) | ||
|
||
@property | ||
def install_dir(self) -> str: | ||
return os.path.join(self.work_dir, f"{self.filename}-{self.version}") | ||
|
||
@property | ||
def config_dir(self) -> str: | ||
return os.path.join(self.install_dir, "config") | ||
|
||
def install(self, bundle_name: str) -> None: | ||
logging.info(f"Installing {bundle_name} in {self.install_dir}") | ||
with ZipFile(bundle_name, "r") as zip: | ||
zip.extractall(self.work_dir) | ||
|
||
@property | ||
def start_cmd(self) -> str: | ||
start_cmd_map = { | ||
"opensearch": "./opensearch-windows-install.bat", | ||
"opensearch-dashboards": "./opensearch-dashboards.bat", | ||
} | ||
return start_cmd_map[self.filename] | ||
|
||
def uninstall(self) -> None: | ||
logging.info(f"Cleanup {self.work_dir}/* content after the test") | ||
subprocess.check_call(f"rm -rf {self.work_dir}/*", shell=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+566 Bytes
...w/test_integ_workflow/integ_test/data/artifacts/dist/opensearch-min-2.4.0-windows-x64.zip
Binary file not shown.
96 changes: 96 additions & 0 deletions
96
tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_zip.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Copyright OpenSearch Contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
|
||
import os | ||
import unittest | ||
from unittest.mock import MagicMock, Mock, patch | ||
|
||
from test_workflow.integ_test.distribution_zip import DistributionZip | ||
|
||
|
||
class TestDistributionZipOpenSearch(unittest.TestCase): | ||
|
||
def setUp(self) -> None: | ||
|
||
self.work_dir = os.path.join(os.path.dirname(__file__), "data") | ||
self.product = "opensearch" | ||
self.version = "2.4.0" | ||
self.distribution_zip = DistributionZip(self.product, self.version, self.work_dir) | ||
|
||
def test_distribution_zip_vars(self) -> None: | ||
self.assertEqual(self.distribution_zip.filename, self.product) | ||
self.assertEqual(self.distribution_zip.version, self.version) | ||
self.assertEqual(self.distribution_zip.work_dir, self.work_dir) | ||
|
||
def test_install_dir(self) -> None: | ||
self.assertEqual(self.distribution_zip.install_dir, os.path.join(self.work_dir, f"{self.product}-{self.version}")) | ||
|
||
def test_config_dir(self) -> None: | ||
self.assertEqual(self.distribution_zip.config_dir, os.path.join(self.work_dir, f"{self.product}-{self.version}", "config")) | ||
|
||
def test_install(self) -> None: | ||
with patch("test_workflow.integ_test.distribution_zip.ZipFile") as mock_zipfile_open: | ||
mock_zipfile_extractall = MagicMock() | ||
mock_zipfile_open.return_value.__enter__.return_value.extractall = mock_zipfile_extractall | ||
|
||
self.distribution_zip.install(os.path.join(self.work_dir, "artifacts", "dist", f"{self.product}-min-{self.version}-windows-x64.zip")) | ||
|
||
mock_zipfile_open.assert_called_with(os.path.join(self.work_dir, "artifacts", "dist", f"{self.product}-min-{self.version}-windows-x64.zip"), "r") | ||
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") | ||
|
||
@patch("subprocess.check_call") | ||
def test_uninstall(self, check_call_mock: Mock) -> None: | ||
self.distribution_zip.uninstall() | ||
args_list = check_call_mock.call_args_list | ||
|
||
self.assertEqual(check_call_mock.call_count, 1) | ||
self.assertEqual(f"rm -rf {self.work_dir}/*", args_list[0][0][0]) | ||
|
||
|
||
class TestDistributionZipOpenSearchDashboards(unittest.TestCase): | ||
|
||
def setUp(self) -> None: | ||
|
||
self.work_dir = os.path.join(os.path.dirname(__file__), "data") | ||
self.product = "opensearch-dashboards" | ||
self.version = "2.4.0" | ||
self.distribution_zip = DistributionZip(self.product, self.version, self.work_dir) | ||
|
||
def test_distribution_zip_vars(self) -> None: | ||
self.assertEqual(self.distribution_zip.filename, self.product) | ||
self.assertEqual(self.distribution_zip.version, self.version) | ||
self.assertEqual(self.distribution_zip.work_dir, self.work_dir) | ||
|
||
def test_install_dir(self) -> None: | ||
self.assertEqual(self.distribution_zip.install_dir, os.path.join(self.work_dir, f"{self.product}-{self.version}")) | ||
|
||
def test_config_dir(self) -> None: | ||
self.assertEqual(self.distribution_zip.config_dir, os.path.join(self.work_dir, f"{self.product}-{self.version}", "config")) | ||
|
||
def test_install(self) -> None: | ||
with patch("test_workflow.integ_test.distribution_zip.ZipFile") as mock_zipfile_open: | ||
mock_zipfile_extractall = MagicMock() | ||
mock_zipfile_open.return_value.__enter__.return_value.extractall = mock_zipfile_extractall | ||
|
||
self.distribution_zip.install(os.path.join(self.work_dir, "artifacts", "dist", f"{self.product}-min-{self.version}-windows-x64.zip")) | ||
|
||
mock_zipfile_open.assert_called_with(os.path.join(self.work_dir, "artifacts", "dist", f"{self.product}-min-{self.version}-windows-x64.zip"), "r") | ||
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") | ||
|
||
@patch("subprocess.check_call") | ||
def test_uninstall(self, check_call_mock: Mock) -> None: | ||
self.distribution_zip.uninstall() | ||
args_list = check_call_mock.call_args_list | ||
|
||
self.assertEqual(check_call_mock.call_count, 1) | ||
self.assertEqual(f"rm -rf {self.work_dir}/*", args_list[0][0][0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters