Skip to content

Commit

Permalink
[v2] E2E test for --target (#711)
Browse files Browse the repository at this point in the history
Turns out we already plumb target from Stack → Update → Agent → Auto
API.

This adds a small E2E test around the behavior.
  • Loading branch information
blampe authored Oct 11, 2024
1 parent d52dbe7 commit 83f8438
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 1 deletion.
16 changes: 16 additions & 0 deletions operator/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ func TestE2E(t *testing.T) {
assert.Equal(t, `"foo"`, string(stack.Status.Outputs["simpleOutput"].Raw))
},
},
{
name: "targets",
f: func(t *testing.T) {
t.Parallel()

cmd := exec.Command("kubectl", "apply", "-f", "e2e/testdata/targets")
require.NoError(t, run(cmd))
dumpLogs(t, "targets", "pod/targets-workspace-0")

stack, err := waitFor[pulumiv1.Stack]("stacks/targets", "targets", "condition=Ready", 5*time.Minute)
assert.NoError(t, err)

assert.Contains(t, stack.Status.Outputs, "targeted")
assert.NotContains(t, stack.Status.Outputs, "notTargeted")
},
},
}

for _, tt := range tests {
Expand Down
1 change: 0 additions & 1 deletion operator/e2e/testdata/git-auth-nonroot/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ spec:
value: "test"
workspaceTemplate:
spec:
image: pulumi/pulumi:3.134.1-nonroot
podTemplate:
spec:
containers:
Expand Down
74 changes: 74 additions & 0 deletions operator/e2e/testdata/targets/manifests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: targets
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: state
namespace: targets
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
---
apiVersion: pulumi.com/v1
kind: Program
metadata:
name: targets
namespace: targets
program:
resources:
notTargeted:
type: random:RandomInteger
properties:
min: 1
max: 100
targeted:
type: random:RandomInteger
properties:
min: 1
max: 100
outputs:
targeted: ${targeted.result}
notTargeted: ${notTargeted.result} # Should be absent
---
apiVersion: pulumi.com/v1
kind: Stack
metadata:
name: targets
namespace: targets
spec:
stack: dev
programRef:
name: targets
targets:
- urn:pulumi:dev::targets::random:index/randomInteger:RandomInteger::targeted

# Enable file state for testing.
envRefs:
PULUMI_BACKEND_URL:
type: Literal
literal:
value: "file:///state/"
PULUMI_CONFIG_PASSPHRASE:
type: Literal
literal:
value: "test"
workspaceTemplate:
spec:
podTemplate:
spec:
containers:
- name: pulumi
volumeMounts:
- name: state
mountPath: /state
volumes:
- name: state
persistentVolumeClaim:
claimName: state

0 comments on commit 83f8438

Please sign in to comment.