Skip to content
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

Skip generated tests for google_tpu_v2_vm #9315

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions mmv1/products/tpuv2/Vm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ examples:
primary_resource_id: 'tpu'
vars:
vm_name: 'test-tpu'
skip_test: true # The test case is covered in the update test
- !ruby/object:Provider::Terraform::Examples
name: 'tpu_v2_vm_full'
min_version: 'beta'
primary_resource_id: 'tpu'
vars:
vm_name: 'test-tpu'
skip_test: true # The test case is covered in the update test
parameters:
- !ruby/object:Api::Type::String
name: 'zone'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ package tpuv2_test

<% unless version == 'ga' -%>
import (
"fmt"
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

"github.com/hashicorp/terraform-provider-google/google/acctest"
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
)

func TestAccTpuV2Vm_update(t *testing.T) {
Expand Down Expand Up @@ -95,4 +100,43 @@ resource "google_tpu_v2_vm" "tpu" {
}
`, context)
}

func testAccCheckTpuV2VmDestroyProducer(t *testing.T) func(s *terraform.State) error {
return func(s *terraform.State) error {
for name, rs := range s.RootModule().Resources {
if rs.Type != "google_tpu_v2_vm" {
continue
}
if strings.HasPrefix(name, "data.") {
continue
}

config := acctest.GoogleProviderConfig(t)

url, err := tpgresource.ReplaceVarsForTest(config, rs, "{{TpuV2BasePath}}projects/{{project}}/locations/{{zone}}/nodes/{{name}}")
if err != nil {
return err
}

billingProject := ""

if config.BillingProject != "" {
billingProject = config.BillingProject
}

_, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "GET",
Project: billingProject,
RawURL: url,
UserAgent: config.UserAgent,
})
if err == nil {
return fmt.Errorf("TpuV2Vm still exists at %s", url)
}
}

return nil
}
}
<% end -%>
Loading