Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to check for agent #6111

Merged
merged 3 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/data/matrix-smoke-nap.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@
"nap_modules": "dos",
"marker": "dos_learning",
"platforms": "linux/amd64"
},
{
"label": "AGENT 1/1",
"image": "debian-plus-nap",
"type": "plus",
"nap_modules": "waf",
"marker": "agent",
"platforms": "linux/amd64"
}
],
"k8s": []
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pythonpath = [
addopts = "--tb=native -ra --disable-warnings -x -l --profile -v --strict-markers"
log_cli = true
markers =[
"agent",
"annotations",
"appprotect",
"appprotect_integration",
Expand Down
50 changes: 50 additions & 0 deletions tests/suite/utils/test_agent_app_protect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import pytest
from kubernetes.stream import stream
from suite.utils.resources_utils import get_first_pod_name, wait_before_test


@pytest.mark.skip_for_nginx_oss
@pytest.mark.agent
@pytest.mark.parametrize(
"crd_ingress_controller_with_ap",
[
{
"extra_args": [
"-enable-app-protect",
"-agent=true",
"-agent-instance-group=test-ic",
]
}
],
indirect=["crd_ingress_controller_with_ap"],
)
class TestAppProtectAgent:
def test_ap_agent(self, kube_apis, ingress_controller_prerequisites, crd_ingress_controller_with_ap):
pod_name = get_first_pod_name(kube_apis.v1, "nginx-ingress")
log = kube_apis.v1.read_namespaced_pod_log(pod_name, ingress_controller_prerequisites.namespace)

command = ["/usr/bin/nginx-agent", "-v"]
retries = 0
while retries <= 3:
wait_before_test()
try:
resp = stream(
kube_apis.v1.connect_get_namespaced_pod_exec,
pod_name,
ingress_controller_prerequisites.namespace,
command=command,
stderr=True,
stdin=False,
stdout=True,
tty=False,
)
break
except Exception as e:
print(f"Error: {e}")
retries += 1
if retries == 3:
raise e
result_conf = str(resp)

assert f"Failed to get nginx-agent version: fork/exec /usr/bin/nginx-agent" not in log
assert "nginx-agent version " in result_conf
Loading