From 0657a2c70913dbe8632eaa682e0b5d94887d327a Mon Sep 17 00:00:00 2001 From: Markus Rudy Date: Tue, 5 Mar 2024 11:30:41 +0100 Subject: [PATCH] e2e: deploy port-forwarder from go --- deployments/openssl/portforwarder.yml | 30 --------------------------- e2e/openssl/openssl_test.go | 17 ++++++++++++++- 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/deployments/openssl/portforwarder.yml b/deployments/openssl/portforwarder.yml index 367b0da214..a8021696cc 100644 --- a/deployments/openssl/portforwarder.yml +++ b/deployments/openssl/portforwarder.yml @@ -27,33 +27,3 @@ spec: memory: 50Mi limits: memory: 50Mi ---- -apiVersion: v1 -kind: Pod -metadata: - name: port-forwarder-openssl-frontend - namespace: edg-default - labels: - app.kubernetes.io/name: port-forwarder-openssl-frontend -spec: - containers: - - name: port-forwarder - image: "ghcr.io/edgelesssys/contrast/port-forwarder:latest" - env: - - name: LISTEN_PORT - value: "443" - - name: FORWARD_HOST - value: openssl-frontend - - name: FORWARD_PORT - value: "443" - command: - - /bin/bash - - "-c" - - echo Starting port-forward with socat; exec socat -d -d TCP-LISTEN:${LISTEN_PORT},fork TCP:${FORWARD_HOST}:${FORWARD_PORT} - ports: - - containerPort: 443 - resources: - requests: - memory: 50Mi - limits: - memory: 50Mi diff --git a/e2e/openssl/openssl_test.go b/e2e/openssl/openssl_test.go index 9e6791874e..966e730888 100644 --- a/e2e/openssl/openssl_test.go +++ b/e2e/openssl/openssl_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/edgelesssys/contrast/e2e/internal/kubeclient" + "github.com/edgelesssys/contrast/e2e/internal/kuberesource" "github.com/stretchr/testify/require" ) @@ -59,7 +60,21 @@ func TestFrontend(t *testing.T) { namespace := os.Getenv(namespaceEnv) require.NotEmpty(namespace, "environment variable %q must be set", namespaceEnv) - addr, cancelPortForward, err := c.PortForwardPod(ctx, namespace, "port-forwarder-openssl-frontend", "443") + pf := kuberesource.PortForwarder("openssl-frontend", namespace). + WithListenPort(443). + WithForwardTarget("openssl-frontend", 443). + PodApplyConfiguration + + // TODO(burgerdev): why is the actual image not published? + img := "nixery.dev/shell/socat" + pf.Spec.Containers[0].Image = &img + + res, err := kuberesource.ResourcesToUnstructured([]any{pf}) + require.NoError(err) + require.NoError(c.Deploy(ctx, res...)) + require.NoError(c.WaitForPod(ctx, namespace, *pf.Name)) + + addr, cancelPortForward, err := c.PortForwardPod(ctx, namespace, *pf.Name, "443") require.NoError(err) defer cancelPortForward()