Skip to content

Commit

Permalink
e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
EronWright committed Feb 7, 2025
1 parent b5b503a commit a71e9f9
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 0 deletions.
20 changes: 20 additions & 0 deletions operator/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
54 changes: 54 additions & 0 deletions operator/e2e/testdata/issue-801/manifests.yaml
Original file line number Diff line number Diff line change
@@ -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: {}
55 changes: 55 additions & 0 deletions operator/e2e/testdata/issue-801/step2/manifests.yaml
Original file line number Diff line number Diff line change
@@ -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: {}

0 comments on commit a71e9f9

Please sign in to comment.