microsoft / terraform-provider-power-platform

Power Platform Terraform Provider
https://registry.terraform.io/providers/microsoft/power-platform/latest/docs
MIT License
35 stars 13 forks source link

Acceptance tests that use azapi failing #482

Closed mattdot closed 1 month ago

mattdot commented 1 month ago

Describe the bug

=== RUN   TestAccBillingPolicyResource_Validate_Create
2024-10-02T20:45:48.082Z [WARN]  sdk.helper_resource: Error running Terraform CLI command: test_name=TestAccBillingPolicyResource_Validate_Create test_terraform_path=/home/runner/work/_temp/a0ad3463-bfab-4d31-a701-d32925886fe6/terraform test_working_directory=/tmp/plugintest362[709](https://github.com/microsoft/terraform-provider-power-platform/actions/runs/11150307579/job/30993261946#step:8:710)1347 test_step_number=1
  error=
  | exit status 1
  | 
  | Error: Resource already exists
  | 
  |   with azapi_resource.rg_example,
  |   on terraform_plugin_test.tf line 19, in resource "azapi_resource" "rg_example":
  |   19: \t\t\t\tresource "azapi_resource" "rg_example" {
  | 
  | A resource with the ID
  | "/subscriptions/***/resourceGroups/power-platform-billing-TestAccBillingPolicyResource_Validate_Create"
  | already exists - to be managed via Terraform this resource needs to be
  | imported into the State. Please see the resource documentation for
  | "azapi_resource" for more information.

Error: -02T20:45:48.083Z [ERROR] sdk.helper_resource: Unexpected error: test_name=TestAccBillingPolicyResource_Validate_Create test_terraform_path=/home/runner/work/_temp/a0ad3463-bfab-4d31-a701-d32925886fe6/terraform test_working_directory=/tmp/plugintest3627091347 test_step_number=1
  error=
  | Error running apply: exit status 1
  | 
  | Error: Resource already exists
  | 
  |   with azapi_resource.rg_example,
  |   on terraform_plugin_test.tf line 19, in resource "azapi_resource" "rg_example":
  |   19: \t\t\t\tresource "azapi_resource" "rg_example" {
  | 
  | A resource with the ID
  | "/subscriptions/***/resourceGroups/power-platform-billing-TestAccBillingPolicyResource_Validate_Create"
  | already exists - to be managed via Terraform this resource needs to be
  | imported into the State. Please see the resource documentation for
  | "azapi_resource" for more information.

    resource_billing_policy_test.go:21: Step 1/1 error: Error running apply: exit status 1

        Error: Resource already exists

          with azapi_resource.rg_example,
          on terraform_plugin_test.tf line 19, in resource "azapi_resource" "rg_example":
          19:               resource "azapi_resource" "rg_example" {

        A resource with the ID
        "/subscriptions/***/resourceGroups/power-platform-billing-TestAccBillingPolicyResource_Validate_Create"
        already exists - to be managed via Terraform this resource needs to be
        imported into the State. Please see the resource documentation for
        "azapi_resource" for more information.
--- FAIL: TestAccBillingPolicyResource_Validate_Create (4.38s)

Expected behavior

Tests should clean up after themselves, and test resource names should be randomized to prevent blocking conflicts

System Information

Additional context

Add any other context about the problem here.

Contribution

Do you plan to raise a PR to address this issue? YES / NO?