Skip to content

Commit

Permalink
Test Fix: Kusto Service (#11570)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbfrahry authored May 4, 2021
1 parent 4a28d98 commit 80b4515
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ resource "azurerm_kusto_database" "followed_database" {
cluster_name = azurerm_kusto_cluster.cluster1.name
}
resource "azurerm_kusto_attached_database_configuration" "configuration1" {
resource "azurerm_kusto_attached_database_configuration" "test" {
name = "acctestka-%d"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestAccKustoClusterCustomerManagedKey_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
// Then ensure the encryption settings on the Kusto cluster
// have been reverted to their default state
data.CheckWithClient(r.clusterIsNotUsingCustomerManagedKey),
check.That("azurerm_kusto_cluster.test").DoesNotExistInAzure(r),
),
},
})
Expand Down Expand Up @@ -100,34 +100,12 @@ func (KustoClusterCustomerManagedKeyResource) Exists(ctx context.Context, client
}

if resp.ClusterProperties == nil || resp.ClusterProperties.KeyVaultProperties == nil {
return nil, fmt.Errorf("properties nil for %s", id.String())
return utils.Bool(false), nil
}

return utils.Bool(true), nil
}

func (r KustoClusterCustomerManagedKeyResource) clusterIsNotUsingCustomerManagedKey(ctx context.Context, client *clients.Client, state *terraform.InstanceState) error {
id, err := parse.ClusterID(state.ID)
if err != nil {
return err
}

resp, err := client.Kusto.ClustersClient.Get(ctx, id.ResourceGroup, id.Name)
if err != nil {
return fmt.Errorf("retrieving %s: %v", id.String(), err)
}

if resp.ClusterProperties == nil {
return fmt.Errorf("properties nil for %s", id.String())
}

if resp.ClusterProperties.KeyVaultProperties != nil {
return fmt.Errorf("keyVaultProperties was non-nil")
}

return nil
}

func (KustoClusterCustomerManagedKeyResource) basic(data acceptance.TestData) string {
template := KustoClusterCustomerManagedKeyResource{}.template(data)
return fmt.Sprintf(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ resource "azurerm_public_ip" "management_pip" {
name = "acctestkc%s-management-pip"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku = "Basic"
sku = "Standard"
allocation_method = "Static"
}
Expand Down

0 comments on commit 80b4515

Please sign in to comment.