From 291d99522d45a1084b35e3be14e4dc14913d03bd Mon Sep 17 00:00:00 2001 From: Mofizur Rahman Date: Mon, 10 Aug 2020 16:49:41 -0400 Subject: [PATCH] multizone support fix tests --- internals/cron/cloudfoundry_test.go | 16 ++++++++-------- internals/cron/cron.go | 9 +++++---- templates/message.gotmpl | 6 +++--- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/internals/cron/cloudfoundry_test.go b/internals/cron/cloudfoundry_test.go index c983506..552a562 100644 --- a/internals/cron/cloudfoundry_test.go +++ b/internals/cron/cloudfoundry_test.go @@ -8,22 +8,22 @@ import ( ) func TestGetCommentString(t *testing.T) { - request := ibmcloud.ClusterRequest{ - DataCenter: "dal10", + request := ibmcloud.ScheduleRequest{ + DataCenters: []string{"dal10"}, MachineType: "4X16", MasterVersion: "iks16.7", WorkerNum: 1, } - createRequest := ibmcloud.CreateClusterRequest{ - ClusterRequest: request, + scheduleRequest := ibmcloud.ScheduleClusterRequest{ + ScheduleRequest: request, } schedule := ibmcloud.Schedule{ - Count: "5", - CreateRequest: createRequest, - EventName: "mofisapp", - Password: "ikslab", + Count: "5", + ScheduleRequest: scheduleRequest, + EventName: "mofisapp", + Password: "ikslab", } comment, err := getCommentString(schedule, "../../templates/message.gotmpl") diff --git a/internals/cron/cron.go b/internals/cron/cron.go index e801800..214df62 100644 --- a/internals/cron/cron.go +++ b/internals/cron/cron.go @@ -182,7 +182,8 @@ func checkCloudant() { // for each cluster loop through and create cluster, ignore error for now. for i := 1; i <= count; i++ { datacenters := schedule.ScheduleRequest.ScheduleRequest.DataCenters - vlans, err := session.GetDatacenterVlan() + datacenter := datacenters[i%len(datacenters)] + vlans, err := session.GetDatacenterVlan(datacenter) if err != nil { // could not get vlan // skip the scheduling @@ -248,13 +249,13 @@ func checkCloudant() { schedule.Clusters = append(schedule.Clusters, response.ID) for _, tag := range tags { - _, err := session.SetClusterTag(tag, response.ID, schedule.CreateRequest.ResourceGroup) + _, err := session.SetClusterTag(tag, response.ID, schedule.ScheduleRequest.ResourceGroup) if err != nil { - log.Println("error setting tag : investigate ", schedule.CreateRequest.ClusterRequest.Name, err) + log.Println("error setting tag : investigate ", schedule.ScheduleRequest.ScheduleRequest.Name, err) hasErrors = true schedError := ScheduleError{ Error: err, - Message: fmt.Sprintf("Error creting tag %s for cluster %s", tag, schedule.CreateRequest.ClusterRequest.Name), + Message: fmt.Sprintf("Error creting tag %s for cluster %s", tag, schedule.ScheduleRequest.ScheduleRequest.Name), } emailData.Errors = append(emailData.Errors, schedError) continue diff --git a/templates/message.gotmpl b/templates/message.gotmpl index e5975dd..726027f 100644 --- a/templates/message.gotmpl +++ b/templates/message.gotmpl @@ -2,10 +2,10 @@ Key: `{{ .Password }}` -Region: {{ .CreateRequest.ClusterRequest.DataCenter }} +Region: {{ .ScheduleRequest.ScheduleRequest.DataCenters }} Clusters: {{ .Count }} -Workers: {{ .CreateRequest.ClusterRequest.WorkerNum }} x {{ $.CreateRequest.ClusterRequest.MachineType }} -K8s Version: {{ .CreateRequest.ClusterRequest.MasterVersion }} +Workers: {{ .ScheduleRequest.ScheduleRequest.WorkerNum }} x {{ $.ScheduleRequest.ScheduleRequest.MachineType }} +K8s Version: {{ .ScheduleRequest.ScheduleRequest.MasterVersion }} ## Note - Please be sure to click: `Prefill Cache` button on the URL before your lab