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

✨ (go/v4) Add Metrics Validation and Helper Functions to E2E Tests #4124

Closed

Conversation

camilamacedo86
Copy link
Member

@camilamacedo86 camilamacedo86 commented Sep 1, 2024

Provide further improvements for e2e tests test to help users be aware of how to tests using the metrics endpoint and validate if the metrics are properly expose. Furthermore, shows how to use it to validate the reconciliation.

Partially closes: #4120

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 1, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 1, 2024
@camilamacedo86 camilamacedo86 changed the title ✨ (go/v4) Add Metrics Validation and Helper Functions to E2E Tests WIP ✨ (go/v4) Add Metrics Validation and Helper Functions to E2E Tests Sep 1, 2024
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 1, 2024
@camilamacedo86 camilamacedo86 force-pushed the test-e2e-impro branch 7 times, most recently from db3877e to 331bac7 Compare September 1, 2024 22:44
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 1, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 1, 2024
@camilamacedo86 camilamacedo86 changed the title WIP ✨ (go/v4) Add Metrics Validation and Helper Functions to E2E Tests ✨ (go/v4) Add Metrics Validation and Helper Functions to E2E Tests Sep 1, 2024
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 1, 2024
@camilamacedo86
Copy link
Member Author

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 1, 2024
@camilamacedo86 camilamacedo86 changed the title ✨ (go/v4) Add Metrics Validation and Helper Functions to E2E Tests WIP ✨ (go/v4) Add Metrics Validation and Helper Functions to E2E Tests Sep 1, 2024
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 1, 2024
@camilamacedo86 camilamacedo86 force-pushed the test-e2e-impro branch 2 times, most recently from 8f6e1f0 to 69c1d84 Compare September 2, 2024 08:40
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 2, 2024
@camilamacedo86 camilamacedo86 changed the title WIP ✨ (go/v4) Add Metrics Validation and Helper Functions to E2E Tests (Blocked by others PRs) ✨ (go/v4) Add Metrics Validation and Helper Functions to E2E Tests Sep 2, 2024
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 2, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 2, 2024
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 2, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 3, 2024
@camilamacedo86 camilamacedo86 force-pushed the test-e2e-impro branch 2 times, most recently from a9b1d9c to d714031 Compare September 3, 2024 06:58
@camilamacedo86 camilamacedo86 changed the title (Blocked by others PRs) ✨ (go/v4) Add Metrics Validation and Helper Functions to E2E Tests ✨ (go/v4) Add Metrics Validation and Helper Functions to E2E Tests Sep 3, 2024
@camilamacedo86
Copy link
Member Author

@Adembc

With this one I think we can address all.

@camilamacedo86
Copy link
Member Author

/hold false

It seems great to fly 🚀

@camilamacedo86 camilamacedo86 removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 3, 2024
ExpectWithOffset(2, token).NotTo(BeEmpty())

By("waiting for the metrics endpoint to be ready")
verifyMetricsEndpointReady := func() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Eventually funcs can take a Gomega parameter, which you can then use to verify, instead of returning an error.

verifyMetricsEndpointReady := func(g Gomega) {
	cmd := exec.Command("kubectl", "get", "endpoints", metricsServiceName, "-n", namespace)
	g.Expect(utils.Run(cmd)).To(ContainSubstring("8443"))
})
Eventually(verifyMetricsEndpointReady).WithTimeout(...).Should(Succeed())

you shouldn't need the WithOffset(2), and the whole test is somewhat more condensed, since it's not mixing the go error handling with Expectations.

g.Expect() in the snippet above both should check the error be nil and the contents of the output string (not 100% sure about the type conversion from []byte to string, though).

testdata/project-v4-multigroup/test/e2e/e2e_test.go Outdated Show resolved Hide resolved
Provide further improvements for e2e tests test to help
users be aware of how to tests using the metrics endpoint
and validate if the metrics are properly expose.
@camilamacedo86 camilamacedo86 force-pushed the test-e2e-impro branch 2 times, most recently from 5d772aa to f867ac0 Compare September 3, 2024 20:44
@mogsie
Copy link
Contributor

mogsie commented Sep 4, 2024

/lgtm

(not that I think I have a say in the matter 😄)

@k8s-ci-robot
Copy link
Contributor

@mogsie: changing LGTM is restricted to collaborators

In response to this:

/lgtm

(not that I think I have a say in the matter 😄)

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

E2e tests scaffolded by default
3 participants