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

Commit

Permalink
Windows e2e scale up / down test Fixes#3632 (#4264)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michelle Cone authored and jackfrancis committed Nov 21, 2018
1 parent 8122aeb commit ba9630f
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/e2e/kubernetes/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,17 @@ func (d *Deployment) Expose(svcType string, targetPort, exposedPort int) error {
return nil
}

// ScaleDeployment scales a deployment to n instancees
func (d *Deployment) ScaleDeployment(n int) error {
cmd := exec.Command("kubectl", "scale", fmt.Sprintf("--replicas=%d", n), "deployment", d.Metadata.Name)
out, err := util.RunAndLogCommand(cmd)
if err != nil {
log.Printf("Error while scaling deployment %s to %d pods:%s\n", d.Metadata.Name, n, string(out))
return err
}
return nil
}

// CreateDeploymentHPA applies autoscale characteristics to deployment
func (d *Deployment) CreateDeploymentHPA(cpuPercent, min, max int) error {
cmd := exec.Command("kubectl", "autoscale", "deployment", d.Metadata.Name, fmt.Sprintf("--cpu-percent=%d", cpuPercent),
Expand Down
103 changes: 103 additions & 0 deletions test/e2e/kubernetes/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,109 @@ var _ = Describe("Azure Container Cluster using the Kubernetes Orchestrator", fu
}
})

It("should be able to scale an iis webserver", func() {
if eng.HasWindowsAgents() {
iisImage := "microsoft/iis:windowsservercore-1803" // BUG: This should be set based on the host OS version

By("Creating a deployment with 1 pod running IIS")
r := rand.New(rand.NewSource(time.Now().UnixNano()))
deploymentName := fmt.Sprintf("iis-%s-%v", cfg.Name, r.Intn(99999))
iisDeploy, err := deployment.CreateWindowsDeploy(iisImage, deploymentName, "default", 80, -1)
Expect(err).NotTo(HaveOccurred())

By("Waiting on pod to be Ready")
running, err := pod.WaitOnReady(deploymentName, "default", 3, 30*time.Second, cfg.Timeout)
Expect(err).NotTo(HaveOccurred())
Expect(running).To(Equal(true))

By("Exposing a LoadBalancer for the pod")
err = iisDeploy.Expose("LoadBalancer", 80, 80)
Expect(err).NotTo(HaveOccurred())
iisService, err := service.Get(deploymentName, "default")
Expect(err).NotTo(HaveOccurred())

By("Verifying that the service is reachable and returns the default IIS start page")
valid := iisService.Validate("(IIS Windows Server)", 10, 10*time.Second, cfg.Timeout)
Expect(valid).To(BeTrue())

By("Checking that each pod can reach http://www.bing.com")
iisPods, err := iisDeploy.Pods()
Expect(err).NotTo(HaveOccurred())
Expect(len(iisPods)).ToNot(BeZero())
for _, iisPod := range iisPods {
pass, err := iisPod.CheckWindowsOutboundConnection("www.bing.com", 10*time.Second, cfg.Timeout)
Expect(err).NotTo(HaveOccurred())
Expect(pass).To(BeTrue())
}

By("Scaling deployment to 5 pods")
err = iisDeploy.ScaleDeployment(5)
Expect(err).NotTo(HaveOccurred())
_, err = iisDeploy.WaitForReplicas(5, 5, 2*time.Second, cfg.Timeout)
Expect(err).NotTo(HaveOccurred())

By("Waiting on 5 pods to be Ready")
running, err = pod.WaitOnReady(deploymentName, "default", 3, 30*time.Second, cfg.Timeout)
Expect(err).NotTo(HaveOccurred())
Expect(running).To(Equal(true))
iisPods, err = iisDeploy.Pods()
Expect(err).NotTo(HaveOccurred())
Expect(len(iisPods)).To(Equal(5))

By("Verifying that the service is reachable and returns the default IIS start page")
valid = iisService.Validate("(IIS Windows Server)", 10, 10*time.Second, cfg.Timeout)
Expect(valid).To(BeTrue())

By("Checking that each pod can reach http://www.bing.com")
iisPods, err = iisDeploy.Pods()
Expect(err).NotTo(HaveOccurred())
Expect(len(iisPods)).ToNot(BeZero())
for _, iisPod := range iisPods {
pass, err := iisPod.CheckWindowsOutboundConnection("www.bing.com", 10*time.Second, cfg.Timeout)
Expect(err).NotTo(HaveOccurred())
Expect(pass).To(BeTrue())
}

By("Checking that no pods restart")
for _, iisPod := range iisPods {
log.Printf("Checking %s", iisPod.Metadata.Name)
Expect(iisPod.Status.ContainerStatuses[0].Ready).To(BeTrue())
Expect(iisPod.Status.ContainerStatuses[0].RestartCount).To(Equal(0))
}

By("Scaling deployment to 2 pods")
err = iisDeploy.ScaleDeployment(2)
Expect(err).NotTo(HaveOccurred())
_, err = iisDeploy.WaitForReplicas(2, 2, 2*time.Second, cfg.Timeout)
Expect(err).NotTo(HaveOccurred())
iisPods, err = iisDeploy.Pods()
Expect(err).NotTo(HaveOccurred())
Expect(len(iisPods)).To(Equal(2))

By("Verifying that the service is reachable and returns the default IIS start page")
valid = iisService.Validate("(IIS Windows Server)", 10, 10*time.Second, cfg.Timeout)
Expect(valid).To(BeTrue())

By("Checking that each pod can reach http://www.bing.com")
iisPods, err = iisDeploy.Pods()
Expect(err).NotTo(HaveOccurred())
Expect(len(iisPods)).ToNot(BeZero())
for _, iisPod := range iisPods {
pass, err := iisPod.CheckWindowsOutboundConnection("www.bing.com", 10*time.Second, cfg.Timeout)
Expect(err).NotTo(HaveOccurred())
Expect(pass).To(BeTrue())
}

By("Verifying pods & services can be deleted")
err = iisDeploy.Delete(deleteResourceRetries)
Expect(err).NotTo(HaveOccurred())
err = iisService.Delete(deleteResourceRetries)
Expect(err).NotTo(HaveOccurred())
} else {
Skip("No windows agent was provisioned for this Cluster Definition")
}
})

It("should be able to resolve DNS across windows and linux deployments", func() {
if eng.HasWindowsAgents() {
iisImage := "microsoft/iis:windowsservercore-1803" // BUG: This should be set based on the host OS version
Expand Down

0 comments on commit ba9630f

Please sign in to comment.