From 72fa369fc92f7b2b5f61aced7e9826909f113ff2 Mon Sep 17 00:00:00 2001 From: Joshua Casey Date: Wed, 4 Sep 2024 20:48:44 -0500 Subject: [PATCH] Integration tests should use PINNIPED_TEST_SUPERVISOR_SERVICE_NAME to decide where to port-forward --- test/integration/securetls_test.go | 21 ++++++++++++++------- test/testlib/env.go | 2 ++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/test/integration/securetls_test.go b/test/integration/securetls_test.go index 7daf2ba3a..7e39d46e1 100644 --- a/test/integration/securetls_test.go +++ b/test/integration/securetls_test.go @@ -118,15 +118,22 @@ func TestSecureTLSSupervisor(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) t.Cleanup(cancel) - supervisorIssuer := testlib.NewSupervisorIssuer(t, env.SupervisorHTTPSAddress) - - serviceSuffix := "-nodeport" - if supervisorIssuer.IsIPAddress() { - // Then there's no nodeport service to connect to, it's a load balancer service! - serviceSuffix = "-loadbalancer" + // On kind, this will generally be app-name-nodeport + // On GKE and AKS, this will generally be app-name-loadbalancer (their ingresses use IP addresses) + // On EKS, this will generally be app-name-loadbalancer (this ingress uses DNS addresses), but we should rely on + // the PINNIPED_TEST_SUPERVISOR_SERVICE_NAME variable. + serviceName := env.SupervisorServiceName + if serviceName == "" { + serviceName = env.SupervisorAppName + "-nodeport" + + supervisorIssuer := testlib.NewSupervisorIssuer(t, env.SupervisorHTTPSAddress) + if supervisorIssuer.IsIPAddress() { + // Then there's no nodeport service to connect to, it's a load balancer service! + serviceName = env.SupervisorAppName + "-loadbalancer" + } } - startKubectlPortForward(ctx, t, "10448", "443", env.SupervisorAppName+serviceSuffix, env.SupervisorNamespace) + startKubectlPortForward(ctx, t, "10448", "443", serviceName, env.SupervisorNamespace) stdout, stderr := testlib.RunNmapSSLEnum(t, "127.0.0.1", 10448) diff --git a/test/testlib/env.go b/test/testlib/env.go index 68d1c8e5c..9e3c1a096 100644 --- a/test/testlib/env.go +++ b/test/testlib/env.go @@ -44,6 +44,7 @@ type TestEnv struct { SupervisorNamespace string `json:"supervisorNamespace"` ConciergeAppName string `json:"conciergeAppName"` SupervisorAppName string `json:"supervisorAppName"` + SupervisorServiceName string `json:"supervisorServiceName"` SupervisorCustomLabels map[string]string `json:"supervisorCustomLabels"` ConciergeCustomLabels map[string]string `json:"conciergeCustomLabels"` KubernetesDistribution KubeDistro `json:"kubernetesDistribution"` @@ -259,6 +260,7 @@ func loadEnvVars(t *testing.T, result *TestEnv) { result.TestWebhook.Endpoint = needEnv(t, "PINNIPED_TEST_WEBHOOK_ENDPOINT") result.SupervisorNamespace = needEnv(t, "PINNIPED_TEST_SUPERVISOR_NAMESPACE") result.SupervisorAppName = needEnv(t, "PINNIPED_TEST_SUPERVISOR_APP_NAME") + result.SupervisorServiceName = os.Getenv("PINNIPED_TEST_SUPERVISOR_SERVICE_NAME") result.TestWebhook.TLS = &authenticationv1alpha1.TLSSpec{CertificateAuthorityData: needEnv(t, "PINNIPED_TEST_WEBHOOK_CA_BUNDLE")} result.SupervisorHTTPSIngressAddress = os.Getenv("PINNIPED_TEST_SUPERVISOR_HTTPS_INGRESS_ADDRESS")