-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into renovate/github.com-googlecloudplatform-clou…
…d-foundation-toolkit-infra-blueprint-test-0.x
- Loading branch information
Showing
6 changed files
with
92 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,11 +37,32 @@ func TestUnit_MainScript_InstallMode(goTester *testing.T) { | |
util.LogError(err, "Failed to read current working directory") | ||
credentialsFile := fmt.Sprintf("%s/credentials_file.json", workingDir) | ||
|
||
dummyCredentials := ` | ||
{ | ||
"type": "service_account", | ||
"project_id": "temp-proj", | ||
"private_key_id": "pkey-id", | ||
"private_key": "-----BEGIN PRIVATE KEY-----\npkey\n-----END PRIVATE KEY-----\n", | ||
"client_email": "[email protected]", | ||
"client_id": "12344321", | ||
"auth_uri": "https://accounts.google.com/o/oauth2/auth", | ||
"token_uri": "https://oauth2.googleapis.com/token", | ||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", | ||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/[email protected]" | ||
} | ||
` | ||
if _, err := os.Stat(credentialsFile); err == nil { | ||
os.Remove(credentialsFile) | ||
} | ||
tmpFile, err := os.Create(credentialsFile) | ||
util.LogError(err, fmt.Sprintf("Could not create temporary file at %s", credentialsFile)) | ||
defer tmpFile.Close() | ||
defer os.Remove(credentialsFile) | ||
|
||
_, err = tmpFile.WriteString(dummyCredentials) | ||
util.LogError(err, fmt.Sprintf("Could not write to temporary file at %s", credentialsFile)) | ||
tmpFile.Sync() | ||
|
||
mode := "install" | ||
resourcesPath := "./resources" | ||
bootDiskSize := 175 | ||
|
@@ -95,7 +116,7 @@ func TestUnit_MainScript_InstallMode(goTester *testing.T) { | |
strings.HasSuffix(moduleAddress, "vm_hosts") || | ||
strings.HasSuffix(moduleAddress, "service_accounts") || | ||
strings.Contains(moduleAddress, "google_apis") || | ||
strings.Contains(moduleAddress, "init_hosts") || | ||
strings.Contains(moduleAddress, "init_hosts") || | ||
strings.Contains(moduleAddress, "gke_hub_membership") { | ||
continue | ||
} else if strings.Contains(moduleAddress, "install_abm") { | ||
|
@@ -123,11 +144,32 @@ func TestUnit_MainScript_ManualLB(goTester *testing.T) { | |
util.LogError(err, "Failed to read current working directory") | ||
credentialsFile := fmt.Sprintf("%s/credentials_file.json", workingDir) | ||
|
||
dummyCredentials := ` | ||
{ | ||
"type": "service_account", | ||
"project_id": "temp-proj", | ||
"private_key_id": "pkey-id", | ||
"private_key": "-----BEGIN PRIVATE KEY-----\npkey\n-----END PRIVATE KEY-----\n", | ||
"client_email": "[email protected]", | ||
"client_id": "12344321", | ||
"auth_uri": "https://accounts.google.com/o/oauth2/auth", | ||
"token_uri": "https://oauth2.googleapis.com/token", | ||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", | ||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/[email protected]" | ||
} | ||
` | ||
if _, err := os.Stat(credentialsFile); err == nil { | ||
os.Remove(credentialsFile) | ||
} | ||
tmpFile, err := os.Create(credentialsFile) | ||
util.LogError(err, fmt.Sprintf("Could not create temporary file at %s", credentialsFile)) | ||
defer tmpFile.Close() | ||
defer os.Remove(credentialsFile) | ||
|
||
_, err = tmpFile.WriteString(dummyCredentials) | ||
util.LogError(err, fmt.Sprintf("Could not write to temporary file at %s", credentialsFile)) | ||
tmpFile.Sync() | ||
|
||
bootDiskSize := 175 | ||
abmClusterID := "test-abm-cluster-id" | ||
resourcesPath := "./resources" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,11 +39,32 @@ func TestUnit_MainScript(goTester *testing.T) { | |
util.LogError(err, "Failed to read current working directory") | ||
credentialsFile := fmt.Sprintf("%s/credentials_file.json", workingDir) | ||
|
||
dummyCredentials := ` | ||
{ | ||
"type": "service_account", | ||
"project_id": "temp-proj", | ||
"private_key_id": "pkey-id", | ||
"private_key": "-----BEGIN PRIVATE KEY-----\npkey\n-----END PRIVATE KEY-----\n", | ||
"client_email": "[email protected]", | ||
"client_id": "12344321", | ||
"auth_uri": "https://accounts.google.com/o/oauth2/auth", | ||
"token_uri": "https://oauth2.googleapis.com/token", | ||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", | ||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/[email protected]" | ||
} | ||
` | ||
if _, err := os.Stat(credentialsFile); err == nil { | ||
os.Remove(credentialsFile) | ||
} | ||
tmpFile, err := os.Create(credentialsFile) | ||
util.LogError(err, fmt.Sprintf("Could not create temporary file at %s", credentialsFile)) | ||
defer tmpFile.Close() | ||
defer os.Remove(credentialsFile) | ||
|
||
_, err = tmpFile.WriteString(dummyCredentials) | ||
util.LogError(err, fmt.Sprintf("Could not write to temporary file at %s", credentialsFile)) | ||
tmpFile.Sync() | ||
|
||
resourcesPath := "./resources" | ||
username := "test_username" | ||
minCPUPlatform := "test_cpu_platform" | ||
|
@@ -131,6 +152,7 @@ func TestUnit_MainScript(goTester *testing.T) { | |
var terraformPlan util.MainModulePlan | ||
err = json.Unmarshal([]byte(tfPlanJSON), &terraformPlan) | ||
util.LogError(err, "Failed to parse the JSON plan into the MainModulePlan struct in unit/module_main.go") | ||
util.WriteToFile(tfPlanJSON, "../../plan.json") | ||
/** | ||
* Pro tip: | ||
* Write the json to a file using the util.WriteToFile() method to easily debug | ||
|
@@ -280,11 +302,32 @@ func TestUnit_MainScript_ValidateDefaults(goTester *testing.T) { | |
credentialsFile := fmt.Sprintf("%s/credentials_file.json", workingDir) | ||
resourcesPath := "./resources" | ||
|
||
dummyCredentials := ` | ||
{ | ||
"type": "service_account", | ||
"project_id": "temp-proj", | ||
"private_key_id": "pkey-id", | ||
"private_key": "-----BEGIN PRIVATE KEY-----\npkey\n-----END PRIVATE KEY-----\n", | ||
"client_email": "[email protected]", | ||
"client_id": "12344321", | ||
"auth_uri": "https://accounts.google.com/o/oauth2/auth", | ||
"token_uri": "https://oauth2.googleapis.com/token", | ||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", | ||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/[email protected]" | ||
} | ||
` | ||
if _, err := os.Stat(credentialsFile); err == nil { | ||
os.Remove(credentialsFile) | ||
} | ||
tmpFile, err := os.Create(credentialsFile) | ||
util.LogError(err, fmt.Sprintf("Could not create temporary file at %s", credentialsFile)) | ||
defer tmpFile.Close() | ||
defer os.Remove(credentialsFile) | ||
|
||
_, err = tmpFile.WriteString(dummyCredentials) | ||
util.LogError(err, fmt.Sprintf("Could not write to temporary file at %s", credentialsFile)) | ||
tmpFile.Sync() | ||
|
||
machineType := "test_machine_type" | ||
tfPlanOutput := "terraform_test.tfplan" | ||
tfPlanOutputArg := fmt.Sprintf("-out=%s", tfPlanOutput) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters