Skip to content

Commit dde207a

Browse files
committed
make agent tests run on all images
1 parent 83e4f98 commit dde207a

File tree

2 files changed

+47
-12
lines changed

2 files changed

+47
-12
lines changed

.github/data/matrix-smoke-nap.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"image": "debian-plus-nap",
3030
"type": "plus",
3131
"nap_modules": "waf",
32-
"marker": "'appprotect_watch or appprotect_batch or appprotect_integration or appprotect_waf_policies_vsr'",
32+
"marker": "'appprotect and not appprotect_waf_policies'",
3333
"platforms": "linux/amd64"
3434
},
3535
{
@@ -63,14 +63,6 @@
6363
"nap_modules": "dos",
6464
"marker": "dos_learning",
6565
"platforms": "linux/amd64"
66-
},
67-
{
68-
"label": "AGENT 1/1",
69-
"image": "debian-plus-nap",
70-
"type": "plus",
71-
"nap_modules": "waf",
72-
"marker": "agent",
73-
"platforms": "linux/amd64"
7466
}
7567
],
7668
"k8s": []

tests/suite/test_agent_app_protect.py renamed to tests/suite/test_agent.py

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
@pytest.mark.skip_for_nginx_oss
7-
@pytest.mark.agent
7+
@pytest.mark.appprotect
88
@pytest.mark.parametrize(
99
"crd_ingress_controller_with_ap",
1010
[
@@ -18,7 +18,7 @@
1818
],
1919
indirect=["crd_ingress_controller_with_ap"],
2020
)
21-
class TestAppProtectAgent:
21+
class TestAppProtectAgentV2:
2222
def test_ap_agent(self, kube_apis, ingress_controller_prerequisites, crd_ingress_controller_with_ap):
2323
pod_name = get_first_pod_name(kube_apis.v1, "nginx-ingress")
2424
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
4747
result_conf = str(resp)
4848

4949
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

Comments
 (0)