Skip to content

Commit

Permalink
Merge pull request #25578 from xiaxyi/signalR/addPremiumP2Sku
Browse files Browse the repository at this point in the history
`azurerm_web_pubsub`, `azurerm_signalr_service` - add `Premium_P2` to SKU property
  • Loading branch information
tombuildsstuff authored Apr 11, 2024
2 parents f621dea + 69e70d8 commit a412752
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 18 deletions.
8 changes: 5 additions & 3 deletions internal/services/signalr/signalr_service_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,13 +828,15 @@ func resourceArmSignalRServiceSchema() map[string]*pluginsdk.Schema {
"Free_F1",
"Standard_S1",
"Premium_P1",
"Premium_P2",
}, false),
},

"capacity": {
Type: pluginsdk.TypeInt,
Required: true,
ValidateFunc: validation.IntInSlice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}),
Type: pluginsdk.TypeInt,
Required: true,
ValidateFunc: validation.IntInSlice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200,
300, 400, 500, 600, 700, 800, 900, 1000}),
},
},
},
Expand Down
35 changes: 29 additions & 6 deletions internal/services/signalr/signalr_service_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,36 @@ func TestAccSignalRService_identity(t *testing.T) {
})
}

func TestAccSignalRService_premium(t *testing.T) {
func TestAccSignalRService_premiumP1(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_signalr_service", "test")
r := SignalRServiceResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.premium(data),
Config: r.premium(data, "Premium_P1", 1),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("hostname").Exists(),
check.That(data.ResourceName).Key("ip_address").Exists(),
check.That(data.ResourceName).Key("public_port").Exists(),
check.That(data.ResourceName).Key("server_port").Exists(),
check.That(data.ResourceName).Key("primary_access_key").Exists(),
check.That(data.ResourceName).Key("primary_connection_string").Exists(),
check.That(data.ResourceName).Key("secondary_access_key").Exists(),
check.That(data.ResourceName).Key("secondary_connection_string").Exists(),
),
},
data.ImportStep(),
})
}

func TestAccSignalRService_premiumP2(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_signalr_service", "test")
r := SignalRServiceResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.premium(data, "Premium_P2", 100),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("hostname").Exists(),
Expand Down Expand Up @@ -690,7 +713,7 @@ resource "azurerm_signalr_service" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

func (r SignalRServiceResource) premium(data acceptance.TestData) string {
func (r SignalRServiceResource) premium(data acceptance.TestData, planSku string, capacity int) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
Expand All @@ -707,11 +730,11 @@ resource "azurerm_signalr_service" "test" {
resource_group_name = azurerm_resource_group.test.name
sku {
name = "Premium_P1"
capacity = 1
name = "%s"
capacity = %d
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, planSku, capacity)
}

func (r SignalRServiceResource) requiresImport(data acceptance.TestData) string {
Expand Down
11 changes: 6 additions & 5 deletions internal/services/signalr/web_pubsub_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,18 @@ func resourceWebPubSub() *pluginsdk.Resource {
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"Premium_P1",
"Premium_P2",
"Standard_S1",
"Free_F1",
}, false),
},

"capacity": {
Type: pluginsdk.TypeInt,
Optional: true,
Default: 1,
ValidateFunc: validation.IntInSlice([]int{1, 2, 5, 10, 20, 50, 100}),
},
Type: pluginsdk.TypeInt,
Optional: true,
Default: 1,
ValidateFunc: validation.IntInSlice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200,
300, 400, 500, 600, 700, 800, 900, 1000})},

"live_trace": {
Type: pluginsdk.TypeList,
Expand Down
58 changes: 58 additions & 0 deletions internal/services/signalr/web_pubsub_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,50 @@ func TestAccWebPubsub_basic(t *testing.T) {
})
}

func TestAccWebPubsub_premiumP1(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_web_pubsub", "test")
r := WebPubsubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.premium(data, "Premium_P1", 1),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("hostname").Exists(),
check.That(data.ResourceName).Key("public_port").Exists(),
check.That(data.ResourceName).Key("server_port").Exists(),
check.That(data.ResourceName).Key("primary_access_key").Exists(),
check.That(data.ResourceName).Key("primary_connection_string").Exists(),
check.That(data.ResourceName).Key("secondary_access_key").Exists(),
check.That(data.ResourceName).Key("secondary_connection_string").Exists(),
),
},
data.ImportStep(),
})
}

func TestAccWebPubsub_premiumP2(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_web_pubsub", "test")
r := WebPubsubResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.premium(data, "Premium_P2", 100),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("hostname").Exists(),
check.That(data.ResourceName).Key("public_port").Exists(),
check.That(data.ResourceName).Key("server_port").Exists(),
check.That(data.ResourceName).Key("primary_access_key").Exists(),
check.That(data.ResourceName).Key("primary_connection_string").Exists(),
check.That(data.ResourceName).Key("secondary_access_key").Exists(),
check.That(data.ResourceName).Key("secondary_connection_string").Exists(),
),
},
data.ImportStep(),
})
}

func TestAccWebPubsub_complete(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_web_pubsub", "test")
r := WebPubsubResource{}
Expand Down Expand Up @@ -264,6 +308,20 @@ resource "azurerm_web_pubsub" "test" {
`, r.template(data), data.RandomInteger)
}

func (r WebPubsubResource) premium(data acceptance.TestData, sku string, capacity int) string {
return fmt.Sprintf(`
%s
resource "azurerm_web_pubsub" "test" {
name = "acctestWebPubsub-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku = "%s"
capacity = %d
}
`, r.template(data), data.RandomInteger, sku, capacity)
}

func (r WebPubsubResource) complete(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
Expand Down
6 changes: 4 additions & 2 deletions website/docs/r/signalr_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ A `live_trace` block supports the following:

A `sku` block supports the following:

* `name` - (Required) Specifies which tier to use. Valid values are `Free_F1`, `Standard_S1` and `Premium_P1`.
* `name` - (Required) Specifies which tier to use. Valid values are `Free_F1`, `Standard_S1`, `Premium_P1` and `Premium_P2`.

* `capacity` - (Required) Specifies the number of units associated with this SignalR service. Valid values are `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `20`, `30`, `40`, `50`, `60`, `70`, `80`, `90` and `100`.
* `capacity` - (Required) Specifies the number of units associated with this SignalR service. Valid values are `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `20`, `30`, `40`, `50`, `60`, `70`, `80`, `90`, `100`, `200`, `300`, `400`, `500`, `600`, `700`, `800`, `900` and `1000`.

~> **NOTE:** The valid capacity range for sku `Free_F1` is `1`, for sku `Premium_P2` is from `100` to `1000`, and from `1` to `100` for sku `Standard_S1` and `Premium_P1`.

---

Expand Down
6 changes: 4 additions & 2 deletions website/docs/r/web_pubsub.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ The following arguments are supported:

* `location` - (Required) Specifies the supported Azure location where the Web PubSub service exists. Changing this forces a new resource to be created.

* `sku` - (Required) Specifies which SKU to use. Possible values are `Free_F1`, `Standard_S1`, and `Premium_P1`.
* `sku` - (Required) Specifies which SKU to use. Possible values are `Free_F1`, `Standard_S1`, `Premium_P1` and `Premium_P2`.

* `capacity` - (Optional) Specifies the number of units associated with this Web PubSub resource. Valid values are: Free: `1`, Standard: `1`, `2`, `5`, `10`, `20`, `50`, `100`.
* `capacity` - (Optional) Specifies the number of units associated with this Web PubSub resource. Valid values are `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `20`, `30`, `40`, `50`, `60`, `70`, `80`, `90`, `100`, `200`, `300`, `400`, `500`, `600`, `700`, `800`, `900` and `1000`.

~> **NOTE:** The valid capacity range for sku `Free_F1` is `1`, for sku `Premium_P2` is from `100` to `1000`, and from `1` to `100` for sku `Standard_S1` and `Premium_P1`.

* `public_network_access_enabled` - (Optional) Whether to enable public network access? Defaults to `true`.

Expand Down

0 comments on commit a412752

Please sign in to comment.