-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ServiceBus Namespace: polling for the deletion #1908
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,14 @@ package azurerm | |
import ( | ||
"fmt" | ||
"log" | ||
"regexp" | ||
"strings" | ||
|
||
"github.com/Azure/azure-sdk-for-go/services/servicebus/mgmt/2017-04-01/servicebus" | ||
"github.com/hashicorp/terraform/helper/schema" | ||
"github.com/hashicorp/terraform/helper/validation" | ||
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/response" | ||
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" | ||
"regexp" | ||
) | ||
|
||
// Default Authorization Rule/Policy created by Azure, used to populate the | ||
|
@@ -212,10 +213,19 @@ func resourceArmServiceBusNamespaceDelete(d *schema.ResourceData, meta interface | |
resourceGroup := id.ResourceGroup | ||
name := id.Path["namespaces"] | ||
|
||
_, err = client.Delete(ctx, resourceGroup, name) | ||
deleteFuture, err := client.Delete(ctx, resourceGroup, name) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = deleteFuture.WaitForCompletionRef(ctx, client.Client) | ||
if err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These lines could be combines as such: if err := deleteFuture.WaitForCompletionRef(ctx, client.Client); err != nil { |
||
if response.WasNotFound(deleteFuture.Response()) { | ||
return nil | ||
} | ||
|
||
return fmt.Errorf("Error deleting Service Bus %q: %+v", name, err) | ||
} | ||
|
||
return nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,6 +136,26 @@ func TestAccAzureRMServiceBusNamespace_NonStandardCasing(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccAzureRMServiceBusNamespace_premium(t *testing.T) { | ||
resourceName := "azurerm_servicebus_namespace.test" | ||
ri := acctest.RandInt() | ||
config := testAccAzureRMServiceBusNamespace_premium(ri, testLocation()) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMServiceBusNamespaceDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: config, | ||
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureRMServiceBusNamespaceExists(resourceName), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testCheckAzureRMServiceBusNamespaceDestroy(s *terraform.State) error { | ||
client := testAccProvider.Meta().(*ArmClient).serviceBusNamespacesClient | ||
ctx := testAccProvider.Meta().(*ArmClient).StopContext | ||
|
@@ -221,3 +241,19 @@ resource "azurerm_servicebus_namespace" "test" { | |
} | ||
`, rInt, location, rInt) | ||
} | ||
|
||
func testAccAzureRMServiceBusNamespace_premium(rInt int, location string) string { | ||
return fmt.Sprintf(` | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-%d" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we align these assignments? |
||
location = "%s" | ||
} | ||
resource "azurerm_servicebus_namespace" "test" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And add a space here between the resources |
||
name = "acctestservicebusnamespace-%d" | ||
location = "${azurerm_resource_group.test.location}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
sku = "Premium" | ||
capacity = 1 | ||
} | ||
`, rInt, location, rInt) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we call this
future
to match the rest of the codebase?