Skip to content

Commit 7a7bbbf

Browse files
committed
Discover service namespace in e2e metrics tests
Previously, the metrics test assumed the service was in a hardcoded namespace. This change queries for the service across all namespaces to find its actual location, making the test more robust against various deployment configurations.
1 parent ba665c7 commit 7a7bbbf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/e2e/steps/steps.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,11 @@ func randomAvailablePort() (int, error) {
537537

538538
func SendMetricsRequest(ctx context.Context, serviceAccount string, endpoint string, controllerName string) error {
539539
sc := scenarioCtx(ctx)
540-
v, err := k8sClient("get", "service", "-n", olmNamespace, fmt.Sprintf("%s-service", controllerName), "-o", "json")
540+
serviceNs, err := k8sClient("get", "service", "-A", "-o", fmt.Sprintf(`jsonpath={.items[?(@.metadata.name=="%s-service")].metadata.namespace}`, controllerName))
541+
if err != nil {
542+
return err
543+
}
544+
v, err := k8sClient("get", "service", "-n", serviceNs, fmt.Sprintf("%s-service", controllerName), "-o", "json")
541545
if err != nil {
542546
return err
543547
}

0 commit comments

Comments
 (0)