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 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)
Beispiel #3
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()