diff --git a/tests/e2e_test.py b/tests/e2e_test.py index 250b635..1b653b9 100644 --- a/tests/e2e_test.py +++ b/tests/e2e_test.py @@ -9,6 +9,7 @@ TESTS_PATH = Path(__file__).parent MANIFESTS_PATH = TESTS_PATH / "manifests" +TEST_NS = "test-ns" TIMEOUT = SYNC_INTERVAL * 3 @@ -26,6 +27,7 @@ def run(*, command: list[str], **kw_args) -> str: @pytest.fixture(scope="session") def setup(): try: + run(command=["kubectl", "create", "namespace", TEST_NS]) run( command=[ "helm", @@ -57,7 +59,7 @@ def setup(): ] ) - run(command=["kubectl", "apply", "-f", f"{MANIFESTS_PATH}/metrics-generator.yaml"]) + run(command=["kubectl", "apply", "-f", f"{MANIFESTS_PATH}/metrics-generator.yaml", "--namespace", TEST_NS]) yield finally: run( @@ -74,19 +76,21 @@ def setup(): "prometheus-adapter", ] ) - run(command=["kubectl", "delete", "-f", f"{MANIFESTS_PATH}/metrics-generator.yaml"]) + run(command=["kubectl", "delete", "-f", f"{MANIFESTS_PATH}/metrics-generator.yaml", "--namespace", TEST_NS]) + run(command=["kubectl", "delete", "namespace", TEST_NS]) def deploy_target(manifest: str): - run(command=["kubectl", "apply", "-f", f"{MANIFESTS_PATH}/{manifest}"]) + run(command=["kubectl", "apply", "-f", f"{MANIFESTS_PATH}/{manifest}", "--namespace", TEST_NS]) def delete_target(manifest: str): - run(command=["kubectl", "delete", "-f", f"{MANIFESTS_PATH}/{manifest}"]) + run(command=["kubectl", "delete", "-f", f"{MANIFESTS_PATH}/{manifest}", "--namespace", TEST_NS]) def run_scaler(): - return subprocess.Popen(["python", f"{TESTS_PATH.parent}/main.py"]) + # return subprocess.Popen(["python", f"{TESTS_PATH.parent}/main.py", "--hpa-namespace", TEST_NS]) + return subprocess.Popen(["python", f"{TESTS_PATH.parent}/main.py", "--hpa-namespace", TEST_NS]) def set_foo_metric_value(value: int): @@ -111,6 +115,8 @@ def wait_deployment_scale(*, name: str, replicas: int): f"--for=jsonpath={{.spec.replicas}}={replicas}", "deployment", name, + "--namespace", + TEST_NS, f"--timeout={TIMEOUT}s", ] )