Skip to content

Commit

Permalink
Test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
blampe committed Nov 26, 2024
1 parent 0ea14f0 commit eaaba7b
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 96 deletions.
54 changes: 27 additions & 27 deletions tests/sdk/java/await_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,23 @@ func TestAwaitDaemonSet(t *testing.T) {
opttest.SkipInstall(),
)
t.Cleanup(func() {
test.Destroy()
test.Destroy(t)
})

// Create a new DS that takes a few seconds to become ready.
up := test.Up()
up := test.Up(t)
t.Log(up.Summary.Message)
assertReady(t, up.Outputs)

test.Refresh() // Exercise read-await logic.
test.Refresh(t) // Exercise read-await logic.

// Update the DS to use a different but valid image tag.
test.UpdateSource("testdata/await/daemonset/step2")
up = test.Up()
test.UpdateSource(t, "testdata/await/daemonset/step2")
up = test.Up(t)
assertReady(t, up.Outputs)

// Update the DS to use an invalid image tag. It should never become ready.
test.UpdateSource("testdata/await/daemonset/step3")
test.UpdateSource(t, "testdata/await/daemonset/step3")
_, err := test.CurrentStack().Up(context.Background())
assert.ErrorContains(t, err, `the Kubernetes API server reported that "default/await-daemonset" failed to fully initialize or become live: timed out waiting for the condition`)
}
Expand All @@ -87,16 +87,16 @@ func TestAwaitPVC(t *testing.T) {
opttest.SkipInstall(),
)
t.Cleanup(func() {
test.Destroy()
test.Destroy(t)
})

// WaitUntilFirstConsumer PVC should still be Pending.
up := test.Up()
up := test.Up(t)
assert.Equal(t, "Pending", up.Outputs["status"].Value)

// Adding a Deployment to consume the PVC should succeed.
test.UpdateSource("testdata/await/pvc/step2")
up = test.Up()
test.UpdateSource(t, "testdata/await/pvc/step2")
up = test.Up(t)
}

func TestAwaitService(t *testing.T) {
Expand All @@ -107,19 +107,19 @@ func TestAwaitService(t *testing.T) {
opttest.SkipInstall(),
)
t.Cleanup(func() {
test.Destroy()
test.Destroy(t)
})

up := test.Up()
up := test.Up(t)
assert.Equal(t, float64(1), up.Outputs["replicas"].Value.(float64))
assert.Nil(t, up.Outputs["selector"].Value)
test.Refresh()
test.Refresh(t)

test.UpdateSource("testdata/await/service/step2")
up = test.Up()
test.UpdateSource(t, "testdata/await/service/step2")
up = test.Up(t)
assert.Equal(t, float64(0), up.Outputs["replicas"].Value.(float64))
assert.Equal(t, up.Outputs["selector"], up.Outputs["label"])
test.Refresh()
test.Refresh(t)
}

func TestAwaitServiceAccount(t *testing.T) {
Expand All @@ -130,13 +130,13 @@ func TestAwaitServiceAccount(t *testing.T) {
opttest.SkipInstall(),
)
t.Cleanup(func() {
test.Destroy()
test.Destroy(t)
})

test.Up()
test.UpdateSource("testdata/await/service-account/step2")
test.Up()
test.Refresh()
test.Up(t)
test.UpdateSource(t, "testdata/await/service-account/step2")
test.Up(t)
test.Refresh(t)
}

func TestAwaitSkip(t *testing.T) {
Expand All @@ -147,27 +147,27 @@ func TestAwaitSkip(t *testing.T) {
opttest.SkipInstall(),
)
t.Cleanup(func() {
test.Destroy()
test.Destroy(t)
})

start := time.Now()
_ = test.Up(optup.ProgressStreams(os.Stdout))
_ = test.Up(t, optup.ProgressStreams(os.Stdout))
took := time.Since(start)
assert.Less(t, took, 2*time.Minute, "didn't skip pod's slow startup")

start = time.Now()
_ = test.Refresh(optrefresh.ProgressStreams(os.Stdout))
_ = test.Refresh(t, optrefresh.ProgressStreams(os.Stdout))
took = time.Since(start)
assert.Less(t, took, 2*time.Minute, "didn't skip pod's slow read")

test.UpdateSource("testdata/await/skipawait/step2")
test.UpdateSource(t, "testdata/await/skipawait/step2")
start = time.Now()
_ = test.Refresh(optrefresh.ProgressStreams(os.Stdout))
_ = test.Refresh(t, optrefresh.ProgressStreams(os.Stdout))
took = time.Since(start)
assert.Less(t, took, 2*time.Minute, "didn't skip pod's slow update")

start = time.Now()
_ = test.Destroy(optdestroy.ProgressStreams(os.Stdout))
_ = test.Destroy(t, optdestroy.ProgressStreams(os.Stdout))
took = time.Since(start)
assert.Less(t, took, 2*time.Minute, "didn't skip config map's stuck delete")
}
8 changes: 4 additions & 4 deletions tests/sdk/java/chartv4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ func TestChartv4(t *testing.T) {
test := pulumitest.NewPulumiTest(t, "testdata/chartv4", opttest.SkipInstall())
t.Logf("into %s", test.Source())
t.Cleanup(func() {
test.Destroy()
test.Destroy(t)
})
test.Preview()
test.Up()
test.Up(optup.ExpectNoChanges())
test.Preview(t)
test.Up(t)
test.Up(t, optup.ExpectNoChanges())
}
8 changes: 4 additions & 4 deletions tests/sdk/java/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ func TestClusterIdentifier(t *testing.T) {
ctx := context.Background()
test := pulumitest.NewPulumiTest(t, "config/cluster-identifier")
t.Cleanup(func() {
test.Destroy()
test.Destroy(t)
})

test.Up()
test.Up(t)

test.UpdateSource("config/cluster-identifier/step2")
test.UpdateSource(t, "config/cluster-identifier/step2")
up, err := test.CurrentStack().Up(ctx)

require.NoError(t, err)
assert.Contains(t, up.StdOut, "updated")
assert.NotContains(t, up.StdOut, "replaced")

test.UpdateSource("config/cluster-identifier/step3")
test.UpdateSource(t, "config/cluster-identifier/step3")
up, err = test.CurrentStack().Up(ctx)

require.NoError(t, err)
Expand Down
12 changes: 6 additions & 6 deletions tests/sdk/java/configmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ func TestConfigMapAndSecretImmutability(t *testing.T) {
opttest.SkipInstall(),
)
t.Cleanup(func() {
test.Destroy()
test.Destroy(t)
})

// Create the secrets/configmaps.
up := test.Up()
up := test.Up(t)

// We will detect update/replacement behavior by observing effects on our
// downstream dependencies.
Expand All @@ -32,8 +32,8 @@ func TestConfigMapAndSecretImmutability(t *testing.T) {
mutableConfigmap := up.Outputs["mutableConfigmap"].Value.(string)

// Update the data of all our secrets and configmaps.
test.UpdateSource("testdata/immutability/step2")
up = test.Up()
test.UpdateSource(t, "testdata/immutability/step2")
up = test.Up(t)

// Only the mutable configmap and secret should have been updated -- so no
// impact on those two downstreams.
Expand All @@ -53,8 +53,8 @@ func TestConfigMapAndSecretImmutability(t *testing.T) {

// The final step only touches annotations. All resources should have been
// updated.
test.UpdateSource("testdata/immutability/step3")
up = test.Up()
test.UpdateSource(t, "testdata/immutability/step3")
up = test.Up(t)
assert.Equal(t, secret, up.Outputs["secret"].Value.(string))
assert.Equal(t, configmap, up.Outputs["configmap"].Value.(string))
assert.Equal(t, autonamedSecret, up.Outputs["autonamedSecret"].Value.(string))
Expand Down
14 changes: 7 additions & 7 deletions tests/sdk/java/csa_to_ssa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ func TestCSAToSSANoManagedFields(t *testing.T) {
test := pulumitest.NewPulumiTest(t, "testdata/csa-to-ssa", opttest.SkipInstall())
t.Logf("into %s", test.Source())
t.Cleanup(func() {
test.Destroy()
test.Destroy(t)
})
test.Preview()
test.Up()
test.Preview(t)
test.Up(t)

outputs, err := test.CurrentStack().Outputs(ctx)
require.NoError(t, err, "Failed to get outputs from stack")
Expand Down Expand Up @@ -85,8 +85,8 @@ func TestCSAToSSANoManagedFields(t *testing.T) {
require.Empty(t, dep.GetManagedFields(), "Failed to remove managedFields from deployment object")

// 3. Apply step 2 of testdata where SSA mode is enabled, with a change in the image spec field.
test.UpdateSource("testdata/csa-to-ssa/step2")
test.Preview()
test.Up()
test.Up(optup.ExpectNoChanges())
test.UpdateSource(t, "testdata/csa-to-ssa/step2")
test.Preview(t)
test.Up(t)
test.Up(t, optup.ExpectNoChanges())
}
6 changes: 3 additions & 3 deletions tests/sdk/java/kustomizev2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func TestKustomizeV2(t *testing.T) {
)
t.Logf("into %s", test.Source())
t.Cleanup(func() {
test.Destroy()
test.Destroy(t)
})
test.Preview()
test.Up()
test.Preview(t)
test.Up(t)
}
24 changes: 12 additions & 12 deletions tests/sdk/java/patch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ func TestPatchResources(t *testing.T) {
// 1. Create the resources.
test := pulumitest.NewPulumiTest(t, filepath.Join(testFolder, language, "step1"))
if language != "yaml" {
test.Install()
test.Install(t)
}
t.Logf("into %s", test.Source())
t.Cleanup(func() {
test.Destroy()
test.Destroy(t)
})

test.Preview()
outputs := test.Up().Outputs
test.Preview(t)
outputs := test.Up(t).Outputs
// Validate the resources do not contain the patch fields. Get the program outputs for use with `kubectl`.
namespace := outputs["nsName"].Value.(string)
resources := []rsc{
Expand Down Expand Up @@ -135,12 +135,12 @@ func TestPatchResources(t *testing.T) {
}

// 2. Patch the resources.
test.UpdateSource(testFolder, language, "step2")
test.UpdateSource(t, testFolder, language, "step2")
if language != "yaml" {
test.Install()
test.Install(t)
}
test.Preview()
test.Up()
test.Preview(t)
test.Up(t)

// Validate the resources contain the patch fields.
for _, resource := range resources {
Expand All @@ -166,13 +166,13 @@ func TestPatchResources(t *testing.T) {
}

// 3. Delete the Patch resources by reverting to the Pulumi program in step 1.
test.UpdateSource(testFolder, language, "step1")
test.UpdateSource(t, testFolder, language, "step1")
if language != "yaml" {
test.Install()
test.Install(t)
}

test.Preview()
test.Up()
test.Preview(t)
test.Up(t)

// Validate the resources do not contain the patch fields, and the object has not been deleted from cluster.
for _, resource := range resources {
Expand Down
20 changes: 10 additions & 10 deletions tests/sdk/java/preview_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ func TestPreviewReplacements(t *testing.T) {
test := pulumitest.NewPulumiTest(t, "testdata/preview-replacements", opttest.SkipInstall())
t.Logf("into %s", test.Source())
t.Cleanup(func() {
test.Destroy()
test.Destroy(t)
})
test.Preview()
test.Up()
test.Preview(t)
test.Up(t)

// Preview should not fail when there is a replacement due to immutable fields.
test.UpdateSource("testdata/preview-replacements", "step2")
test.Preview()
test.UpdateSource(t, "testdata/preview-replacements", "step2")
test.Preview(t)
}

// TestCRDPreviews ensures that CRDs are correctly previewed, and are not created or updated on the cluster.
Expand All @@ -36,20 +36,20 @@ func TestCRDPreviews(t *testing.T) {
test := pulumitest.NewPulumiTest(t, testFolder, opttest.SkipInstall())
t.Logf("into %s", test.Source())
t.Cleanup(func() {
test.Destroy()
test.Destroy(t)
})
test.Up()
test.Up(t)

// 2. Preview should not actually update the CRD resource. Step 2 adds a new field ("testNewField") to the CRD.
test.UpdateSource(testFolder, "step2")
test.Preview()
test.UpdateSource(t, testFolder, "step2")
test.Preview(t)

out, err := tests.Kubectl("get", "crd", crdName, "-o", "yaml")
require.NoError(t, err, "unable to get CRD with kubectl")
require.NotContains(t, string(out), "testNewField", "expected CRD to not have new field added in preview")

// 3. Update should actually update the CRD resource.
test.Up()
test.Up(t)
out, err = tests.Kubectl("get", "crd", crdName, "-o", "yaml")
require.NoError(t, err, "unable to get CRD with kubectl")
require.Contains(t, string(out), "testNewField", "expected CRD to have new field added in update operation")
Expand Down
14 changes: 7 additions & 7 deletions tests/sdk/java/yamlv2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ func TestYamlV2(t *testing.T) {
test := pulumitest.NewPulumiTest(t, "testdata/yamlv2", opttest.SkipInstall())
t.Logf("into %s", test.Source())
t.Cleanup(func() {
test.Destroy()
test.Destroy(t)
})
test.Preview()
test.Up()
test.Preview(t)
test.Up(t)
}

// TestJobUnreachable ensures that a panic does not occur when diffing Job resources against an unreachable API server.
Expand All @@ -30,16 +30,16 @@ func TestJobUnreachable(t *testing.T) {
test := pulumitest.NewPulumiTest(t, "testdata/job-unreachable", opttest.SkipInstall())
t.Logf("into %s", test.Source())
t.Cleanup(func() {
test.Destroy()
test.Destroy(t)
})
test.Preview()
test.Preview(t)

// Create the job, but expect it to fail as the job is meant to fail.
_, err := test.CurrentStack().Up(test.Context())
assert.ErrorContains(t, err, `but the Kubernetes API server reported that it failed to fully initialize or become live`)

// Re-run the Pulumi program with a malformed kubeconfig to simulate an unreachable API server.
// This should not panic annd preview should succeed.
test.UpdateSource("testdata/job-unreachable/step2")
test.Preview()
test.UpdateSource(t, "testdata/job-unreachable/step2")
test.Preview(t)
}
Loading

0 comments on commit eaaba7b

Please sign in to comment.