Exemplo n.º 1
0
 def test_find_integ_test_script_does_not_exist(self, *mocks):
     with self.assertRaisesRegex(
             ScriptFinder.ScriptNotFoundError,
             "Could not find integtest.sh script. Looked in .*",
     ):
         ScriptFinder.find_integ_test_script("anything",
                                             self.component_without_scripts)
Exemplo n.º 2
0
 def test_find_integ_test_script_default(self):
     self.assertEqual(
         os.path.join(ScriptFinder.default_scripts_path, "integtest.sh"),
         ScriptFinder.find_integ_test_script(
             "invalid", self.component_without_scripts),
         msg="A component without an override resolves to a default.",
     )
Exemplo n.º 3
0
    def execute_integtest_sh(self, endpoint: str, port: int, security: bool,
                             test_config: str) -> int:
        script = ScriptFinder.find_integ_test_script(
            self.component.name, self.repo.working_directory)
        if os.path.exists(script):
            cmd = f"{script} -b {endpoint} -p {port} -s {str(security).lower()} -v {self.bundle_manifest.build.version}"
            self.repo_work_dir = os.path.join(
                self.repo.dir, self.test_config.working_directory
            ) if self.test_config.working_directory is not None else self.repo.dir
            (status, stdout, stderr) = execute(cmd, self.repo_work_dir, True,
                                               False)

            test_result_data = TestResultData(self.component.name, test_config,
                                              status, stdout, stderr,
                                              self.test_artifact_files)
            self.save_logs.save_test_result_data(test_result_data)
            if stderr:
                logging.info("Integration test run failed for component " +
                             self.component.name)
                logging.info(stderr)
            return status
        else:
            logging.info(
                f"{script} does not exist. Skipping integ tests for {self.component.name}"
            )
            return 0
Exemplo n.º 4
0
 def test_find_integ_test_script_component_script_in_folder(self):
     self.assertEqual(
         os.path.join(self.component_with_scripts_folder, "scripts",
                      "integtest.sh"),
         ScriptFinder.find_integ_test_script(
             "foobar", self.component_with_scripts_folder),
         msg="A component with a scripts folder resolves to an override.",
     )
Exemplo n.º 5
0
 def test_find_integ_test_script_component_script(self):
     self.assertEqual(
         os.path.join(ScriptFinder.component_scripts_path, "OpenSearch",
                      "integtest.sh"),
         ScriptFinder.find_integ_test_script("OpenSearch",
                                             self.component_with_scripts),
         msg="A component with a script resolves to the script at the root.",
     )
Exemplo n.º 6
0
 def test_find_integ_test_script_component_override(self):
     self.assertEqual(
         os.path.join(ScriptFinder.component_scripts_path, "OpenSearch",
                      "integtest.sh"),
         ScriptFinder.find_integ_test_script(
             "OpenSearch", self.component_without_scripts),
         msg="A component without scripts resolves to a component override.",
     )
Exemplo n.º 7
0
 def test_find_integ_test_script_component_script_in_folder_with_default(
         self):
     self.assertEqual(
         os.path.join(ScriptFinder.component_scripts_path, "OpenSearch",
                      "integtest.sh"),
         ScriptFinder.find_integ_test_script(
             "OpenSearch", self.component_with_scripts_folder),
         msg=
         "A component with a scripts folder resolves to a script in that folder.",
     )