-
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
azurerm_servicebus_topic
- add premium namespace partition validation
#26680
base: main
Are you sure you want to change the base?
Changes from all commits
1ea2aa6
a8aa1e4
34b9699
f1fd24c
7f2390e
849feb8
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ package servicebus_test | |
import ( | ||
"context" | ||
"fmt" | ||
"regexp" | ||
"testing" | ||
|
||
"github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics" | ||
|
@@ -236,6 +237,37 @@ func TestAccServiceBusTopic_isoTimeSpanAttributes(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccServiceBusTopic_nonPartitionedPremiumNamespaceError(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_servicebus_topic", "test") | ||
r := ServiceBusTopicResource{} | ||
|
||
data.ResourceTest(t, r, []acceptance.TestStep{ | ||
{ | ||
Config: r.nonPartitionedPremiumNamespaceError(data), | ||
ExpectError: regexp.MustCompile("the parent premium namespace is not partitioned and the partitioning for premium namespace is only available at the namepsace creation"), | ||
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. This error message needs to be updated |
||
}, | ||
}) | ||
} | ||
|
||
func TestAccServiceBusTopic_partitionedPremiumNamespace(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_servicebus_topic", "test") | ||
r := ServiceBusTopicResource{} | ||
|
||
data.ResourceTest(t, r, []acceptance.TestStep{ | ||
{ | ||
Config: r.PremiumNamespacePartitioned(data, false), | ||
ExpectError: regexp.MustCompile("non-partitioned entities are not allowed in partitioned namespace"), | ||
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. This error message doesn't match what's been written in the resource |
||
}, | ||
{ | ||
Config: r.PremiumNamespacePartitioned(data, true), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep(), | ||
}) | ||
} | ||
|
||
func (t ServiceBusTopicResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { | ||
id, err := topics.ParseTopicID(state.ID) | ||
if err != nil { | ||
|
@@ -505,3 +537,61 @@ resource "azurerm_servicebus_topic" "test" { | |
} | ||
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) | ||
} | ||
|
||
func (ServiceBusTopicResource) PremiumNamespacePartitioned(data acceptance.TestData, enabled bool) string { | ||
return fmt.Sprintf(` | ||
provider "azurerm" { | ||
features {} | ||
} | ||
|
||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-%d" | ||
location = "%s" | ||
} | ||
|
||
resource "azurerm_servicebus_namespace" "test" { | ||
name = "acctestservicebusnamespace-%d" | ||
resource_group_name = azurerm_resource_group.test.name | ||
location = azurerm_resource_group.test.location | ||
sku = "Premium" | ||
premium_messaging_partitions = 2 | ||
capacity = 2 | ||
} | ||
|
||
resource "azurerm_servicebus_topic" "test" { | ||
name = "acctestservicebustopic-%d" | ||
namespace_id = azurerm_servicebus_namespace.test.id | ||
|
||
partitioning_enabled = %t | ||
} | ||
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, enabled) | ||
} | ||
|
||
func (ServiceBusTopicResource) nonPartitionedPremiumNamespaceError(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
provider "azurerm" { | ||
features {} | ||
} | ||
|
||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-%d" | ||
location = "%s" | ||
} | ||
|
||
resource "azurerm_servicebus_namespace" "test" { | ||
name = "acctestservicebusnamespace-%d" | ||
resource_group_name = azurerm_resource_group.test.name | ||
location = azurerm_resource_group.test.location | ||
sku = "Premium" | ||
premium_messaging_partitions = 1 | ||
capacity = 1 | ||
} | ||
|
||
resource "azurerm_servicebus_topic" "test" { | ||
name = "acctestservicebustopic-%d" | ||
namespace_id = azurerm_servicebus_namespace.test.id | ||
|
||
partitioning_enabled = true | ||
} | ||
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -61,7 +61,7 @@ The following arguments are supported: | |||||
|
||||||
* `partitioning_enabled` - (Optional) Boolean flag which controls whether to enable the topic to be partitioned across multiple message brokers. Changing this forces a new resource to be created. | ||||||
|
||||||
-> **NOTE:** Partitioning is available at entity creation for all queues and topics in Basic or Standard SKUs. It is not available for the Premium messaging SKU, but any previously existing partitioned entities in Premium namespaces continue to work as expected. Please [see the documentation](https://docs.microsoft.com/azure/service-bus-messaging/service-bus-partitioning) for more information. | ||||||
-> **NOTE:** Partitioning is available at entity creation for all queues and topics in Basic or Standard SKUs. It is not available for the Premium messaging SKU, but any previously existing partitioned entities in Premium namespaces continue to work as expected. For premium namespace, partitioning is available at namespace creation, and all queues and topics in the partitioned namespace will be partitioned, for the premium namespace that has `premium_messaging_partitions` sets to `1`, the namespace is not partitioned. Please [see the documentation](https://docs.microsoft.com/azure/service-bus-messaging/service-bus-partitioning) for more information. | ||||||
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.
Suggested change
|
||||||
|
||||||
* `max_message_size_in_kilobytes` - (Optional) Integer value which controls the maximum size of a message allowed on the topic for Premium SKU. For supported values see the "Large messages support" section of [this document](https://docs.microsoft.com/azure/service-bus-messaging/service-bus-premium-messaging#large-messages-support-preview). Defaults to `256`. | ||||||
|
||||||
|
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.
Can we please re-write this