diff --git a/src/test_workflow/integ_test/distribution.py b/src/test_workflow/integ_test/distribution.py index 991eb00f69..c563999af8 100644 --- a/src/test_workflow/integ_test/distribution.py +++ b/src/test_workflow/integ_test/distribution.py @@ -43,6 +43,15 @@ def config_path(self) -> str: pass @property + @abstractmethod + def data_dir(self) -> str: + """ + Return the data directory for the distribution + """ + pass + + @property + @abstractmethod def log_dir(self) -> str: """ Return the log directory for the distribution diff --git a/src/test_workflow/integ_test/distribution_deb.py b/src/test_workflow/integ_test/distribution_deb.py index c4390906fc..fa86912582 100644 --- a/src/test_workflow/integ_test/distribution_deb.py +++ b/src/test_workflow/integ_test/distribution_deb.py @@ -25,6 +25,10 @@ def install_dir(self) -> str: def config_path(self) -> str: return os.path.join(os.sep, "etc", self.filename, self.config_filename) + @property + def data_dir(self) -> str: + return os.path.join(os.sep, "var", "lib", self.filename) + @property def log_dir(self) -> str: return os.path.join(os.sep, "var", "log", self.filename) @@ -39,6 +43,8 @@ def install(self, bundle_name: str) -> None: '--purge', self.filename, '&&', + f'sudo rm -rf {os.path.dirname(self.config_path)} {self.data_dir} {self.log_dir}', + '&&', 'sudo', 'env', 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!', @@ -64,4 +70,4 @@ def start_cmd(self) -> str: def uninstall(self) -> None: logging.info(f"Uninstall {self.filename} package after the test") - subprocess.check_call(f"sudo dpkg --purge {self.filename} && sudo rm -rf {os.path.dirname(self.config_path)} {self.log_dir}", shell=True) + subprocess.check_call(f"sudo dpkg --purge {self.filename} && sudo rm -rf {os.path.dirname(self.config_path)} {self.data_dir} {self.log_dir}", shell=True) diff --git a/src/test_workflow/integ_test/distribution_rpm.py b/src/test_workflow/integ_test/distribution_rpm.py index efed2a86db..4e8b280c84 100644 --- a/src/test_workflow/integ_test/distribution_rpm.py +++ b/src/test_workflow/integ_test/distribution_rpm.py @@ -25,6 +25,10 @@ def install_dir(self) -> str: def config_path(self) -> str: return os.path.join(os.sep, "etc", self.filename, self.config_filename) + @property + def data_dir(self) -> str: + return os.path.join(os.sep, "var", "lib", self.filename) + @property def log_dir(self) -> str: return os.path.join(os.sep, "var", "log", self.filename) @@ -40,6 +44,8 @@ def install(self, bundle_name: str) -> None: '-y', self.filename, '&&', + f'sudo rm -rf {os.path.dirname(self.config_path)} {self.data_dir} {self.log_dir}', + '&&', 'sudo', 'env', 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!', @@ -66,4 +72,4 @@ def start_cmd(self) -> str: def uninstall(self) -> None: logging.info(f"Uninstall {self.filename} package after the test") - subprocess.check_call(f"sudo yum remove -y {self.filename} && sudo rm -rf {os.path.dirname(self.config_path)} {self.log_dir}", shell=True) + subprocess.check_call(f"sudo yum remove -y {self.filename} && sudo rm -rf {os.path.dirname(self.config_path)} {self.data_dir} {self.log_dir}", shell=True) diff --git a/src/test_workflow/integ_test/distribution_tar.py b/src/test_workflow/integ_test/distribution_tar.py index e99ee34e40..1a8b5edf98 100644 --- a/src/test_workflow/integ_test/distribution_tar.py +++ b/src/test_workflow/integ_test/distribution_tar.py @@ -25,6 +25,10 @@ def install_dir(self) -> str: def config_path(self) -> str: return os.path.join(self.install_dir, "config", self.config_filename) + @property + def data_dir(self) -> str: + return os.path.join(self.install_dir, "data") + @property def log_dir(self) -> str: return os.path.join(self.install_dir, "logs") diff --git a/src/test_workflow/integ_test/distribution_zip.py b/src/test_workflow/integ_test/distribution_zip.py index 12991891a4..c82e1ab424 100644 --- a/src/test_workflow/integ_test/distribution_zip.py +++ b/src/test_workflow/integ_test/distribution_zip.py @@ -25,6 +25,10 @@ def install_dir(self) -> str: def config_path(self) -> str: return os.path.join(self.install_dir, "config", self.config_filename) + @property + def data_dir(self) -> str: + return os.path.join(self.install_dir, "data") + @property def log_dir(self) -> str: return os.path.join(self.install_dir, "logs") diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py index dc26cca156..ee2687fd05 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py @@ -32,6 +32,10 @@ def test_config_path(self) -> None: self.assertEqual(self.distribution_deb.config_path, os.path.join(os.sep, "etc", "opensearch", "opensearch.yml")) self.assertEqual(self.distribution_deb_dashboards.config_path, os.path.join(os.sep, "etc", "opensearch-dashboards", "opensearch_dashboards.yml")) + def test_data_dir(self) -> None: + self.assertEqual(self.distribution_deb.data_dir, os.path.join(os.sep, "var", "lib", "opensearch")) + self.assertEqual(self.distribution_deb_dashboards.data_dir, os.path.join(os.sep, "var", "lib", "opensearch-dashboards")) + def test_log_dir(self) -> None: self.assertEqual(self.distribution_deb.log_dir, os.path.join(os.sep, "var", "log", "opensearch")) self.assertEqual(self.distribution_deb_dashboards.log_dir, os.path.join(os.sep, "var", "log", "opensearch-dashboards")) @@ -45,6 +49,7 @@ def test_install(self, check_call_mock: Mock) -> None: self.assertEqual( ( "sudo dpkg --purge opensearch && " + f"sudo rm -rf {os.path.dirname(self.distribution_deb.config_path)} {self.distribution_deb.data_dir} {self.distribution_deb.log_dir} && " "sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! " "dpkg --install opensearch.deb && " f"sudo chmod 0666 {self.distribution_deb.config_path} {os.path.dirname(self.distribution_deb.config_path)}/jvm.options && " @@ -64,6 +69,7 @@ def test_install_opensearch_dashboards(self, check_call_mock: Mock) -> None: self.assertEqual( ( "sudo dpkg --purge opensearch-dashboards && " + f"sudo rm -rf {os.path.dirname(self.distribution_deb_dashboards.config_path)} {self.distribution_deb_dashboards.data_dir} {self.distribution_deb_dashboards.log_dir} && " "sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! " "dpkg --install opensearch-dashboards.deb && " f"sudo chmod 0666 {self.distribution_deb_dashboards.config_path} && " @@ -84,4 +90,10 @@ def test_uninstall(self, check_call_mock: Mock) -> None: args_list = check_call_mock.call_args_list self.assertEqual(check_call_mock.call_count, 1) - self.assertEqual(f"sudo dpkg --purge opensearch && sudo rm -rf {os.path.dirname(self.distribution_deb.config_path)} {self.distribution_deb.log_dir}", args_list[0][0][0]) + self.assertEqual( + ( + "sudo dpkg --purge opensearch && " + f"sudo rm -rf {os.path.dirname(self.distribution_deb.config_path)} {self.distribution_deb.data_dir} {self.distribution_deb.log_dir}" + ), + args_list[0][0][0], + ) diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py index 1d912e6932..41ce82a268 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py @@ -32,6 +32,10 @@ def test_config_path(self) -> None: self.assertEqual(self.distribution_rpm.config_path, os.path.join(os.sep, "etc", "opensearch", "opensearch.yml")) self.assertEqual(self.distribution_rpm_dashboards.config_path, os.path.join(os.sep, "etc", "opensearch-dashboards", "opensearch_dashboards.yml")) + def test_data_dir(self) -> None: + self.assertEqual(self.distribution_rpm.data_dir, os.path.join(os.sep, "var", "lib", "opensearch")) + self.assertEqual(self.distribution_rpm_dashboards.data_dir, os.path.join(os.sep, "var", "lib", "opensearch-dashboards")) + def test_log_dir(self) -> None: self.assertEqual(self.distribution_rpm.log_dir, os.path.join(os.sep, "var", "log", "opensearch")) self.assertEqual(self.distribution_rpm_dashboards.log_dir, os.path.join(os.sep, "var", "log", "opensearch-dashboards")) @@ -45,6 +49,7 @@ def test_install(self, check_call_mock: Mock) -> None: self.assertEqual( ( "sudo yum remove -y opensearch && " + f"sudo rm -rf {os.path.dirname(self.distribution_rpm.config_path)} {self.distribution_rpm.data_dir} {self.distribution_rpm.log_dir} && " "sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! " "yum install -y opensearch.rpm && " f"sudo chmod 0666 {self.distribution_rpm.config_path} {os.path.dirname(self.distribution_rpm.config_path)}/jvm.options && " @@ -64,6 +69,7 @@ def test_install_opensearch_dashboards(self, check_call_mock: Mock) -> None: self.assertEqual( ( "sudo yum remove -y opensearch-dashboards && " + f"sudo rm -rf {os.path.dirname(self.distribution_rpm_dashboards.config_path)} {self.distribution_rpm_dashboards.data_dir} {self.distribution_rpm_dashboards.log_dir} && " "sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! " "yum install -y opensearch-dashboards.rpm && " f"sudo chmod 0666 {self.distribution_rpm_dashboards.config_path} && " @@ -84,4 +90,10 @@ def test_uninstall(self, check_call_mock: Mock) -> None: args_list = check_call_mock.call_args_list self.assertEqual(check_call_mock.call_count, 1) - self.assertEqual(f"sudo yum remove -y opensearch && sudo rm -rf {os.path.dirname(self.distribution_rpm.config_path)} {self.distribution_rpm.log_dir}", args_list[0][0][0]) + self.assertEqual( + ( + "sudo yum remove -y opensearch && " + f"sudo rm -rf {os.path.dirname(self.distribution_rpm.config_path)} {self.distribution_rpm.data_dir} {self.distribution_rpm.log_dir}" + ), + args_list[0][0][0], + ) diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_tar.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_tar.py index 766dc11e6c..a4207aa81b 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_tar.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_tar.py @@ -34,6 +34,10 @@ def test_config_path(self) -> None: self.assertEqual(self.distribution_tar.config_path, os.path.join(self.work_dir, "opensearch-1.3.0", "config", "opensearch.yml")) self.assertEqual(self.distribution_tar_dashboards.config_path, os.path.join(self.work_dir, "opensearch-dashboards-1.3.0", "config", "opensearch_dashboards.yml")) + def test_data_dir(self) -> None: + self.assertEqual(self.distribution_tar.data_dir, os.path.join(self.work_dir, "opensearch-1.3.0", "data")) + self.assertEqual(self.distribution_tar_dashboards.data_dir, os.path.join(self.work_dir, "opensearch-dashboards-1.3.0", "data")) + def test_log_dir(self) -> None: self.assertEqual(self.distribution_tar.log_dir, os.path.join(self.work_dir, "opensearch-1.3.0", "logs")) self.assertEqual(self.distribution_tar_dashboards.log_dir, os.path.join(self.work_dir, "opensearch-dashboards-1.3.0", "logs")) diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_zip.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_zip.py index e5d7a7845d..0aa85c9bcb 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_zip.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_zip.py @@ -37,6 +37,10 @@ def test_config_path(self) -> None: self.assertEqual(self.distribution_zip.config_path, os.path.join(self.work_dir, f"{self.product}-{self.version}", "config", "opensearch.yml")) self.assertEqual(self.distribution_zip_dashboards.config_path, os.path.join(self.work_dir, f"{self.product_dashboards}-{self.version}", "config", "opensearch_dashboards.yml")) + def test_data_dir(self) -> None: + self.assertEqual(self.distribution_zip.data_dir, os.path.join(self.work_dir, f"{self.product}-{self.version}", "data")) + self.assertEqual(self.distribution_zip_dashboards.data_dir, os.path.join(self.work_dir, f"{self.product_dashboards}-{self.version}", "data")) + def test_log_dir(self) -> None: self.assertEqual(self.distribution_zip.log_dir, os.path.join(self.work_dir, f"{self.product}-{self.version}", "logs")) self.assertEqual(self.distribution_zip_dashboards.log_dir, os.path.join(self.work_dir, f"{self.product_dashboards}-{self.version}", "logs"))