From a71e9f9c7d048a78a733e89816ff61bef98aaff9 Mon Sep 17 00:00:00 2001 From: Eron Wright Date: Fri, 7 Feb 2025 12:19:14 -0800 Subject: [PATCH] e2e test --- operator/e2e/e2e_test.go | 20 +++++++ .../e2e/testdata/issue-801/manifests.yaml | 54 ++++++++++++++++++ .../testdata/issue-801/step2/manifests.yaml | 55 +++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 operator/e2e/testdata/issue-801/manifests.yaml create mode 100644 operator/e2e/testdata/issue-801/step2/manifests.yaml diff --git a/operator/e2e/e2e_test.go b/operator/e2e/e2e_test.go index 118cdd28..84c0634d 100644 --- a/operator/e2e/e2e_test.go +++ b/operator/e2e/e2e_test.go @@ -27,6 +27,7 @@ import ( "testing" "time" + autov1alpha1 "github.com/pulumi/pulumi-kubernetes-operator/v2/operator/api/auto/v1alpha1" pulumiv1 "github.com/pulumi/pulumi-kubernetes-operator/v2/operator/api/pulumi/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -120,6 +121,25 @@ func TestE2E(t *testing.T) { assert.NotContains(t, stack.Status.Outputs, "notTargeted") }, }, + { + name: "issue-801", + f: func(t *testing.T) { + t.Parallel() + + cmd := exec.Command("kubectl", "apply", "-f", "e2e/testdata/issue-801") + require.NoError(t, run(cmd)) + dumpLogs(t, "issue-801", "pods/issue-801-workspace-0") + + _, err := waitFor[autov1alpha1.Workspace]("pods/issue-801-workspace-0", "issue-801", "create", 5*time.Minute) + assert.NoError(t, err) + + cmd = exec.Command("kubectl", "apply", "-f", "e2e/testdata/issue-801/step2") + require.NoError(t, run(cmd)) + + _, err = waitFor[autov1alpha1.Workspace]("workspaces/issue-801", "issue-801", "condition=Ready", 5*time.Minute) + assert.NoError(t, err) + }, + }, } for _, tt := range tests { diff --git a/operator/e2e/testdata/issue-801/manifests.yaml b/operator/e2e/testdata/issue-801/manifests.yaml new file mode 100644 index 00000000..0ed4c6da --- /dev/null +++ b/operator/e2e/testdata/issue-801/manifests.yaml @@ -0,0 +1,54 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: issue-801 +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: issue-801 + namespace: issue-801 +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: issue-801:system:auth-delegator +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: system:auth-delegator +subjects: +- kind: ServiceAccount + name: issue-801 + namespace: issue-801 +--- +apiVersion: auto.pulumi.com/v1alpha1 +kind: Workspace +metadata: + name: issue-801 + namespace: issue-801 +spec: + image: pulumi/nosuchimage:3.147.0-nonroot + securityProfile: restricted + serviceAccountName: issue-801 + git: + url: https://github.com/pulumi/examples.git + ref: 1e2fc471709448f3c9f7a250f28f1eafcde7017b + dir: random-yaml + shallow: true + env: + - name: PULUMI_CONFIG_PASSPHRASE + value: test + - name: PULUMI_BACKEND_URL + value: file:///state/ + + podTemplate: + spec: + containers: + - name: pulumi + volumeMounts: + - name: state + mountPath: /state + volumes: + - name: state + emptyDir: {} diff --git a/operator/e2e/testdata/issue-801/step2/manifests.yaml b/operator/e2e/testdata/issue-801/step2/manifests.yaml new file mode 100644 index 00000000..e98b61fe --- /dev/null +++ b/operator/e2e/testdata/issue-801/step2/manifests.yaml @@ -0,0 +1,55 @@ +# modified: image tag +apiVersion: v1 +kind: Namespace +metadata: + name: issue-801 +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: issue-801 + namespace: issue-801 +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: issue-801:system:auth-delegator +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: system:auth-delegator +subjects: +- kind: ServiceAccount + name: issue-801 + namespace: issue-801 +--- +apiVersion: auto.pulumi.com/v1alpha1 +kind: Workspace +metadata: + name: issue-801 + namespace: issue-801 +spec: + image: pulumi/pulumi:3.147.0-nonroot + securityProfile: restricted + serviceAccountName: issue-801 + git: + url: https://github.com/pulumi/examples.git + ref: 1e2fc471709448f3c9f7a250f28f1eafcde7017b + dir: random-yaml + shallow: true + env: + - name: PULUMI_CONFIG_PASSPHRASE + value: test + - name: PULUMI_BACKEND_URL + value: file:///state/ + + podTemplate: + spec: + containers: + - name: pulumi + volumeMounts: + - name: state + mountPath: /state + volumes: + - name: state + emptyDir: {}