Skip to content

Add integration test for agent #8094

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

Merged
merged 3 commits into from
Aug 6, 2025
Merged
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
48 changes: 47 additions & 1 deletion tests/suite/test_agent.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from kubernetes.stream import stream
from suite.utils.resources_utils import get_first_pod_name, wait_before_test
from suite.utils.resources_utils import get_file_contents, get_first_pod_name, wait_before_test


@pytest.mark.agentv3
Expand Down Expand Up @@ -45,3 +45,49 @@ def test_agent(self, kube_apis, ingress_controller_prerequisites, ingress_contro

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

# Test for agent.config file - verify the agent config exists inside the NIC pod
# The expected config that will be asserted against later
expected_config = """#
# /etc/nginx-agent/nginx-agent.conf
#
# Configuration file for NGINX Agent.
#

log:
# set log level (error, warn, info, debug; default "info")
level: info
# set log path. if empty, don't log to file.
path: /var/log/nginx-agent/

allowed_directories:
- /etc/nginx
- /usr/local/etc/nginx
- /usr/share/nginx/modules
- /var/run/nginx
- /var/log/nginx
#
# Command server settings to connect to a management plane server
#
#command:
# server:
# host: "agent.connect.nginx.com"
# port: 443
# auth:
# token: ""
# tls:
# skip_verify: false"""
expected_config = expected_config.strip()

# Get the actual config file content from the pod
config_contents = get_file_contents(
kube_apis.v1, "/etc/nginx-agent/nginx-agent.conf", pod_name, ingress_controller_prerequisites.namespace
)

# Normalize whitespace for comparison - remove trailing spaces from each line
def normalize_config(config_text):
return "\n".join(line.rstrip() for line in config_text.strip().split("\n"))

config_contents_normalized = normalize_config(config_contents)
expected_config_normalized = normalize_config(expected_config)
assert config_contents_normalized == expected_config_normalized
Loading