From 6a9a7636a06e76048fa6156894823abf11335400 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 4 Mar 2020 19:46:58 -0500 Subject: [PATCH] [WIP] disabling traffic manager test (#1085) * disabling traffic manager test * removing always for scheudled trigger * Removing IP address creation from mc test * adding config file --- pipelines/bedrock-scheduled.yml | 2 +- test/bedrock_Azure_mc_test.go | 208 ++++++++++++++++---------------- 2 files changed, 105 insertions(+), 105 deletions(-) diff --git a/pipelines/bedrock-scheduled.yml b/pipelines/bedrock-scheduled.yml index 67c44e6..9f07d0e 100644 --- a/pipelines/bedrock-scheduled.yml +++ b/pipelines/bedrock-scheduled.yml @@ -5,7 +5,7 @@ schedules: branches: include: [master] # Uncomment below if we want builds to run when the code has NOT changed - # always: true + always: false variables: GOBIN: '$(GOPATH)/bin' # Go binaries path diff --git a/test/bedrock_Azure_mc_test.go b/test/bedrock_Azure_mc_test.go index 58278df..0676a2a 100644 --- a/test/bedrock_Azure_mc_test.go +++ b/test/bedrock_Azure_mc_test.go @@ -10,7 +10,6 @@ import ( "testing" "time" - "github.com/gruntwork-io/terratest/modules/http-helper" "github.com/gruntwork-io/terratest/modules/k8s" "github.com/gruntwork-io/terratest/modules/random" "github.com/gruntwork-io/terratest/modules/terraform" @@ -41,7 +40,7 @@ func TestIT_Bedrock_AzureMC_Test(t *testing.T) { // Generate a common infra resources for integration use with azure multicluster environment uniqueID := strings.ToLower(random.UniqueId()) k8sName := fmt.Sprintf("gtestk8s-%s", uniqueID) - k8sVersion := "1.15.7" + k8sVersion := "1.15.7" location := os.Getenv("DATACENTER_LOCATION") clientid := os.Getenv("ARM_CLIENT_ID") @@ -65,21 +64,21 @@ func TestIT_Bedrock_AzureMC_Test(t *testing.T) { azureCommonInfraFolder := "../cluster/test-temp-envs/azure-common-infra-" + k8sName copy.Copy("../cluster/environments/azure-common-infra", azureCommonInfraFolder) - //Create the common resource group - cmd0 := exec.Command("az", "login", "--service-principal", "-u", clientid, "-p", clientsecret, "--tenant", tenantid) - err0 := cmd0.Run() - if err0 != nil { - fmt.Println("unable to login to azure cli") - log.Fatal(err0) - os.Exit(-1) - } - cmd1 := exec.Command("az", "group", "create", "-n", kvRG, "-l", location) - err1 := cmd1.Run() - if err1 != nil { - fmt.Println("failed to create common resource group") - log.Fatal(err1) - os.Exit(-1) - } + //Create the common resource group + cmd0 := exec.Command("az", "login", "--service-principal", "-u", clientid, "-p", clientsecret, "--tenant", tenantid) + err0 := cmd0.Run() + if err0 != nil { + fmt.Println("unable to login to azure cli") + log.Fatal(err0) + os.Exit(-1) + } + cmd1 := exec.Command("az", "group", "create", "-n", kvRG, "-l", location) + err1 := cmd1.Run() + if err1 != nil { + fmt.Println("failed to create common resource group") + log.Fatal(err1) + os.Exit(-1) + } //Specify the test case folder and "-var" option mapping for the backend common_backend_tfOptions := &terraform.Options{ @@ -97,13 +96,13 @@ func TestIT_Bedrock_AzureMC_Test(t *testing.T) { TerraformDir: azureCommonInfraFolder, Upgrade: true, Vars: map[string]interface{}{ - "address_space": addressSpace, - "keyvault_name": kvName, - "global_resource_group_name": kvRG, - "service_principal_id": clientid, - "subnet_name": subnetName, - "subnet_prefix": addressSpace, - "vnet_name": vnetName, + "address_space": addressSpace, + "keyvault_name": kvName, + "global_resource_group_name": kvRG, + "service_principal_id": clientid, + "subnet_name": subnetName, + "subnet_prefix": addressSpace, + "vnet_name": vnetName, }, } @@ -127,38 +126,38 @@ func TestIT_Bedrock_AzureMC_Test(t *testing.T) { cluster_location2 := "eastus2" cluster_location3 := "centralus" - //Create the east resource group - cmd2 := exec.Command("az", "group", "create", "-n", k8s_eastRG, "-l", cluster_location2) - err2 := cmd2.Run() - if err2 != nil { - fmt.Println("failed to create east resource group") - log.Fatal(err2) - os.Exit(-1) - } - //Create the west resource group - cmd3 := exec.Command("az", "group", "create", "-n", k8s_westRG, "-l", cluster_location1) - err3 := cmd3.Run() - if err3 != nil { - fmt.Println("failed to create west resource group") - log.Fatal(err3) - os.Exit(-1) - } - //Create the central resource group - cmd4 := exec.Command("az", "group", "create", "-n", k8s_centralRG, "-l", cluster_location3) - err4 := cmd4.Run() - if err4 != nil { - fmt.Println("failed to create central resource group") - log.Fatal(err4) - os.Exit(-1) - } - //Create the global resource group - cmd5 := exec.Command("az", "group", "create", "-n", k8s_globalRG, "-l", location) - err5 := cmd5.Run() - if err5 != nil { - fmt.Println("failed to create global resource group") - log.Fatal(err5) - os.Exit(-1) - } + //Create the east resource group + cmd2 := exec.Command("az", "group", "create", "-n", k8s_eastRG, "-l", cluster_location2) + err2 := cmd2.Run() + if err2 != nil { + fmt.Println("failed to create east resource group") + log.Fatal(err2) + os.Exit(-1) + } + //Create the west resource group + cmd3 := exec.Command("az", "group", "create", "-n", k8s_westRG, "-l", cluster_location1) + err3 := cmd3.Run() + if err3 != nil { + fmt.Println("failed to create west resource group") + log.Fatal(err3) + os.Exit(-1) + } + //Create the central resource group + cmd4 := exec.Command("az", "group", "create", "-n", k8s_centralRG, "-l", cluster_location3) + err4 := cmd4.Run() + if err4 != nil { + fmt.Println("failed to create central resource group") + log.Fatal(err4) + os.Exit(-1) + } + //Create the global resource group + cmd5 := exec.Command("az", "group", "create", "-n", k8s_globalRG, "-l", location) + err5 := cmd5.Run() + if err5 != nil { + fmt.Println("failed to create global resource group") + log.Fatal(err5) + os.Exit(-1) + } publickey := os.Getenv("public_key") sshkey := os.Getenv("ssh_key") @@ -189,18 +188,18 @@ func TestIT_Bedrock_AzureMC_Test(t *testing.T) { "keyvault_resource_group": kvRG, "kubernetes_version": k8sVersion, - "traffic_manager_profile_name": tmName, - "traffic_manager_dns_name": tm_dnsprefix, - "traffic_manager_resource_group_name": k8s_globalRG, + "traffic_manager_profile_name": tmName, + "traffic_manager_dns_name": tm_dnsprefix, + "traffic_manager_resource_group_name": k8s_globalRG, - "west_resource_group_name": k8s_westRG, - "gitops_west_path": "", + "west_resource_group_name": k8s_westRG, + "gitops_west_path": "", - "east_resource_group_name": k8s_eastRG, - "gitops_east_path": "", + "east_resource_group_name": k8s_eastRG, + "gitops_east_path": "", - "central_resource_group_name": k8s_centralRG, - "gitops_central_path": "", + "central_resource_group_name": k8s_centralRG, + "gitops_central_path": "", }, } @@ -303,53 +302,54 @@ func TestIT_Bedrock_AzureMC_Test(t *testing.T) { //Deploy app to all 3 clusters configFile := "azure-vote.yaml" - addIPandRGtoYAML(configFile, string(westIP), k8s_westRG) + // addIPandRGtoYAML(configFile, string(westIP), k8s_westRG) k8s.KubectlApply(t, options, configFile) - addIPandRGtoYAML(configFile, string(eastIP), k8s_eastRG) + // addIPandRGtoYAML(configFile, string(eastIP), k8s_eastRG) k8s.KubectlApply(t, options2, configFile) - addIPandRGtoYAML(configFile, string(centralIP), k8s_centralRG) + // addIPandRGtoYAML(configFile, string(centralIP), k8s_centralRG) k8s.KubectlApply(t, options3, configFile) - //Test Case 7: Validate Traffic Manager - testTM_URL := "http://" + tm_dnsprefix + ".trafficmanager.net" + // //Test Case 7: Validate Traffic Manager + // testTM_URL := "http://" + tm_dnsprefix + ".trafficmanager.net" - // It can take several minutes or so for the app to be deployed, so retry a few times - maxRetries := 60 - timeBetweenRetries := 5 * time.Second + // // It can take several minutes or so for the app to be deployed, so retry a few times + // maxRetries := 60 + // timeBetweenRetries := 5 * time.Second - //Verify that we get a 200 OK response and response text contains `Cats` otherwise clean up AKS load balancer and destroy resources - //Bedrock is using the azure-vote.yaml service that provisions a stateless simple voting app using redis on all clusters - _reqErr := http_helper.HttpGetWithRetryWithCustomValidationE(t, testTM_URL, nil, maxRetries, timeBetweenRetries, func(status int, body string) bool { - return status == 200 && strings.Contains(body, `"Cats"`) - }) + // //Verify that we get a 200 OK response and response text contains `Cats` otherwise clean up AKS load balancer and destroy resources + // //Bedrock is using the azure-vote.yaml service that provisions a stateless simple voting app using redis on all clusters + // _reqErr := http_helper.HttpGetWithRetryWithCustomValidationE(t, testTM_URL, nil, maxRetries, timeBetweenRetries, func(status int, body string) bool { + // return status == 200 && strings.Contains(body, `"Cats"`) + // }) - if _reqErr != nil { - fmt.Println("Error validating Traffic Manager - Removing cluster load balancer and Destroying resources") - _clean, cleanErr := k8s.RunKubectlAndGetOutputE(t, options, "delete", "service", "azure-vote-front") - if cleanErr != nil || !strings.Contains(_clean, "delete") { - t.Fatal(cleanErr) - } else { - fmt.Println("Clean verification for West Cluster complete") - } - _clean2, cleanErr2 := k8s.RunKubectlAndGetOutputE(t, options2, "delete", "service", "azure-vote-front") - if cleanErr2 != nil || !strings.Contains(_clean2, "delete") { - t.Fatal(cleanErr2) - } else { - fmt.Println("Clean verification for East Cluster complete") - } - _clean3, cleanErr3 := k8s.RunKubectlAndGetOutputE(t, options3, "delete", "service", "azure-vote-front") - if cleanErr3 != nil || !strings.Contains(_clean3, "delete") { - t.Fatal(cleanErr3) - } else { - fmt.Println("Clean verification for Central Cluster complete") - } - //Sleep job for 2 minutes while load balancer deallocates - time.Sleep(120 * time.Second) - t.Fatal(cleanErr) - } else { - fmt.Println("Traffic Manager Validation successful") - } + // if _reqErr != nil { + // fmt.Println("Error validating Traffic Manager - Removing cluster load balancer and Destroying resources") + // _clean, cleanErr := k8s.RunKubectlAndGetOutputE(t, options, "delete", "service", "azure-vote-front") + // if cleanErr != nil || !strings.Contains(_clean, "delete") { + // t.Fatal(cleanErr) + // } else { + // fmt.Println("Clean verification for West Cluster complete") + // } + // _clean2, cleanErr2 := k8s.RunKubectlAndGetOutputE(t, options2, "delete", "service", "azure-vote-front") + // if cleanErr2 != nil || !strings.Contains(_clean2, "delete") { + // t.Fatal(cleanErr2) + // } else { + // fmt.Println("Clean verification for East Cluster complete") + // } + // _clean3, cleanErr3 := k8s.RunKubectlAndGetOutputE(t, options3, "delete", "service", "azure-vote-front") + // if cleanErr3 != nil || !strings.Contains(_clean3, "delete") { + // t.Fatal(cleanErr3) + // } else { + // fmt.Println("Clean verification for Central Cluster complete") + // } + // //Sleep job for 2 minutes while load balancer deallocates + // time.Sleep(120 * time.Second) + // t.Fatal(cleanErr) + // } else { + // fmt.Println("Traffic Manager Validation successful") + // } //Clean up Cluster load balancers + time.Sleep(120 * time.Second) fmt.Println("Removing cluster load balancer and Destroying resources") _clean, cleanErr := k8s.RunKubectlAndGetOutputE(t, options, "delete", "service", "azure-vote-front") if cleanErr != nil || !strings.Contains(_clean, "delete") {