コード例 #1
0
    def setUp(self) -> None:
        self.data_path = os.path.realpath(
            os.path.join(os.path.dirname(__file__), "data"))
        self.manifest_filename = os.path.join(self.data_path,
                                              "opensearch-bundle-1.1.0.yml")
        self.manifest = BundleManifest.from_path(self.manifest_filename)

        self.manifest_distribution_filename = os.path.join(
            self.data_path, "opensearch-bundle-1.3.0.yml")
        self.manifest_distribution = BundleManifest.from_path(
            self.manifest_distribution_filename)
コード例 #2
0
    def test_install_maven_dependencies_local(self, mock_request: Mock,
                                              mock_copyfile: Mock,
                                              mock_makedirs: Mock) -> None:
        counter = ThreadSafeCounter()
        mock_copyfile.side_effect = counter.thread_safe_count

        dependency_installer = DependencyInstallerOpenSearch(
            self.DATA, BuildManifest.from_path(self.BUILD_MANIFEST),
            BundleManifest.from_path(self.DIST_MANIFEST_LOCAL))

        dependency_installer.install_maven_dependencies()

        mock_makedirs.assert_called_with(os.path.realpath(
            os.path.join(dependency_installer.maven_local_path, "org",
                         "opensearch", "notification")),
                                         exist_ok=True)
        mock_request.assert_not_called()
        self.assertEqual(counter.call_count, 2375)
        mock_copyfile.assert_has_calls([
            call(
                os.path.join(self.DATA, "builds", "opensearch", "maven", "org",
                             "opensearch", "notification",
                             "alerting-notification-1.2.0.0.jar"),
                os.path.realpath(
                    os.path.join(dependency_installer.maven_local_path, "org",
                                 "opensearch", "notification",
                                 "alerting-notification-1.2.0.0.jar")))
        ])
コード例 #3
0
    def __init__(self, path: str, build_dir: str, bundle_dir: str) -> None:
        self.path = path
        self.build_dir = build_dir
        self.bundle_dir = bundle_dir

        self.bundle_manifest = BundleManifest.from_urlpath("/".join([self.path.rstrip("/"), self.bundle_dir]))
        self.build_manifest = BuildManifest.from_urlpath("/".join([self.path.rstrip("/"), self.build_dir]))
コード例 #4
0
    def test_install_maven_dependencies_remote(self, mock_request, mock_copyfile, mock_makedirs):
        counter = ThreadSafeCounter()
        mock_request.side_effect = counter.thread_safe_count
        dependency_installer = DependencyInstallerOpenSearch(
            "https://ci.opensearch.org/x/y",
            BuildManifest.from_path(self.BUILD_MANIFEST),
            BundleManifest.from_path(self.DIST_MANIFEST_REMOTE)
        )

        dependency_installer.install_maven_dependencies()
        self.assertEqual(counter.call_count, 2375)

        mock_makedirs.assert_called_with(
            os.path.realpath(
                os.path.join(
                    dependency_installer.maven_local_path, "org", "opensearch", "notification"
                )
            ),
            exist_ok=True
        )
        mock_copyfile.assert_not_called()
        mock_request.assert_has_calls([
            call(
                "https://ci.opensearch.org/x/y/builds/opensearch/maven/org/opensearch/notification/alerting-notification-1.2.0.0.jar",
                os.path.realpath(os.path.join(dependency_installer.maven_local_path, "org", "opensearch", "notification", "alerting-notification-1.2.0.0.jar"))
            )
        ])
コード例 #5
0
 def test_versions(self) -> None:
     self.assertTrue(len(BundleManifest.VERSIONS))
     for version in BundleManifest.VERSIONS:
         manifest = BundleManifest.from_path(
             os.path.join(
                 self.data_path, "bundle",
                 f"opensearch-bundle-schema-version-{version}.yml"))
         self.assertEqual(version, manifest.version)
コード例 #6
0
def main():
    args = TestArgs()
    console.configure(level=args.logging_level)
    with TemporaryDirectory(keep=args.keep) as work_dir:
        bundle_manifest = BundleManifest.from_urlpath(
            args.paths.get("opensearch", os.getcwd()))
        BwcTestSuite(bundle_manifest, work_dir.name, args.component,
                     args.keep).execute()
コード例 #7
0
def main() -> int:
    """
        Entry point for Performance Test with bundle manifest, config file containing the required arguments for running
        rally test and the stack name for the cluster. Will call out in test.sh with perf as argument
    """
    perf_args = PerfArgs()
    manifest = BundleManifest.from_file(perf_args.bundle_manifest)
    PerfTestRunners.from_args(perf_args, manifest).run()
    return 0
 def setUp(self) -> None:
     os.chdir(os.path.dirname(__file__))
     self.bundle_manifest = BundleManifest.from_path(self.BUNDLE_MANIFEST)
     self.build_manifest = BuildManifest.from_path(self.BUILD_MANIFEST)
     self.test_manifest = TestManifest.from_path(self.TEST_MANIFEST)
     self.work_dir = Path("test_dir")
     self.test_recorder = MagicMock()
     self.save_logs = MagicMock()
     self.test_recorder.test_results_logs = self.save_logs
コード例 #9
0
 def setUp(self) -> None:
     self.manifest = BundleManifest.from_path(self.BUNDLE_MANIFEST)
     self.stack_name = "stack"
     self.config = {
         "Constants": {
             "SecurityGroupId": "sg-00000000",
             "VpcId": "vpc-12345",
             "AccountId": "12345678",
             "Region": "us-west-2",
             "Role": "role-arn"
         }
     }
コード例 #10
0
 def setUp(self):
     self.data_path = os.path.realpath(
         os.path.join(os.path.dirname(__file__), "data"))
     self.manifest_filename = os.path.join(self.data_path,
                                           "bundle_manifest.yml")
     self.manifest = BundleManifest.from_path(self.manifest_filename)
     self.endpoint = None
     self.perf_test_suite = PerfTestSuite(
         bundle_manifest=self.manifest,
         endpoint=None,
         security=False,
         current_workspace="current_workspace")
    def test_run(self, mock_git: Mock, mock_temp_directory: Mock, *mocks: Any) -> None:
        mock_temp_directory.return_value.__enter__.return_value.name = tempfile.gettempdir()

        perf_args = PerfArgs()
        test_manifest = BundleManifest.from_file(perf_args.bundle_manifest)
        runner = PerfTestRunners.from_args(perf_args, test_manifest)
        runner.run()

        mock_git.assert_called_with("https://github.com/opensearch-project/plugin-name.git", "main",
                                    os.path.join(tempfile.gettempdir(), "plugin-name"))

        self.assertEqual(mock_git.call_count, 1)
        self.assertEqual(mock_temp_directory.call_count, 1)
コード例 #12
0
 def test_install_build_dependencies_local(self, mock_request, mock_copyfile, mock_makedirs):
     dependency_installer = DependencyInstallerOpenSearch(
         self.DATA,
         BuildManifest.from_path(self.BUILD_MANIFEST),
         BundleManifest.from_path(self.DIST_MANIFEST_LOCAL)
     )
     dependencies = dict({"opensearch-job-scheduler": "1.1.0.0"})
     dependency_installer.install_build_dependencies(dependencies, os.path.dirname(__file__))
     mock_makedirs.assert_called_with(os.path.dirname(__file__), exist_ok=True)
     mock_request.assert_not_called()
     mock_copyfile.assert_called_once_with(
         os.path.join(self.DATA, "builds", "opensearch", "plugins", "opensearch-job-scheduler-1.1.0.0.zip"),
         os.path.realpath(os.path.join(os.path.dirname(__file__), "opensearch-job-scheduler-1.1.0.0.zip")),
     )
コード例 #13
0
    def test_install_maven_dependencies_remote_failure(self, mock_request, mock_copyfile, mock_makedirs):
        def mock_retrieve(source, dest):
            raise HTTPError(url=source, hdrs={}, fp=None, msg="Not Found", code=404)

        mock_request.side_effect = mock_retrieve

        dependency_installer = DependencyInstallerOpenSearch(
            "https://ci.opensearch.org/x/y",
            BuildManifest.from_path(self.BUILD_MANIFEST),
            BundleManifest.from_path(self.DIST_MANIFEST_REMOTE)
        )

        with self.assertRaises(HTTPError) as ctx:
            dependency_installer.install_maven_dependencies()
        self.assertEqual(str(ctx.exception), "HTTP Error 404: Not Found")
コード例 #14
0
 def test_install_build_dependencies_remote(self, mock_request: Mock,
                                            mock_copyfile: Mock,
                                            mock_makedirs: Mock) -> None:
     dependency_installer = DependencyInstallerOpenSearch(
         "https://ci.opensearch.org/x/y",
         BuildManifest.from_path(self.BUILD_MANIFEST),
         BundleManifest.from_path(self.DIST_MANIFEST_REMOTE))
     dependencies = dict({"opensearch-job-scheduler": "1.1.0.0"})
     dependency_installer.install_build_dependencies(
         dependencies, os.path.dirname(__file__))
     mock_makedirs.assert_called_with(os.path.dirname(__file__),
                                      exist_ok=True)
     mock_copyfile.assert_not_called()
     mock_request.assert_called_once_with(
         "https://ci.opensearch.org/x/y/builds/opensearch/plugins/opensearch-job-scheduler-1.1.0.0.zip",
         os.path.realpath(
             os.path.join(os.path.dirname(__file__),
                          "opensearch-job-scheduler-1.1.0.0.zip")),
     )
コード例 #15
0
 def setUp(self):
     self.manifest = BundleManifest.from_path(self.BUNDLE_MANIFEST)
     self.stack_name = "stack"
     self.security = "disable"
     config = {
         "Constants": {
             "SecurityGroupId": "sg-00000000",
             "VpcId": "vpc-12345",
             "AccountId": "12345678",
             "Region": "us-west-2",
             "Role": "role-arn"
         }
     }
     self.perf_test_cluster = PerfTestCluster(
         bundle_manifest=self.manifest,
         config=config,
         stack_name=self.stack_name,
         security=self.security,
         current_workspace="current_workspace")
コード例 #16
0
    def setUp(self) -> None:
        self.args = Mock()
        self.args.workload = "nyc_taxis"
        self.args.workload_options = "{}"
        self.args.warmup_iters = 0
        self.args.test_iters = 1
        self.data_path = os.path.realpath(
            os.path.join(os.path.dirname(__file__), "data"))
        self.manifest_filename = os.path.join(self.data_path,
                                              "bundle_manifest.yml")
        self.manifest = BundleManifest.from_path(self.manifest_filename)
        self.endpoint = "abc.com"

        self.perf_test_suite = PerfTestSuite(
            bundle_manifest=self.manifest,
            endpoint=self.endpoint,
            security=False,
            current_workspace="current_workspace",
            test_results_path="test/results/",
            args=self.args)
コード例 #17
0
def main():
    """
        Entry point for Performance Test with bundle manifest, config file containing the required arguments for running
        rally test and the stack name for the cluster. Will call out in test.sh with perf as argument
    """
    parser = argparse.ArgumentParser(description="Test an OpenSearch Bundle")
    parser.add_argument("--bundle-manifest",
                        type=argparse.FileType("r"),
                        help="Bundle Manifest file.",
                        required=True)
    parser.add_argument("--stack",
                        dest="stack",
                        help="Stack name for performance test")
    parser.add_argument("--config",
                        type=argparse.FileType("r"),
                        help="Config file.",
                        required=True)
    parser.add_argument("--keep",
                        dest="keep",
                        action="store_true",
                        help="Do not delete the working temporary directory.")
    args = parser.parse_args()

    manifest = BundleManifest.from_file(args.bundle_manifest)
    config = yaml.safe_load(args.config)

    with TemporaryDirectory(keep=args.keep, chdir=True) as work_dir:
        current_workspace = os.path.join(work_dir.name, "infra")
        with GitRepository(get_infra_repo_url(), "main", current_workspace):
            security = "security" in manifest.components
            with WorkingDirectory(current_workspace):
                with PerfTestCluster.create(
                        manifest, config, args.stack, security,
                        current_workspace) as (test_cluster_endpoint,
                                               test_cluster_port):
                    perf_test_suite = PerfTestSuite(manifest,
                                                    test_cluster_endpoint,
                                                    security,
                                                    current_workspace)
                    perf_test_suite.execute()
コード例 #18
0
    def setUp(self):
        os.chdir(os.path.dirname(__file__))

        self.manifest = BundleManifest.from_path(self.MANIFEST)
        self.bwc_test_suite = BwcTestSuite(manifest=self.manifest, work_dir=".", component=None, keep=False)
コード例 #19
0
 def to_manifest(self) -> BundleManifest:
     return BundleManifest(self.data)
コード例 #20
0
 def setUp(self):
     os.chdir(os.path.dirname(__file__))
     self.bundle_manifest = BundleManifest.from_path(self.BUNDLE_MANIFEST)
     self.build_manifest = BuildManifest.from_path(self.BUILD_MANIFEST)
     self.test_manifest = TestManifest.from_path(self.TEST_MANIFEST)