-
Notifications
You must be signed in to change notification settings - Fork 78
test(registration-service): expose metrics for the git commit #1269
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
Changes from all commits
a75907b
f34ee82
4ab8cad
d6aa218
0aaaaed
feef64f
0b072e8
f8d9edc
dc5f66d
4804ed9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,14 @@ | ||
| ignored-vulnerabilities: [] | ||
| ignored-vulnerabilities: | ||
| # Incorrect parsing of IPv6 host literals in net/url | ||
| # Found in: net/url@go1.24.13 | ||
| # Fixed in: net/url@go1.25.8 | ||
| - id: GO-2026-4601 | ||
| info: https://pkg.go.dev/vuln/GO-2026-4601 | ||
| silence-until: 2026-04-23 | ||
| # FileInfo can escape from a Root in os | ||
| # Found in: os@go1.24.13 | ||
| # Fixed in: os@go1.25.8 | ||
| - id: GO-2026-4602 | ||
| info: https://pkg.go.dev/vuln/GO-2026-4602 | ||
| silence-until: 2026-04-23 | ||
|
|
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,31 +32,52 @@ func TestOperatorVersionMetrics(t *testing.T) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| awaitilities := WaitForDeployments(t) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.Run("host-operator", func(t *testing.T) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // given | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hostAwait := awaitilities.Host() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // host metrics should be available at this point | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hostAwait.InitMetrics(t, awaitilities.Member1().ClusterName, awaitilities.Member2().ClusterName) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| labels := hostAwait.GetMetricLabels(t, wait.HostOperatorVersionMetric) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.Run("commit", func(t *testing.T) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| labels := hostAwait.GetMetricLabels(t, hostAwait.MetricsURL, wait.HostOperatorCommitMetric) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // verify that the "version" metric exists for Host Operator and that it has a non-empty `commit` label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.Len(t, labels, 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| commit := labels[0]["commit"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert.Len(t, commit, 7) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // verify that the "version" metric exists for Host Operator and that it has a non-empty `commit` label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.Len(t, labels, 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| commit := labels[0]["commit"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert.Len(t, commit, len("e6a12a442a60dfd86d348a030ad2e789c79184b5")) // example value: 40 characters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.Run("short commit", func(t *testing.T) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| labels := hostAwait.GetMetricLabels(t, hostAwait.MetricsURL, wait.HostOperatorShortCommitMetric) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // verify that the "version" metric exists for Host Operator and that it has a non-empty `commit` label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.Len(t, labels, 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| commit := labels[0]["commit"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert.Len(t, commit, 7) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.Run("version", func(t *testing.T) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| labels := hostAwait.GetMetricLabels(t, hostAwait.MetricsURL, wait.HostOperatorVersionMetric) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // verify that the "version" metric exists for Host Operator and that it has a non-empty `commit` label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.Len(t, labels, 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| commit := labels[0]["commit"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert.Len(t, commit, 7) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.Run("member-operators", func(t *testing.T) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // given | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| member1Await := awaitilities.Member1() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| member2Await := awaitilities.Member1() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| member2Await := awaitilities.Member2() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // member metrics should be available at this point | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| member1Await.InitMetrics(t) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| member2Await.InitMetrics(t) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // --- member1 --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| labels := member1Await.GetMetricLabels(t, wait.MemberOperatorVersionMetric) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| labels := member1Await.GetMetricLabels(t, member1Await.MetricsURL, wait.MemberOperatorVersionMetric) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // verify that the "version" metric exists for the first Member Operator and that it has a non-empty `commit` label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.Len(t, labels, 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -65,7 +86,7 @@ func TestOperatorVersionMetrics(t *testing.T) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // --- member2 --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| labels = member2Await.GetMetricLabels(t, wait.MemberOperatorVersionMetric) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| labels = member2Await.GetMetricLabels(t, member2Await.MetricsURL, wait.MemberOperatorVersionMetric) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // verify that the "version" metric exists for the second Member Operator and that it has a non-empty `commit` label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.Len(t, labels, 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -75,6 +96,35 @@ func TestOperatorVersionMetrics(t *testing.T) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // expect the same version on member1 and member2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert.Equal(t, commit1, commit2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.Run("registration-service", func(t *testing.T) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // given | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hostAwait := awaitilities.Host() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _, err := hostAwait.WaitForRouteToBeAvailable(t, hostAwait.Namespace, "registration-service-metrics", "/metrics") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.NoError(t, err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.Run("commit", func(t *testing.T) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| labels := hostAwait.GetMetricLabels(t, hostAwait.RegistrationServiceMetricsURL, wait.RegistrationServiceCommitMetric) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // verify that the "version" metric exists for Host Operator and that it has a non-empty `commit` label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.Len(t, labels, 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| commit := labels[0]["commit"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert.Len(t, commit, len("da3f54634cc65075d51d067a157831d44bf1413e")) // example value: 40 characters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.Run("short commit", func(t *testing.T) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| labels := hostAwait.GetMetricLabels(t, hostAwait.RegistrationServiceMetricsURL, wait.RegistrationServiceShortCommitMetric) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // verify that the "version" metric exists for Host Operator and that it has a non-empty `commit` label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.Len(t, labels, 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| commit := labels[0]["commit"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert.Len(t, commit, 7) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+107
to
+125
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix misleading comments - these refer to registration-service, not Host Operator. Lines 111 and 121 contain copy-paste errors from the host-operator subtests. The comments say "Host Operator" but this is the registration-service subtest. ✏️ Proposed fix t.Run("commit", func(t *testing.T) {
// when
labels := hostAwait.GetMetricLabels(t, hostAwait.RegistrationServiceMetricsURL, wait.RegistrationServiceCommitMetric)
- // verify that the "version" metric exists for Host Operator and that it has a non-empty `commit` label
+ // verify that the "commit" metric exists for registration-service and that it has a non-empty `commit` label
require.Len(t, labels, 1)
commit := labels[0]["commit"]
assert.Len(t, commit, len("da3f54634cc65075d51d067a157831d44bf1413e")) // example value: 40 characters
})
t.Run("short commit", func(t *testing.T) {
// when
labels := hostAwait.GetMetricLabels(t, hostAwait.RegistrationServiceMetricsURL, wait.RegistrationServiceShortCommitMetric)
- // verify that the "version" metric exists for Host Operator and that it has a non-empty `commit` label
+ // verify that the "short_commit" metric exists for registration-service and that it has a non-empty `commit` label
require.Len(t, labels, 1)
commit := labels[0]["commit"]
assert.Len(t, commit, 7)
})📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // TestMetricsWhenUsersManuallyApproved verifies that `UserSignupsApprovedMetric` and `UserSignupsApprovedWithMethodMetric` counters are increased when users are approved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -34,6 +34,7 @@ | |||||||||||||||||||||||||||||||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||||||||||||||||||||||||||||
| "k8s.io/apimachinery/pkg/runtime" | ||||||||||||||||||||||||||||||||
| "k8s.io/apimachinery/pkg/types" | ||||||||||||||||||||||||||||||||
| "k8s.io/apimachinery/pkg/util/intstr" | ||||||||||||||||||||||||||||||||
| "k8s.io/client-go/rest" | ||||||||||||||||||||||||||||||||
| "k8s.io/client-go/tools/clientcmd" | ||||||||||||||||||||||||||||||||
| "k8s.io/client-go/tools/clientcmd/api" | ||||||||||||||||||||||||||||||||
|
|
@@ -205,14 +206,46 @@ | |||||||||||||||||||||||||||||||
| require.NoError(t, err, "failed to find proxy metrics service") | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // setup host metrics route for metrics verification in tests | ||||||||||||||||||||||||||||||||
| hostMetricsRoute, err := initHostAwait.SetupRouteForService(t, "host-operator-metrics-service", "/metrics") | ||||||||||||||||||||||||||||||||
| hostMetricsRoute, err := initHostAwait.SetupRouteForService(t, "host-operator-metrics-service", "/metrics", | ||||||||||||||||||||||||||||||||
|
Check failure on line 209 in testsupport/init.go
|
||||||||||||||||||||||||||||||||
| &routev1.RoutePort{ | ||||||||||||||||||||||||||||||||
| TargetPort: intstr.FromString("https"), | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| &routev1.TLSConfig{ | ||||||||||||||||||||||||||||||||
| Termination: routev1.TLSTerminationPassthrough, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
| require.NoError(t, err) | ||||||||||||||||||||||||||||||||
| require.NotEmpty(t, hostMetricsRoute.Status.Ingress, "route has no ingress status for host metrics service") | ||||||||||||||||||||||||||||||||
| initHostAwait.MetricsURL = "https://" + hostMetricsRoute.Status.Ingress[0].Host | ||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||
| t.Logf("host metrics URL: %s", initHostAwait.MetricsURL) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // setup registration service metrics route for metrics verification in tests | ||||||||||||||||||||||||||||||||
| registrationServiceMetricsRoute, err := initHostAwait.SetupRouteForService(t, "registration-service-metrics", "/metrics", | ||||||||||||||||||||||||||||||||
| &routev1.RoutePort{ | ||||||||||||||||||||||||||||||||
| TargetPort: intstr.FromString("regsvc-metrics"), | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| &routev1.TLSConfig{ | ||||||||||||||||||||||||||||||||
| Termination: routev1.TLSTerminationEdge, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
| require.NoError(t, err) | ||||||||||||||||||||||||||||||||
| require.NotEmpty(t, registrationServiceMetricsRoute.Status.Ingress, "route has no ingress status for registration service metrics service") | ||||||||||||||||||||||||||||||||
| initHostAwait.RegistrationServiceMetricsURL = "https://" + registrationServiceMetricsRoute.Status.Ingress[0].Host | ||||||||||||||||||||||||||||||||
| t.Logf("registration service metrics URL: %s", initHostAwait.RegistrationServiceMetricsURL) | ||||||||||||||||||||||||||||||||
|
Comment on lines
+223
to
+234
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it looks like the route creation is also done in the tests toolchain-e2e/test/e2e/parallel/registration_service_test.go Lines 76 to 90 in 629dc7b
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahh, good catch! I only ran the tests in the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed in 0aaaaed |
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // setup member metrics route for metrics verification in tests | ||||||||||||||||||||||||||||||||
| memberMetricsRoute, err := initMemberAwait.SetupRouteForService(t, "member-operator-metrics-service", "/metrics") | ||||||||||||||||||||||||||||||||
| memberMetricsRoute, err := initMemberAwait.SetupRouteForService(t, "member-operator-metrics-service", "/metrics", | ||||||||||||||||||||||||||||||||
| &routev1.RoutePort{ | ||||||||||||||||||||||||||||||||
| TargetPort: intstr.FromString("https"), | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| &routev1.TLSConfig{ | ||||||||||||||||||||||||||||||||
| Termination: routev1.TLSTerminationPassthrough, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
| require.NoError(t, err, "failed while setting up or waiting for the route to the 'member-operator-metrics' service to be available") | ||||||||||||||||||||||||||||||||
| require.NotEmpty(t, memberMetricsRoute.Status.Ingress, "route has no ingress status for member metrics service") | ||||||||||||||||||||||||||||||||
| initMemberAwait.MetricsURL = "https://" + memberMetricsRoute.Status.Ingress[0].Host | ||||||||||||||||||||||||||||||||
| t.Logf("member metrics URL: %s", initMemberAwait.MetricsURL) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Wait for the webhooks in Member 1 only because we do not deploy webhooks for Member 2 | ||||||||||||||||||||||||||||||||
| // (we can't deploy the same webhook multiple times on the same cluster) | ||||||||||||||||||||||||||||||||
|
|
@@ -222,6 +255,19 @@ | |||||||||||||||||||||||||||||||
| if IsSecondMemberMode(t) { | ||||||||||||||||||||||||||||||||
| err = initMember2Await.WaitUntilWebhookDeleted(t) // webhook on member2 should be deleted | ||||||||||||||||||||||||||||||||
| require.NoError(t, err) | ||||||||||||||||||||||||||||||||
| memberMetricsRoute, err := initMember2Await.SetupRouteForService(t, "member-operator-metrics-service", "/metrics", | ||||||||||||||||||||||||||||||||
| &routev1.RoutePort{ | ||||||||||||||||||||||||||||||||
| TargetPort: intstr.FromString("https"), | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| &routev1.TLSConfig{ | ||||||||||||||||||||||||||||||||
| Termination: routev1.TLSTerminationPassthrough, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
| require.NoError(t, err, "failed while setting up or waiting for the route to the 'member-operator-metrics' service to be available") | ||||||||||||||||||||||||||||||||
| require.NotEmpty(t, memberMetricsRoute.Status.Ingress, "route has no ingress status for member metrics service") | ||||||||||||||||||||||||||||||||
| initMember2Await.MetricsURL = "https://" + memberMetricsRoute.Status.Ingress[0].Host | ||||||||||||||||||||||||||||||||
| t.Logf("member metrics URL: %s", initMember2Await.MetricsURL) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| initMemberAwait.WaitForMemberWebhooks(t, webhookImage) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix misleading comments - these refer to "version" metric but test commit metrics.
Lines 43 and 53 have copy-paste errors. The comments say
"version" metricbut these subtests validatecommitandshort_commitmetrics respectively.✏️ Proposed fix
t.Run("commit", func(t *testing.T) { // when labels := hostAwait.GetMetricLabels(t, hostAwait.MetricsURL, wait.HostOperatorCommitMetric) - // verify that the "version" metric exists for Host Operator and that it has a non-empty `commit` label + // verify that the "commit" metric exists for Host Operator and that it has a non-empty `commit` label require.Len(t, labels, 1) commit := labels[0]["commit"] assert.Len(t, commit, len("e6a12a442a60dfd86d348a030ad2e789c79184b5")) // example value: 40 characters }) t.Run("short commit", func(t *testing.T) { // when labels := hostAwait.GetMetricLabels(t, hostAwait.MetricsURL, wait.HostOperatorShortCommitMetric) - // verify that the "version" metric exists for Host Operator and that it has a non-empty `commit` label + // verify that the "short_commit" metric exists for Host Operator and that it has a non-empty `commit` label require.Len(t, labels, 1) commit := labels[0]["commit"] assert.Len(t, commit, 7) })📝 Committable suggestion
🤖 Prompt for AI Agents