|
4 | 4 |
|
5 | 5 |
|
6 | 6 | @pytest.mark.skip_for_nginx_oss
|
7 |
| -@pytest.mark.agent |
| 7 | +@pytest.mark.appprotect |
8 | 8 | @pytest.mark.parametrize(
|
9 | 9 | "crd_ingress_controller_with_ap",
|
10 | 10 | [
|
|
18 | 18 | ],
|
19 | 19 | indirect=["crd_ingress_controller_with_ap"],
|
20 | 20 | )
|
21 |
| -class TestAppProtectAgent: |
| 21 | +class TestAppProtectAgentV2: |
22 | 22 | def test_ap_agent(self, kube_apis, ingress_controller_prerequisites, crd_ingress_controller_with_ap):
|
23 | 23 | pod_name = get_first_pod_name(kube_apis.v1, "nginx-ingress")
|
24 | 24 | log = kube_apis.v1.read_namespaced_pod_log(pod_name, ingress_controller_prerequisites.namespace)
|
@@ -47,4 +47,47 @@ def test_ap_agent(self, kube_apis, ingress_controller_prerequisites, crd_ingress
|
47 | 47 | result_conf = str(resp)
|
48 | 48 |
|
49 | 49 | assert f"Failed to get nginx-agent version: fork/exec /usr/bin/nginx-agent" not in log
|
50 |
| - assert "nginx-agent version " in result_conf |
| 50 | + assert "nginx-agent version v2" in result_conf |
| 51 | + |
| 52 | + |
| 53 | +@pytest.mark.parametrize( |
| 54 | + "ingress_controller", |
| 55 | + [ |
| 56 | + { |
| 57 | + "extra_args": [ |
| 58 | + f"-agent=true", |
| 59 | + ] |
| 60 | + } |
| 61 | + ], |
| 62 | + indirect=["ingress_controller"], |
| 63 | +) |
| 64 | +class TestAgentV3: |
| 65 | + def test_ap_agent(self, kube_apis, ingress_controller_prerequisites, ingress_controller): |
| 66 | + pod_name = get_first_pod_name(kube_apis.v1, "nginx-ingress") |
| 67 | + log = kube_apis.v1.read_namespaced_pod_log(pod_name, ingress_controller_prerequisites.namespace) |
| 68 | + |
| 69 | + command = ["/usr/bin/nginx-agent", "-v"] |
| 70 | + retries = 0 |
| 71 | + while retries <= 3: |
| 72 | + wait_before_test() |
| 73 | + try: |
| 74 | + resp = stream( |
| 75 | + kube_apis.v1.connect_get_namespaced_pod_exec, |
| 76 | + pod_name, |
| 77 | + ingress_controller_prerequisites.namespace, |
| 78 | + command=command, |
| 79 | + stderr=True, |
| 80 | + stdin=False, |
| 81 | + stdout=True, |
| 82 | + tty=False, |
| 83 | + ) |
| 84 | + break |
| 85 | + except Exception as e: |
| 86 | + print(f"Error: {e}") |
| 87 | + retries += 1 |
| 88 | + if retries == 3: |
| 89 | + raise e |
| 90 | + result_conf = str(resp) |
| 91 | + |
| 92 | + assert f"Failed to get nginx-agent version: fork/exec /usr/bin/nginx-agent" not in log |
| 93 | + assert "nginx-agent version v3" in result_conf |
0 commit comments