forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_run_perf_test.py
50 lines (39 loc) · 1.56 KB
/
test_run_perf_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
import os
import unittest
from typing import Any
from unittest.mock import Mock, patch
import pytest
from run_perf_test import main
class TestRunPerfTest(unittest.TestCase):
@pytest.fixture(autouse=True)
def _capfd(self, capfd: Any) -> None:
self.capfd = capfd
@patch("argparse._sys.argv", ["run_perf_test.py", "--help"])
def test_usage(self) -> None:
with self.assertRaises(SystemExit):
main()
out, _ = self.capfd.readouterr()
self.assertTrue(out.startswith("usage:"))
BUNDLE_MANIFEST_PATH = os.path.join(
os.path.dirname(__file__),
"jenkins",
"data",
)
CONFIG_ROOT_PATH = os.path.join(
os.path.dirname(__file__),
"data",
)
OPENSEARCH_BUNDLE_MANIFEST = os.path.realpath(os.path.join(BUNDLE_MANIFEST_PATH, "opensearch-1.3.0-bundle.yml"))
PERF_TEST_CONFIG = os.path.realpath(os.path.join(CONFIG_ROOT_PATH, "perf-test-config.yml"))
@patch("argparse._sys.argv", ["run_perf_test.py", "--bundle-manifest", OPENSEARCH_BUNDLE_MANIFEST,
"--stack", "test-stack", "--config", PERF_TEST_CONFIG])
@patch("run_perf_test.PerfTestRunners.from_args")
def test_default_execute_perf_test(self, mock_runner: Mock, *mocks: Any) -> None:
main()
self.assertEqual(1, mock_runner.call_count)