Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/labeler-issue-triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ service/load-balancers:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_lb((.|\n)*)###'

service/load-test:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_load_test((.|\n)*)###'
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_(load_test|playwright_workspace)((.|\n)*)###'

service/log-analytics:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_log_analytics_((.|\n)*)###'
Expand Down
3 changes: 3 additions & 0 deletions .teamcity/components/settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ var serviceTestConfigurationOverrides = mapOf(
// load balancer global tire Public IP is only available in
"loadbalancer" to testConfiguration(locationOverride = LocationConfiguration("westeurope", "eastus2", "westus", false)),

// Playwright workspace is only available in certain locations
"loadtestservice" to testConfiguration(locationOverride = LocationConfiguration("westeurope", "eastus", "westus3", false)),

// Log Analytics Clusters have a max deployments of 2 - parallelism set to 1 or `importTest` fails
"loganalytics" to testConfiguration(parallelism = 1),

Expand Down
13 changes: 11 additions & 2 deletions internal/services/loadtestservice/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import (
"fmt"

loadtestserviceV20221201 "github.com/hashicorp/go-azure-sdk/resource-manager/loadtestservice/2022-12-01"
"github.com/hashicorp/go-azure-sdk/resource-manager/loadtestservice/2025-09-01/playwrightworkspaces"
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)

type AutoClient struct {
V20221201 loadtestserviceV20221201.Client
V20221201 loadtestserviceV20221201.Client
PlaywrightWorkspacesClient *playwrightworkspaces.PlaywrightWorkspacesClient
}
Comment on lines 15 to 18
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disagree as the current format is widely applied


func NewClient(o *common.ClientOptions) (*AutoClient, error) {
Expand All @@ -23,7 +25,14 @@ func NewClient(o *common.ClientOptions) (*AutoClient, error) {
return nil, fmt.Errorf("building client for loadtestservice V20221201: %+v", err)
}

playwrightWorkspacesClient, err := playwrightworkspaces.NewPlaywrightWorkspacesClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building PlaywrightWorkspaces Client: %+v", err)
}
o.Configure(playwrightWorkspacesClient.Client, o.Authorizers.ResourceManager)

return &AutoClient{
V20221201: *v20221201Client,
V20221201: *v20221201Client,
PlaywrightWorkspacesClient: playwrightWorkspacesClient,
Comment on lines 34 to +36
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disagree as the current format is widely applied

}, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// Copyright IBM Corp. 2014, 2025
// SPDX-License-Identifier: MPL-2.0

package loadtestservice

import (
"context"
"fmt"
"regexp"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-sdk/resource-manager/loadtestservice/2025-09-01/playwrightworkspaces"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
)

type PlaywrightWorkspaceDataSource struct{}

var _ sdk.DataSource = PlaywrightWorkspaceDataSource{}

type PlaywrightWorkspaceDataSourceModel struct {
Name string `tfschema:"name"`
ResourceGroupName string `tfschema:"resource_group_name"`
Location string `tfschema:"location"`
DataplaneUri string `tfschema:"dataplane_uri"`
WorkspaceId string `tfschema:"workspace_id"`
Tags map[string]string `tfschema:"tags"`
}

func (PlaywrightWorkspaceDataSource) Arguments() map[string]*pluginsdk.Schema {
return map[string]*pluginsdk.Schema{
"name": {
Type: pluginsdk.TypeString,
Required: true,
ValidateFunc: validation.StringMatch(
regexp.MustCompile(`^[a-zA-Z0-9-]{3,24}$`),
"length of `name` must be between 3 and 24 characters (inclusive) and contain only numbers, letters, and hyphens (-)"),
},

"resource_group_name": commonschema.ResourceGroupNameForDataSource(),
}
}

func (PlaywrightWorkspaceDataSource) Attributes() map[string]*pluginsdk.Schema {
return map[string]*pluginsdk.Schema{
"location": commonschema.LocationComputed(),

"dataplane_uri": {
Type: pluginsdk.TypeString,
Computed: true,
},

"workspace_id": {
Type: pluginsdk.TypeString,
Computed: true,
},

"tags": commonschema.TagsDataSource(),
}
}

func (PlaywrightWorkspaceDataSource) ModelObject() interface{} {
return &PlaywrightWorkspaceDataSourceModel{}
}

func (PlaywrightWorkspaceDataSource) ResourceType() string {
return "azurerm_playwright_workspace"
}

func (PlaywrightWorkspaceDataSource) Read() sdk.ResourceFunc {
return sdk.ResourceFunc{
Timeout: 5 * time.Minute,
Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error {
client := metadata.Client.LoadTestService.PlaywrightWorkspacesClient
subscriptionId := metadata.Client.Account.SubscriptionId

var state PlaywrightWorkspaceDataSourceModel
if err := metadata.Decode(&state); err != nil {
return fmt.Errorf("decoding: %+v", err)
}

id := playwrightworkspaces.NewPlaywrightWorkspaceID(subscriptionId, state.ResourceGroupName, state.Name)
resp, err := client.Get(ctx, id)
if err != nil {
if response.WasNotFound(resp.HttpResponse) {
return fmt.Errorf("%s was not found", id)
}

return fmt.Errorf("retrieving %s: %+v", id, err)
}

metadata.SetID(id)

if model := resp.Model; model != nil {
state.Location = location.NormalizeNilable(&model.Location)

if properties := model.Properties; properties != nil {
if dataplaneUri := properties.DataplaneUri; dataplaneUri != nil {
state.DataplaneUri = pointer.From(dataplaneUri)
}

if workspaceId := properties.WorkspaceId; workspaceId != nil {
state.WorkspaceId = pointer.From(workspaceId)
}
}

state.Tags = pointer.From(model.Tags)
}

return metadata.Encode(&state)
},
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright IBM Corp. 2014, 2025
// SPDX-License-Identifier: MPL-2.0

package loadtestservice_test

import (
"fmt"
"testing"

"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
)

type PlaywrightWorkspaceDataSource struct{}

func TestAccPlaywrightWorkspaceDataSource_basic(t *testing.T) {
data := acceptance.BuildTestData(t, "data.azurerm_playwright_workspace", "test")
r := PlaywrightWorkspaceDataSource{}

data.DataSourceTest(t, []acceptance.TestStep{
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).Key("location").HasValue(location.Normalize(data.Locations.Secondary)),
check.That(data.ResourceName).Key("dataplane_uri").Exists(),
check.That(data.ResourceName).Key("workspace_id").Exists(),
check.That(data.ResourceName).Key("tags.%").HasValue("2"),
check.That(data.ResourceName).Key("tags.Environment").HasValue("Sandbox"),
check.That(data.ResourceName).Key("tags.Label").HasValue("Test"),
),
},
})
}

func (PlaywrightWorkspaceDataSource) basic(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

resource "azurerm_resource_group" "test" {
name = "acctest-rg-pww-%d"
location = "%s"
}

resource "azurerm_playwright_workspace" "test" {
name = "acctest-pww-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location

tags = {
Environment = "Sandbox"
Label = "Test"
}
}

data "azurerm_playwright_workspace" "test" {
name = azurerm_playwright_workspace.test.name
resource_group_name = azurerm_playwright_workspace.test.resource_group_name
}
`, data.RandomInteger, data.Locations.Secondary, data.RandomIntOfLength(8))
}
Loading
Loading