Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -4447,7 +4447,7 @@ func TestAccContainerCluster_failedCreation(t *testing.T) {

clusterName := fmt.Sprintf("tf-test-cluster-%s", RandString(t, 10))

project := BootstrapProject(t, "tf-fail-cluster-test", GetTestBillingAccountFromEnv(t), []string{"container.googleapis.com"})
project := BootstrapProject(t, "tf-fail-cluster-", GetTestBillingAccountFromEnv(t), []string{"container.googleapis.com"})
removeContainerServiceAgentRoleFromContainerEngineRobot(t, project)

VcrTest(t, resource.TestCase{
Expand Down
11 changes: 10 additions & 1 deletion mmv1/third_party/terraform/utils/bootstrap_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,21 @@ func removeContainerServiceAgentRoleFromContainerEngineRobot(t *testing.T, proje
}
}

func BootstrapProject(t *testing.T, projectID, billingAccount string, services []string) *cloudresourcemanager.Project {
// BootstrapProject will create or get a project named
// "<projectIDPrefix><projectIDSuffix>" that will persist across test runs,
// where projectIDSuffix is based off of getTestProjectFromEnv(). The reason
// for the naming is to isolate bootstrapped projects by test environment.
// Given the existing projects being used by our team, the prefix provided to
// this function can be no longer than 18 characters.
func BootstrapProject(t *testing.T, projectIDPrefix, billingAccount string, services []string) *cloudresourcemanager.Project {
config := BootstrapConfig(t)
if config == nil {
return nil
}

projectIDSuffix := strings.Replace(GetTestProjectFromEnv(), "ci-test-project-", "", 1)
projectID := projectIDPrefix + projectIDSuffix

crmClient := config.NewResourceManagerClient(config.UserAgent)

project, err := crmClient.Projects.Get(projectID).Do()
Expand Down