Esempio n. 1
0
    def test_bundle_install_plugin(self, path_isfile: Mock) -> None:
        manifest_path = os.path.join(os.path.dirname(__file__), "data",
                                     "opensearch-build-linux-1.1.0.yml")
        artifacts_path = os.path.join(os.path.dirname(__file__), "data",
                                      "artifacts")
        bundle = BundleOpenSearch(BuildManifest.from_path(manifest_path),
                                  artifacts_path, MagicMock())

        plugin = bundle.components['job-scheduler']

        with patch("shutil.copyfile") as mock_copyfile:
            with patch("subprocess.check_call") as mock_check_call:
                bundle.install_plugin(plugin)

                self.assertEqual(mock_copyfile.call_count, 1)
                self.assertEqual(mock_check_call.call_count, 2)

                script = "opensearch-plugin.bat" if current_platform(
                ) == "windows" else "opensearch-plugin"
                install_plugin_bin = os.path.join(bundle.min_dist.archive_path,
                                                  "bin", script)
                mock_check_call.assert_has_calls([
                    call(
                        f'{install_plugin_bin} install --batch file:{os.path.join(bundle.tmp_dir.name, "opensearch-job-scheduler-1.1.0.0.zip")}',
                        cwd=bundle.min_dist.archive_path,
                        shell=True,
                    ),
                    call(
                        " ".join([
                            "bash",
                            ScriptFinder.find_install_script(
                                "opensearch-job-scheduler"),
                            "-v 1.1.0",
                            "-p linux",
                            "-a x64",
                            "-f",
                            artifacts_path,
                            "-o",
                            bundle.min_dist.archive_path,
                        ]),
                        cwd=bundle.min_dist.archive_path,
                        shell=True,
                    ),
                ])
        self.assertEqual(path_isfile.call_count, 2)
Esempio n. 2
0
 def __init__(
     self,
     version: str,
     patches: List[str] = [],
     platform: str = None,
     architecture: str = None,
     name: str = None,
     snapshot: bool = True,
     build_id: str = None,
     output_dir: str = "artifacts",
 ):
     self.build_id = os.getenv(
         "BUILD_NUMBER") or build_id or uuid.uuid4().hex
     self.name = name
     self.version = version
     self.patches = patches
     self.snapshot = snapshot
     self.architecture = architecture or current_architecture()
     self.platform = platform or current_platform()
     self.output_dir = output_dir
 def test_current_platform_lowercase(self,
                                     mock_subprocess: MagicMock) -> None:
     self.assertTrue(current_platform() == "windows")
 def test_current_platform(self) -> None:
     self.assertTrue(current_platform() in ["linux", "darwin", "windows"])
Esempio n. 5
0
 def install_plugin_script(self) -> str:
     return "opensearch-plugin.bat" if current_platform(
     ) == "windows" else "opensearch-plugin"
Esempio n. 6
0
 def test_current_platform_lowercase(self, mock_subprocess):
     self.assertTrue(current_platform() == "windows")