Skip to content

Commit

Permalink
add success test
Browse files Browse the repository at this point in the history
  • Loading branch information
marekbrysa committed May 31, 2022
1 parent 19e865b commit c185c6f
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions storage/gs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"testing"

"github.com/databrickslabs/terraform-provider-databricks/clusters"
"github.com/databrickslabs/terraform-provider-databricks/common"
"github.com/databrickslabs/terraform-provider-databricks/qa"
"github.com/stretchr/testify/assert"
Expand All @@ -26,3 +27,70 @@ func TestCreateOrValidateClusterForGoogleStorage_Failures(t *testing.T) {
assert.EqualError(t, err, "cannot create mounting cluster: nope")
})
}

func TestCreateOrValidateClusterForGoogleStorage_WorksOnDeletedCluster(t *testing.T) {
qa.HTTPFixturesApply(t, []qa.HTTPFixture{
{
Method: "GET",
Resource: "/api/2.0/clusters/get?cluster_id=removed-cluster",
Status: 404,
Response: common.NotFound("cluster deleted"),
},
{
Method: "GET",
Resource: "/api/2.0/clusters/list",
Response: clusters.ClusterList{
Clusters: []clusters.ClusterInfo{},
},
},
{
ReuseRequest: true,
Method: "GET",
Resource: "/api/2.0/clusters/spark-versions",
},
{
ReuseRequest: true,
Method: "GET",
Resource: "/api/2.0/clusters/list-node-types",
},
{
Method: "POST",
Resource: "/api/2.0/clusters/create",
ExpectedRequest: clusters.Cluster{
CustomTags: map[string]string{
"ResourceClass": "SingleNode",
},
ClusterName: "terraform-mount-gcs-03a56ec1d1576b505aabf088337cbf36",
GcpAttributes: &clusters.GcpAttributes{
GoogleServiceAccount: "service-account",
},
SparkVersion: "7.3.x-scala2.12",
NumWorkers: 0,
NodeTypeID: "i3.xlarge",
AutoterminationMinutes: 10,
SparkConf: map[string]string{
"spark.databricks.cluster.profile": "singleNode",
"spark.master": "local[*]",
"spark.scheduler.mode": "FIFO",
},
},
Response: clusters.ClusterID{
ClusterID: "new-cluster",
},
},
{
Method: "GET",
Resource: "/api/2.0/clusters/get?cluster_id=new-cluster",
Response: clusters.ClusterInfo{
ClusterID: "new-cluster",
State: "RUNNING",
StateMessage: "created",
},
},
}, func(ctx context.Context, client *common.DatabricksClient) {
d := ResourceMount().TestResourceData()
err := createOrValidateClusterForGoogleStorage(ctx, client, d, "removed-cluster", "service-account")
assert.NoError(t, err)
assert.Equal(t, "new-cluster", d.Get("cluster_id"))
})
}

0 comments on commit c185c6f

Please sign in to comment.