|
| 1 | +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"). You may |
| 4 | +# not use this file except in compliance with the License. A copy of the |
| 5 | +# License is located at |
| 6 | +# |
| 7 | +# http://aws.amazon.com/apache2.0/ |
| 8 | +# |
| 9 | +# or in the "license" file accompanying this file. This file is distributed |
| 10 | +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 11 | +# express or implied. See the License for the specific language governing |
| 12 | +# permissions and limitations under the License. |
| 13 | + |
| 14 | +import os |
| 15 | +import pytest |
| 16 | + |
| 17 | +from acktest import k8s |
| 18 | + |
| 19 | + |
| 20 | +def pytest_addoption(parser): |
| 21 | + parser.addoption("--runslow", action="store_true", default=False, help="run slow tests") |
| 22 | + |
| 23 | + |
| 24 | +def pytest_configure(config): |
| 25 | + config.addinivalue_line( |
| 26 | + "markers", "canary: mark test to also run in canary tests" |
| 27 | + ) |
| 28 | + config.addinivalue_line( |
| 29 | + "markers", "service(arg): mark test associated with a given service" |
| 30 | + ) |
| 31 | + config.addinivalue_line( |
| 32 | + "markers", "slow: mark test as slow to run" |
| 33 | + ) |
| 34 | + |
| 35 | +def pytest_collection_modifyitems(config, items): |
| 36 | + if config.getoption("--runslow"): |
| 37 | + return |
| 38 | + skip_slow = pytest.mark.skip(reason="need --runslow option to run") |
| 39 | + for item in items: |
| 40 | + if "slow" in item.keywords: |
| 41 | + item.add_marker(skip_slow) |
| 42 | + |
| 43 | +# Provide a k8s client to interact with the integration test cluster |
| 44 | +@pytest.fixture(scope='class') |
| 45 | +def k8s_client(): |
| 46 | + return k8s._get_k8s_api_client() |
0 commit comments