From 157877a152cf157d4a40244b5ecadbc2485e9539 Mon Sep 17 00:00:00 2001 From: Ilia Babanov Date: Thu, 16 May 2024 11:32:55 +0200 Subject: [PATCH] Fix bundle destroy integration test (#1435) I've updated the `deploy_then_remove_resources` test template in the previous PR, but didn't notice that it was used in the destroy test too. Now destroy test also checks deletion of jobs --- internal/bundle/destroy_test.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/internal/bundle/destroy_test.go b/internal/bundle/destroy_test.go index 43c05fba..baccf4e6 100644 --- a/internal/bundle/destroy_test.go +++ b/internal/bundle/destroy_test.go @@ -6,7 +6,9 @@ import ( "path/filepath" "testing" + "github.com/databricks/cli/internal" "github.com/databricks/cli/internal/acc" + "github.com/databricks/cli/libs/env" "github.com/databricks/databricks-sdk-go/apierr" "github.com/google/uuid" "github.com/stretchr/testify/assert" @@ -17,9 +19,12 @@ func TestAccBundleDestroy(t *testing.T) { ctx, wt := acc.WorkspaceTest(t) w := wt.W + nodeTypeId := internal.GetNodeTypeId(env.Get(ctx, "CLOUD_ENV")) uniqueId := uuid.New().String() bundleRoot, err := initTestTemplate(t, ctx, "deploy_then_remove_resources", map[string]any{ - "unique_id": uniqueId, + "unique_id": uniqueId, + "node_type_id": nodeTypeId, + "spark_version": defaultSparkVersion, }) require.NoError(t, err) @@ -29,7 +34,7 @@ func TestAccBundleDestroy(t *testing.T) { _, err = os.ReadDir(snapshotsDir) assert.ErrorIs(t, err, os.ErrNotExist) - // deploy pipeline + // deploy resources err = deployBundle(t, ctx, bundleRoot) require.NoError(t, err) @@ -49,6 +54,12 @@ func TestAccBundleDestroy(t *testing.T) { require.NoError(t, err) assert.Equal(t, pipeline.Name, pipelineName) + // assert job is created + jobName := "test-bundle-job-" + uniqueId + job, err := w.Jobs.GetBySettingsName(ctx, jobName) + require.NoError(t, err) + assert.Equal(t, job.Settings.Name, jobName) + // destroy bundle err = destroyBundle(t, ctx, bundleRoot) require.NoError(t, err) @@ -57,6 +68,10 @@ func TestAccBundleDestroy(t *testing.T) { _, err = w.Pipelines.GetByName(ctx, pipelineName) assert.ErrorContains(t, err, "does not exist") + // assert job is deleted + _, err = w.Jobs.GetBySettingsName(ctx, jobName) + assert.ErrorContains(t, err, "does not exist") + // Assert snapshot file is deleted entries, err = os.ReadDir(snapshotsDir) require.NoError(t, err)