2019-08-29 20:14:07 +08:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
2019-08-29 19:57:04 +08:00
|
|
|
def pytest_addoption(parser):
|
2021-04-06 21:19:27 +08:00
|
|
|
parser.addoption(
|
|
|
|
"--island",
|
|
|
|
action="store",
|
|
|
|
default="",
|
|
|
|
help="Specify the Monkey Island address (host+port).",
|
|
|
|
)
|
|
|
|
parser.addoption(
|
|
|
|
"--no-gcp",
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
help="Use for no interaction with the cloud.",
|
|
|
|
)
|
|
|
|
parser.addoption(
|
|
|
|
"--quick-performance-tests",
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
help="If enabled performance tests won't reset island and won't send telemetries, "
|
|
|
|
"instead will just test performance of already present island state.",
|
|
|
|
)
|
2021-04-29 20:45:39 +08:00
|
|
|
parser.addoption(
|
2021-04-29 22:42:59 +08:00
|
|
|
"--run-performance-tests",
|
2021-04-29 20:45:39 +08:00
|
|
|
action="store_true",
|
|
|
|
default=False,
|
2021-04-29 22:42:59 +08:00
|
|
|
help="If enabled performance tests will be run.",
|
2021-04-29 20:45:39 +08:00
|
|
|
)
|
2021-09-27 19:08:52 +08:00
|
|
|
parser.addoption(
|
|
|
|
"--os",
|
|
|
|
action="store",
|
|
|
|
default=None,
|
|
|
|
help="Use to run Windows or Linux specific tests.",
|
|
|
|
)
|
2021-04-06 21:19:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
2019-08-29 20:14:07 +08:00
|
|
|
def island(request):
|
2019-09-11 17:39:28 +08:00
|
|
|
return request.config.getoption("--island")
|
2020-05-13 15:44:04 +08:00
|
|
|
|
|
|
|
|
2021-04-06 21:19:27 +08:00
|
|
|
@pytest.fixture(scope="session")
|
2020-05-13 15:44:04 +08:00
|
|
|
def no_gcp(request):
|
|
|
|
return request.config.getoption("--no-gcp")
|
|
|
|
|
|
|
|
|
2021-04-06 21:19:27 +08:00
|
|
|
@pytest.fixture(scope="session")
|
2020-05-13 15:44:04 +08:00
|
|
|
def quick_performance_tests(request):
|
|
|
|
return request.config.getoption("--quick-performance-tests")
|
2021-04-29 20:45:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
def pytest_runtest_setup(item):
|
2021-04-29 22:42:59 +08:00
|
|
|
if "run_performance_tests" in item.keywords and not item.config.getoption(
|
|
|
|
"--run-performance-tests"
|
|
|
|
):
|
2021-04-29 20:45:39 +08:00
|
|
|
pytest.skip(
|
2021-04-29 22:42:59 +08:00
|
|
|
"Skipping performance test because " "--run-performance-tests flag isn't specified."
|
2021-04-29 20:45:39 +08:00
|
|
|
)
|
2021-09-27 19:08:52 +08:00
|
|
|
|
2021-09-27 23:12:28 +08:00
|
|
|
if not item.config.getoption("--os"):
|
2021-09-27 19:08:52 +08:00
|
|
|
pytest.skip(
|
|
|
|
"Skipping OS specific test because"
|
|
|
|
"--os flag isn't specified."
|
|
|
|
" Specify --os with windows or linux as options."
|
|
|
|
)
|
2021-09-27 23:12:28 +08:00
|
|
|
|
|
|
|
os = [mark.args[0] for mark in item.iter_markers(name="os")]
|
|
|
|
|
|
|
|
if os and item.config.getoption("--os") not in os:
|
|
|
|
pytest.skip(
|
|
|
|
f'Skipping OS specific test. Run with "--os={os[0]}" if '
|
|
|
|
f"you want this test to be executed."
|
|
|
|
)
|