From 32862c14d334af7087000e5579afd31ef2d711ae Mon Sep 17 00:00:00 2001 From: Ramon Quitales Date: Mon, 11 Mar 2024 18:21:24 -0700 Subject: [PATCH] chore: add message to explain why tests are skipped in short mode --- tests/sdk/dotnet/dotnet_test.go | 2 +- tests/sdk/nodejs/examples/examples_test.go | 25 +++++++++++----------- tests/sdk/nodejs/nodejs_test.go | 12 +++++------ tests/sdk/nodejs/preview_test.go | 1 + tests/util.go | 4 ++-- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/tests/sdk/dotnet/dotnet_test.go b/tests/sdk/dotnet/dotnet_test.go index b1f93e0cf2..b41f86c04c 100644 --- a/tests/sdk/dotnet/dotnet_test.go +++ b/tests/sdk/dotnet/dotnet_test.go @@ -66,7 +66,7 @@ func TestDotnet_Basic(t *testing.T) { } func TestDotnet_Guestbook(t *testing.T) { - tests.SkipIfShort(t) // An external load balancer is required. + tests.SkipIfShort(t, "test creates a load balancer and requires a Cloud cluster") test := baseOptions.With(integration.ProgramTestOptions{ Dir: "guestbook", Quick: true, diff --git a/tests/sdk/nodejs/examples/examples_test.go b/tests/sdk/nodejs/examples/examples_test.go index 6dd6327ca5..38993b2ac1 100644 --- a/tests/sdk/nodejs/examples/examples_test.go +++ b/tests/sdk/nodejs/examples/examples_test.go @@ -43,7 +43,7 @@ func TestAccMinimal(t *testing.T) { } func TestAccGuestbook(t *testing.T) { - tests.SkipIfShort(t) + tests.SkipIfShort(t, "test provisions a load balancer and requires a cloud provider cluster to run") test := getBaseOptions(t). With(integration.ProgramTestOptions{ Dir: filepath.Join(getCwd(t), "guestbook"), @@ -134,7 +134,7 @@ func TestAccGuestbook(t *testing.T) { } func TestAccIngress(t *testing.T) { - tests.SkipIfShort(t) + tests.SkipIfShort(t, "test provisions a load balancer and requires a cloud provider cluster to run") testNetworkingV1 := getBaseOptions(t). With(integration.ProgramTestOptions{ Dir: filepath.Join(getCwd(t), "ingress"), @@ -164,7 +164,7 @@ func TestAccIngress(t *testing.T) { } func TestAccHelm(t *testing.T) { - tests.SkipIfShort(t) + tests.SkipIfShort(t, "test provisions a load balancer and requires a cloud provider cluster to run") test := getBaseOptions(t). With(integration.ProgramTestOptions{ Dir: filepath.Join(getCwd(t), "helm", "step1"), @@ -190,7 +190,7 @@ func TestAccHelm(t *testing.T) { } func TestHelmNoDefaultProvider(t *testing.T) { - tests.SkipIfShort(t) + tests.SkipIfShort(t, "test provisions a load balancer and requires a cloud provider cluster to run") test := getBaseOptions(t). With(integration.ProgramTestOptions{ Dir: filepath.Join(getCwd(t), "helm-no-default-provider"), @@ -204,7 +204,7 @@ func TestHelmNoDefaultProvider(t *testing.T) { } func TestAccHelmApiVersions(t *testing.T) { - tests.SkipIfShort(t) + tests.SkipIfShort(t, "test provisions a load balancer and requires a cloud provider cluster to run") test := getBaseOptions(t). With(integration.ProgramTestOptions{ Dir: filepath.Join(getCwd(t), "helm-api-versions", "step1"), @@ -221,7 +221,7 @@ func TestAccHelmApiVersions(t *testing.T) { } func TestAccHelmKubeVersion(t *testing.T) { - tests.SkipIfShort(t) + tests.SkipIfShort(t, "test provisions a load balancer and requires a cloud provider cluster to run") test := getBaseOptions(t). With(integration.ProgramTestOptions{ Dir: filepath.Join(getCwd(t), "helm-kube-version", "step1"), @@ -263,7 +263,7 @@ func TestAccHelmAllowCRDRendering(t *testing.T) { } func TestAccHelmLocal(t *testing.T) { - tests.SkipIfShort(t) + tests.SkipIfShort(t, "test provisions a load balancer and requires a cloud provider cluster to run") test := getBaseOptions(t). With(integration.ProgramTestOptions{ Dir: filepath.Join(getCwd(t), "helm-local", "step1"), @@ -307,7 +307,7 @@ func TestAccHelmLocal(t *testing.T) { } func TestAccPrometheusOperator(t *testing.T) { - tests.SkipIfShort(t) + tests.SkipIfShort(t, "test provisions a load balancer and requires a cloud provider cluster to run") test := getBaseOptions(t). With(integration.ProgramTestOptions{ Dir: filepath.Join(getCwd(t), "prometheus-operator"), @@ -354,7 +354,6 @@ func TestAccPrometheusOperator(t *testing.T) { //} func TestAccProvider(t *testing.T) { - tests.SkipIfShort(t) test := getBaseOptions(t). With(integration.ProgramTestOptions{ Dir: filepath.Join(getCwd(t), "provider"), @@ -364,7 +363,7 @@ func TestAccProvider(t *testing.T) { } func TestHelmRelease(t *testing.T) { - tests.SkipIfShort(t) + tests.SkipIfShort(t, "test provisions a load balancer and requires a cloud provider cluster to run") validationFunc := func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) { assert.NotEmpty(t, stackInfo.Outputs["redisMasterClusterIP"].(string)) assert.Equal(t, stackInfo.Outputs["status"], "deployed") @@ -427,7 +426,7 @@ func TestHelmRelease(t *testing.T) { func TestHelmReleaseCRD(t *testing.T) { // Validate that Helm charts with CRDs work across create/update/refresh/delete cycles. // https://github.com/pulumi/pulumi-kubernetes/issues/1712 - tests.SkipIfShort(t) + tests.SkipIfShort(t, "test provisions a load balancer and requires a cloud provider cluster to run") test := getBaseOptions(t). With(integration.ProgramTestOptions{ Dir: filepath.Join(getCwd(t), "helm-release-crd", "step1"), @@ -447,7 +446,7 @@ func TestHelmReleaseCRD(t *testing.T) { func TestHelmReleaseNamespace(t *testing.T) { // Validate fix for https://github.com/pulumi/pulumi-kubernetes/issues/1710 - tests.SkipIfShort(t) + tests.SkipIfShort(t, "test provisions a load balancer and requires a cloud provider cluster to run") test := getBaseOptions(t). With(integration.ProgramTestOptions{ Dir: filepath.Join(getCwd(t), "helm-release-namespace", "step1"), @@ -517,7 +516,7 @@ func TestHelmReleaseRedis(t *testing.T) { } // Validate fix for https://github.com/pulumi/pulumi-kubernetes/issues/1933 - tests.SkipIfShort(t) + tests.SkipIfShort(t, "test provisions a load balancer and requires a cloud provider cluster to run") test := getBaseOptions(t). With(integration.ProgramTestOptions{ Dir: filepath.Join(getCwd(t), "helm-release-redis", "step1"), diff --git a/tests/sdk/nodejs/nodejs_test.go b/tests/sdk/nodejs/nodejs_test.go index 642c5b8951..c16c5b38dd 100644 --- a/tests/sdk/nodejs/nodejs_test.go +++ b/tests/sdk/nodejs/nodejs_test.go @@ -453,7 +453,6 @@ func TestCRDs(t *testing.T) { } func TestPod(t *testing.T) { - tests.SkipIfShort(t) // statuses are different in Kind cluster test := baseOptions.With(integration.ProgramTestOptions{ Dir: filepath.Join("delete-before-replace", "step1"), Quick: true, @@ -489,7 +488,7 @@ func TestPod(t *testing.T) { conditions, _ := openapi.Pluck(pod.Outputs, "status", "conditions") ready := conditions.([]any)[1].(map[string]any) readyType := ready["type"] - assert.Equal(t, "Ready", readyType) + assert.Equal(t, "Ready", readyType, conditions) readyStatus := ready["status"] assert.Equal(t, "True", readyStatus) @@ -795,7 +794,7 @@ func TestGet(t *testing.T) { } func TestIstio(t *testing.T) { - tests.SkipIfShort(t) + tests.SkipIfShort(t, "test provisions a load balancer and requires a cloud provider cluster to run") test := baseOptions.With(integration.ProgramTestOptions{ Dir: filepath.Join("istio", "step1"), Quick: true, @@ -1957,7 +1956,7 @@ func TestClientSideDriftCorrectSSA(t *testing.T) { // 5. Re-enable access to the unreachable cluster and run `pulumi up` again. // 6. Validate that the resource in the unreachable cluster was updated. func TestSkipUpdateUnreachableFlag(t *testing.T) { - tests.SkipIfShort(t) + tests.SkipIfShort(t, "tests need to be updated to work with Kind clusters") var ns0, ns1, cm0, cm1 string test := baseOptions.With(integration.ProgramTestOptions{ @@ -2203,8 +2202,7 @@ func ignoreChageTest(t *testing.T, testFolderName string) { // and has a controller backing it. We create 2 pods to test egress between them, rather than hitting // a live URL, to avoid flakiness. func TestEmptyItemNormalization(t *testing.T) { - tests.SkipIfShort(t) - + tests.SkipIfShort(t, "test requires a cluster with NetworkPolicy support") validateProgram := func(networkingEnabled bool) func(*testing.T, integration.RuntimeValidationStackInfo) { return func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) { ns, ok := stackInfo.Outputs["podANamespace"].(string) @@ -2268,7 +2266,7 @@ func TestEmptyItemNormalization(t *testing.T) { // 3. Update the DeploymentPatch resource to further patch the deployment, setting the image to nginx:1.14.0, // and verify that other fields managed by kubectl-client-side-apply remain unaffected (Step 2). func TestFieldManagerPatchResources(t *testing.T) { - tests.SkipIfShort(t) + tests.SkipIfShort(t, "test needs to be reworked to work on Kind clusters") testFolder := "field-manager-patch-resources" createDeployment := func() string { diff --git a/tests/sdk/nodejs/preview_test.go b/tests/sdk/nodejs/preview_test.go index 453032932f..5e2aaa20cb 100644 --- a/tests/sdk/nodejs/preview_test.go +++ b/tests/sdk/nodejs/preview_test.go @@ -148,6 +148,7 @@ func createSAKubeconfig(t *testing.T, saName string) (string, error) { // TestPreviewWithApply tests the `pulumi preview` CUJ where the user Pulumi program contains an Apply call on status subresoruces. // This is to ensure we don't fail preview, since status fields are only populated after the resource is created on cluster. func TestPreviewWithApply(t *testing.T) { + tests.SkipIfShort(t, "test requires a load balancer and won't work on kind clusters") var externalIP, nsName, svcName string test := baseOptions.With(integration.ProgramTestOptions{ Dir: "preview-apply", diff --git a/tests/util.go b/tests/util.go index 88eef3c5e4..c82a89277f 100644 --- a/tests/util.go +++ b/tests/util.go @@ -15,9 +15,9 @@ import ( ) // SkipIfShort skips the test if the -short flag is passed to `go test`. -func SkipIfShort(t *testing.T) { +func SkipIfShort(t *testing.T, msg string) { if testing.Short() { - t.Skip("skipping long-running test in short mode") + t.Skip("skipping", t.Name(), "in short mode:", msg) } }