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

Common list of GCP regions to avoid in tests #1133

Merged
merged 1 commit into from
Jun 2, 2022
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
12 changes: 6 additions & 6 deletions modules/gcp/compute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ const DEFAULT_MACHINE_TYPE = "f1-micro"
const DEFAULT_IMAGE_FAMILY_PROJECT_NAME = "ubuntu-os-cloud"
const DEFAULT_IMAGE_FAMILY_NAME = "family/ubuntu-1804-lts"

// Regions that don't support running f1-micro instances
var RegionsToAvoid = []string{"asia-east2", "southamerica-west1", "europe-west8"}

func TestGetPublicIpOfInstance(t *testing.T) {
t.Parallel()

instanceName := RandomValidGcpName()
projectID := GetGoogleProjectIDFromEnvVar(t)
zone := GetRandomZone(t, projectID, nil, nil, []string{"southamerica-west1"})
zone := GetRandomZone(t, projectID, nil, nil, RegionsToAvoid)

createComputeInstance(t, projectID, zone, instanceName)
defer deleteComputeInstance(t, projectID, zone, instanceName)
Expand Down Expand Up @@ -74,8 +77,7 @@ func TestGetAndSetLabels(t *testing.T) {
instanceName := RandomValidGcpName()
projectID := GetGoogleProjectIDFromEnvVar(t)

// On October 22, 2018, GCP launched the asia-east2 region, which promptly failed all our tests, so blacklist asia-east2.
zone := GetRandomZone(t, projectID, nil, nil, []string{"asia-east2"})
zone := GetRandomZone(t, projectID, nil, nil, RegionsToAvoid)

createComputeInstance(t, projectID, zone, instanceName)
defer deleteComputeInstance(t, projectID, zone, instanceName)
Expand Down Expand Up @@ -111,9 +113,7 @@ func TestGetAndSetMetadata(t *testing.T) {
projectID := GetGoogleProjectIDFromEnvVar(t)
instanceName := RandomValidGcpName()

// The following zones do not have f1-micro instances available, so we avoid them
zonesToAvoid := []string{"asia-east2", "southamerica-west1"}
zone := GetRandomZone(t, projectID, nil, nil, zonesToAvoid)
zone := GetRandomZone(t, projectID, nil, nil, RegionsToAvoid)

// Create a new Compute Instance
createComputeInstance(t, projectID, zone, instanceName)
Expand Down
7 changes: 4 additions & 3 deletions test/gcp/packer_gcp_basic_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ var DefaultRetryablePackerErrors = map[string]string{
}
var DefaultTimeBetweenPackerRetries = 15 * time.Second

// Regions that don't support n1-standard-1 instances
var RegionsToAvoid = []string{"asia-east2", "southamerica-west1", "europe-west8"}

const DefaultMaxPackerRetries = 3

// An example of how to test the Packer template in examples/packer-basic-example using Terratest.
Expand All @@ -32,9 +35,7 @@ func TestPackerGCPBasicExample(t *testing.T) {
projectID := gcp.GetGoogleProjectIDFromEnvVar(t)

// Pick a random GCP zone to test in. This helps ensure your code works in all regions.
// zones that don't support n1-standard-1 instances
zonesToAvoid := []string{"asia-east2", "southamerica-west1"}
zone := gcp.GetRandomZone(t, projectID, nil, nil, zonesToAvoid)
zone := gcp.GetRandomZone(t, projectID, nil, nil, RegionsToAvoid)

packerOptions := &packer.Options{
// The path to where the Packer template is located
Expand Down
4 changes: 1 addition & 3 deletions test/gcp/terraform_gcp_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ func TestSshAccessToComputeInstance(t *testing.T) {
// Setup values for our Terraform apply
projectID := gcp.GetGoogleProjectIDFromEnvVar(t)
randomValidGcpName := gcp.RandomValidGcpName()
// zones that don't support n1-standard-1 instances
zonesToAvoid := []string{"asia-east2", "southamerica-west1"}
zone := gcp.GetRandomZone(t, projectID, nil, nil, zonesToAvoid)
zone := gcp.GetRandomZone(t, projectID, nil, nil, RegionsToAvoid)

terraformOptions := &terraform.Options{
// The path to where our Terraform code is located
Expand Down
3 changes: 1 addition & 2 deletions test/gcp/terraform_gcp_ig_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ func TestTerraformGcpInstanceGroupExample(t *testing.T) {
// Setup values for our Terraform apply
projectId := gcp.GetGoogleProjectIDFromEnvVar(t)

// On October 22, 2018, GCP launched the asia-east2 region, which promptly failed all our tests, so blacklist asia-east2.
region := gcp.GetRandomRegion(t, projectId, nil, []string{"asia-east2"})
region := gcp.GetRandomRegion(t, projectId, nil, RegionsToAvoid)

randomValidGcpName := gcp.RandomValidGcpName()
clusterSize := 3
Expand Down