Skip to content

Integration tests for N1C metrics #1210

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

spencerugbo
Copy link
Contributor

Proposed changes

This PR aims to add integration tests for N1C metrics.

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING document
  • I have run make install-tools and have attached any dependency changes to this pull request
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes
  • If applicable, I have updated any relevant documentation (README.md)
  • If applicable, I have tested my cross-platform changes on Ubuntu 22, Redhat 8, SUSE 15 and FreeBSD 13

@spencerugbo spencerugbo self-assigned this Aug 12, 2025
@spencerugbo spencerugbo requested a review from a team as a code owner August 12, 2025 16:24
@github-actions github-actions bot added chore Pull requests for routine tasks dependencies documentation Improvements or additions to documentation labels Aug 12, 2025
@spencerugbo spencerugbo changed the title Integration tests for n1c metrics Integration tests for N1C metrics Aug 12, 2025
// osVersion := Env(tb, "OS_VERSION")
buildTarget := Env(tb, "BUILD_TARGET")
dockerfilePath := Env(tb, "DOCKERFILE_PATH")
// containerRegistry := Env(tb, "CONTAINER_NGINX_IMAGE_REGISTRY")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code block is all commented out

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran into an issue with setting up the container for agent with NGINX Plus so I commented out the code for now until I can sort it.

@dhurley dhurley added the v3.x Issues and Pull Requests related to the major version v3 label Aug 14, 2025
s.teardownTest(s.T())
}

func (s *MetricsTestSuite) TestNginxOSS_Test1_TestRequestCount() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the Test1/Test2 from the test titles? The name itself will be the identifier

s.Require().NoError(err)
}

time.Sleep(65 * time.Second)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best practice is not to have a hard coded sleep. Should replace with a method to loop curling the otel collector until metrics is available. This method can be reused for other tests.

}

func (s *MetricsTestSuite) TestNginxOSS_Test2_TestResponseCode() {
family := s.metricFamilies["nginx_http_response_count"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generating metrics could help increase the test coverage.

for code := range responseCodes {
codeRes = append(codeRes, utils.SumMetricFamilyLabel(family, "nginx_status_range", responseCodes[code]))
s.T().Logf("NGINX HTTP response code %s total: %v", responseCodes[code], codeRes[code])
s.Require().NotNil(codeRes[code])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generating metrics could expand the assertions so we know certain response codes are of a particular value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Pull requests for routine tasks dependencies documentation Improvements or additions to documentation v3.x Issues and Pull Requests related to the major version v3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants