Esempio n. 1
0
 def test_find_build_script_does_not_exist(self, *mocks):
     with self.assertRaisesRegex(
             ScriptFinder.ScriptNotFoundError,
             "Could not find build.sh script. Looked in .*",
     ):
         ScriptFinder.find_build_script("OpenSearch", "anything",
                                        self.component_without_scripts)
Esempio n. 2
0
 def test_find_build_script_component_script(self):
     self.assertEqual(
         os.path.join(self.component_with_scripts, "build.sh"),
         ScriptFinder.find_build_script("OpenSearch", "foobar",
                                        self.component_with_scripts),
         msg="A component with a script resolves to the script at the root.",
     )
Esempio n. 3
0
    def build(self, build_recorder: BuildRecorder) -> None:

        # List of components whose build scripts support `-d` parameter
        # Bundled plugins do not need `-d` as they are java based zips
        DISTRIBUTION_SUPPORTED_COMPONENTS = [
            "OpenSearch", "OpenSearch-Dashboards"
        ]

        build_script = ScriptFinder.find_build_script(
            self.target.name, self.component.name,
            self.git_repo.working_directory)

        build_command = " ".join(
            filter(None, [
                "bash",
                build_script,
                f"-v {self.target.version}",
                f"-q {self.target.qualifier}"
                if self.target.qualifier else None,
                f"-p {self.target.platform}",
                f"-a {self.target.architecture}",
                f"-d {self.target.distribution}" if self.component.name
                in DISTRIBUTION_SUPPORTED_COMPONENTS else None,
                f"-s {str(self.target.snapshot).lower()}",
                f"-o {self.output_path}",
            ]))

        self.git_repo.execute(build_command)
        build_recorder.record_component(self.component.name, self.git_repo)
Esempio n. 4
0
 def test_find_build_script_component_script_in_folder_with_default(self):
     self.assertEqual(
         os.path.join(ScriptFinder.component_scripts_path, "OpenSearch",
                      "build.sh"),
         ScriptFinder.find_build_script("OpenSearch", "OpenSearch",
                                        self.component_with_scripts_folder),
         msg="A component with a scripts folder resolves to the override.",
     )
Esempio n. 5
0
 def test_find_build_script_component_override(self):
     self.assertEqual(
         os.path.join(ScriptFinder.component_scripts_path, "OpenSearch",
                      "build.sh"),
         ScriptFinder.find_build_script("OpenSearch", "OpenSearch",
                                        self.component_without_scripts),
         msg="A component without scripts resolves to a component override.",
     )
Esempio n. 6
0
 def test_find_build_script_opensearch_dashboards_default(self):
     self.assertEqual(
         os.path.join(ScriptFinder.default_scripts_path,
                      "opensearch-dashboards", "build.sh"),
         ScriptFinder.find_build_script("OpenSearch-Dashboards", "invalid",
                                        self.component_without_scripts),
         msg="A component without an override resolves to a default.",
     )
Esempio n. 7
0
 def test_find_build_script_component_script_in_folder(self):
     self.assertEqual(
         os.path.join(self.component_with_scripts_folder, "scripts",
                      "build.sh"),
         ScriptFinder.find_build_script("OpenSearch", "foobar",
                                        self.component_with_scripts_folder),
         msg=
         "A component with a scripts folder resolves to a script in that folder.",
     )
    def build(self, build_recorder: BuildRecorder) -> None:
        build_script = ScriptFinder.find_build_script(
            self.target.name, self.component.name,
            self.git_repo.working_directory)

        build_command = " ".join([
            "bash",
            build_script,
            "-v",
            self.target.version,
            "-p",
            self.target.platform,
            "-a",
            self.target.architecture,
            "-s",
            str(self.target.snapshot).lower(),
            "-o",
            self.output_path,
        ])

        self.git_repo.execute(build_command)
        build_recorder.record_component(self.component.name, self.git_repo)