Skip to content

Commit

Permalink
Add common list of regions to avoid in gcp test (#1133)
Browse files Browse the repository at this point in the history
  • Loading branch information
denis256 authored Jun 2, 2022
1 parent 4e0bc50 commit acdc337
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
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

0 comments on commit acdc337

Please sign in to comment.