Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit ba9630f

Browse files
Michelle Conejackfrancis
authored andcommitted
Windows e2e scale up / down test Fixes#3632 (#4264)
1 parent 8122aeb commit ba9630f

File tree

2 files changed

+114
-0
lines changed

2 files changed

+114
-0
lines changed

test/e2e/kubernetes/deployment/deployment.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,17 @@ func (d *Deployment) Expose(svcType string, targetPort, exposedPort int) error {
187187
return nil
188188
}
189189

190+
// ScaleDeployment scales a deployment to n instancees
191+
func (d *Deployment) ScaleDeployment(n int) error {
192+
cmd := exec.Command("kubectl", "scale", fmt.Sprintf("--replicas=%d", n), "deployment", d.Metadata.Name)
193+
out, err := util.RunAndLogCommand(cmd)
194+
if err != nil {
195+
log.Printf("Error while scaling deployment %s to %d pods:%s\n", d.Metadata.Name, n, string(out))
196+
return err
197+
}
198+
return nil
199+
}
200+
190201
// CreateDeploymentHPA applies autoscale characteristics to deployment
191202
func (d *Deployment) CreateDeploymentHPA(cpuPercent, min, max int) error {
192203
cmd := exec.Command("kubectl", "autoscale", "deployment", d.Metadata.Name, fmt.Sprintf("--cpu-percent=%d", cpuPercent),

test/e2e/kubernetes/kubernetes_test.go

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,109 @@ var _ = Describe("Azure Container Cluster using the Kubernetes Orchestrator", fu
10141014
}
10151015
})
10161016

1017+
It("should be able to scale an iis webserver", func() {
1018+
if eng.HasWindowsAgents() {
1019+
iisImage := "microsoft/iis:windowsservercore-1803" // BUG: This should be set based on the host OS version
1020+
1021+
By("Creating a deployment with 1 pod running IIS")
1022+
r := rand.New(rand.NewSource(time.Now().UnixNano()))
1023+
deploymentName := fmt.Sprintf("iis-%s-%v", cfg.Name, r.Intn(99999))
1024+
iisDeploy, err := deployment.CreateWindowsDeploy(iisImage, deploymentName, "default", 80, -1)
1025+
Expect(err).NotTo(HaveOccurred())
1026+
1027+
By("Waiting on pod to be Ready")
1028+
running, err := pod.WaitOnReady(deploymentName, "default", 3, 30*time.Second, cfg.Timeout)
1029+
Expect(err).NotTo(HaveOccurred())
1030+
Expect(running).To(Equal(true))
1031+
1032+
By("Exposing a LoadBalancer for the pod")
1033+
err = iisDeploy.Expose("LoadBalancer", 80, 80)
1034+
Expect(err).NotTo(HaveOccurred())
1035+
iisService, err := service.Get(deploymentName, "default")
1036+
Expect(err).NotTo(HaveOccurred())
1037+
1038+
By("Verifying that the service is reachable and returns the default IIS start page")
1039+
valid := iisService.Validate("(IIS Windows Server)", 10, 10*time.Second, cfg.Timeout)
1040+
Expect(valid).To(BeTrue())
1041+
1042+
By("Checking that each pod can reach http://www.bing.com")
1043+
iisPods, err := iisDeploy.Pods()
1044+
Expect(err).NotTo(HaveOccurred())
1045+
Expect(len(iisPods)).ToNot(BeZero())
1046+
for _, iisPod := range iisPods {
1047+
pass, err := iisPod.CheckWindowsOutboundConnection("www.bing.com", 10*time.Second, cfg.Timeout)
1048+
Expect(err).NotTo(HaveOccurred())
1049+
Expect(pass).To(BeTrue())
1050+
}
1051+
1052+
By("Scaling deployment to 5 pods")
1053+
err = iisDeploy.ScaleDeployment(5)
1054+
Expect(err).NotTo(HaveOccurred())
1055+
_, err = iisDeploy.WaitForReplicas(5, 5, 2*time.Second, cfg.Timeout)
1056+
Expect(err).NotTo(HaveOccurred())
1057+
1058+
By("Waiting on 5 pods to be Ready")
1059+
running, err = pod.WaitOnReady(deploymentName, "default", 3, 30*time.Second, cfg.Timeout)
1060+
Expect(err).NotTo(HaveOccurred())
1061+
Expect(running).To(Equal(true))
1062+
iisPods, err = iisDeploy.Pods()
1063+
Expect(err).NotTo(HaveOccurred())
1064+
Expect(len(iisPods)).To(Equal(5))
1065+
1066+
By("Verifying that the service is reachable and returns the default IIS start page")
1067+
valid = iisService.Validate("(IIS Windows Server)", 10, 10*time.Second, cfg.Timeout)
1068+
Expect(valid).To(BeTrue())
1069+
1070+
By("Checking that each pod can reach http://www.bing.com")
1071+
iisPods, err = iisDeploy.Pods()
1072+
Expect(err).NotTo(HaveOccurred())
1073+
Expect(len(iisPods)).ToNot(BeZero())
1074+
for _, iisPod := range iisPods {
1075+
pass, err := iisPod.CheckWindowsOutboundConnection("www.bing.com", 10*time.Second, cfg.Timeout)
1076+
Expect(err).NotTo(HaveOccurred())
1077+
Expect(pass).To(BeTrue())
1078+
}
1079+
1080+
By("Checking that no pods restart")
1081+
for _, iisPod := range iisPods {
1082+
log.Printf("Checking %s", iisPod.Metadata.Name)
1083+
Expect(iisPod.Status.ContainerStatuses[0].Ready).To(BeTrue())
1084+
Expect(iisPod.Status.ContainerStatuses[0].RestartCount).To(Equal(0))
1085+
}
1086+
1087+
By("Scaling deployment to 2 pods")
1088+
err = iisDeploy.ScaleDeployment(2)
1089+
Expect(err).NotTo(HaveOccurred())
1090+
_, err = iisDeploy.WaitForReplicas(2, 2, 2*time.Second, cfg.Timeout)
1091+
Expect(err).NotTo(HaveOccurred())
1092+
iisPods, err = iisDeploy.Pods()
1093+
Expect(err).NotTo(HaveOccurred())
1094+
Expect(len(iisPods)).To(Equal(2))
1095+
1096+
By("Verifying that the service is reachable and returns the default IIS start page")
1097+
valid = iisService.Validate("(IIS Windows Server)", 10, 10*time.Second, cfg.Timeout)
1098+
Expect(valid).To(BeTrue())
1099+
1100+
By("Checking that each pod can reach http://www.bing.com")
1101+
iisPods, err = iisDeploy.Pods()
1102+
Expect(err).NotTo(HaveOccurred())
1103+
Expect(len(iisPods)).ToNot(BeZero())
1104+
for _, iisPod := range iisPods {
1105+
pass, err := iisPod.CheckWindowsOutboundConnection("www.bing.com", 10*time.Second, cfg.Timeout)
1106+
Expect(err).NotTo(HaveOccurred())
1107+
Expect(pass).To(BeTrue())
1108+
}
1109+
1110+
By("Verifying pods & services can be deleted")
1111+
err = iisDeploy.Delete(deleteResourceRetries)
1112+
Expect(err).NotTo(HaveOccurred())
1113+
err = iisService.Delete(deleteResourceRetries)
1114+
Expect(err).NotTo(HaveOccurred())
1115+
} else {
1116+
Skip("No windows agent was provisioned for this Cluster Definition")
1117+
}
1118+
})
1119+
10171120
It("should be able to resolve DNS across windows and linux deployments", func() {
10181121
if eng.HasWindowsAgents() {
10191122
iisImage := "microsoft/iis:windowsservercore-1803" // BUG: This should be set based on the host OS version

0 commit comments

Comments
 (0)