[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
This commit is contained in:
Nate 2020-03-04 19:46:58 -05:00 коммит произвёл GitHub
Родитель 0d3a235b7f
Коммит 6a9a7636a0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 105 добавлений и 105 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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") {