2015-04-23 14:28:16 +00:00
|
|
|
/*
|
2016-06-03 00:25:58 +00:00
|
|
|
Copyright 2015 The Kubernetes Authors.
|
2015-04-23 14:28:16 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package e2e
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os/exec"
|
2015-07-22 11:40:22 +00:00
|
|
|
"regexp"
|
2015-07-24 02:00:27 +00:00
|
|
|
"strings"
|
2015-04-23 14:28:16 +00:00
|
|
|
"time"
|
|
|
|
|
2015-08-05 22:03:47 +00:00
|
|
|
"k8s.io/kubernetes/pkg/api"
|
2016-11-18 20:55:17 +00:00
|
|
|
"k8s.io/kubernetes/pkg/api/v1"
|
2016-01-13 22:40:56 +00:00
|
|
|
"k8s.io/kubernetes/pkg/apimachinery/registered"
|
2016-12-03 19:06:03 +00:00
|
|
|
metav1 "k8s.io/kubernetes/pkg/apis/meta/v1"
|
2016-12-14 01:18:17 +00:00
|
|
|
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
|
2015-11-10 06:28:45 +00:00
|
|
|
"k8s.io/kubernetes/pkg/util/intstr"
|
2016-04-07 17:21:31 +00:00
|
|
|
"k8s.io/kubernetes/test/e2e/framework"
|
2015-08-05 22:03:47 +00:00
|
|
|
|
2016-03-12 10:57:59 +00:00
|
|
|
"github.com/aws/aws-sdk-go/aws/session"
|
|
|
|
"github.com/aws/aws-sdk-go/service/autoscaling"
|
2015-04-23 14:28:16 +00:00
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
2015-10-19 21:08:35 +00:00
|
|
|
awscloud "k8s.io/kubernetes/pkg/cloudprovider/providers/aws"
|
2015-04-23 14:28:16 +00:00
|
|
|
)
|
|
|
|
|
2015-07-24 02:00:27 +00:00
|
|
|
const (
|
2016-03-21 19:53:22 +00:00
|
|
|
serveHostnameImage = "gcr.io/google_containers/serve_hostname:v1.4"
|
2015-07-24 02:00:27 +00:00
|
|
|
resizeNodeReadyTimeout = 2 * time.Minute
|
|
|
|
resizeNodeNotReadyTimeout = 2 * time.Minute
|
2016-01-09 00:25:59 +00:00
|
|
|
nodeReadinessTimeout = 3 * time.Minute
|
|
|
|
podNotReadyTimeout = 1 * time.Minute
|
|
|
|
podReadyTimeout = 2 * time.Minute
|
2015-10-26 01:01:02 +00:00
|
|
|
testPort = 9376
|
2015-07-24 02:00:27 +00:00
|
|
|
)
|
2015-07-27 02:24:26 +00:00
|
|
|
|
2016-05-23 12:10:40 +00:00
|
|
|
func ResizeGroup(group string, size int32) error {
|
2016-04-07 17:21:31 +00:00
|
|
|
if framework.TestContext.ReportDir != "" {
|
|
|
|
framework.CoreDump(framework.TestContext.ReportDir)
|
|
|
|
defer framework.CoreDump(framework.TestContext.ReportDir)
|
2016-01-25 17:52:57 +00:00
|
|
|
}
|
2016-04-07 17:21:31 +00:00
|
|
|
if framework.TestContext.Provider == "gce" || framework.TestContext.Provider == "gke" {
|
2015-07-06 12:32:56 +00:00
|
|
|
// TODO: make this hit the compute API directly instead of shelling out to gcloud.
|
2015-06-13 14:24:35 +00:00
|
|
|
// TODO: make gce/gke implement InstanceGroups, so we can eliminate the per-provider logic
|
2015-07-22 11:40:22 +00:00
|
|
|
output, err := exec.Command("gcloud", "compute", "instance-groups", "managed", "resize",
|
2016-05-23 12:10:40 +00:00
|
|
|
group, fmt.Sprintf("--size=%v", size),
|
2016-04-07 17:21:31 +00:00
|
|
|
"--project="+framework.TestContext.CloudConfig.ProjectID, "--zone="+framework.TestContext.CloudConfig.Zone).CombinedOutput()
|
2015-06-13 14:24:35 +00:00
|
|
|
if err != nil {
|
2016-04-07 17:21:31 +00:00
|
|
|
framework.Logf("Failed to resize node instance group: %v", string(output))
|
2015-06-13 14:24:35 +00:00
|
|
|
}
|
|
|
|
return err
|
2016-04-07 17:21:31 +00:00
|
|
|
} else if framework.TestContext.Provider == "aws" {
|
2016-03-12 10:57:59 +00:00
|
|
|
client := autoscaling.New(session.New())
|
2016-05-23 12:10:40 +00:00
|
|
|
return awscloud.ResizeInstanceGroup(client, group, int(size))
|
2015-06-13 14:24:35 +00:00
|
|
|
} else {
|
2016-03-12 10:57:59 +00:00
|
|
|
return fmt.Errorf("Provider does not support InstanceGroups")
|
2015-04-23 14:28:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-23 12:10:40 +00:00
|
|
|
func GetGroupNodes(group string) ([]string, error) {
|
|
|
|
if framework.TestContext.Provider == "gce" || framework.TestContext.Provider == "gke" {
|
|
|
|
// TODO: make this hit the compute API directly instead of shelling out to gcloud.
|
|
|
|
// TODO: make gce/gke implement InstanceGroups, so we can eliminate the per-provider logic
|
|
|
|
output, err := exec.Command("gcloud", "compute", "instance-groups", "managed",
|
|
|
|
"list-instances", group, "--project="+framework.TestContext.CloudConfig.ProjectID,
|
|
|
|
"--zone="+framework.TestContext.CloudConfig.Zone).CombinedOutput()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
re := regexp.MustCompile(".*RUNNING")
|
2016-06-09 12:34:50 +00:00
|
|
|
lines := re.FindAllString(string(output), -1)
|
2016-05-23 12:10:40 +00:00
|
|
|
for i, line := range lines {
|
|
|
|
lines[i] = line[:strings.Index(line, " ")]
|
|
|
|
}
|
|
|
|
return lines, nil
|
|
|
|
} else {
|
|
|
|
return nil, fmt.Errorf("provider does not support InstanceGroups")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-23 12:10:40 +00:00
|
|
|
func GroupSize(group string) (int, error) {
|
2016-04-07 17:21:31 +00:00
|
|
|
if framework.TestContext.Provider == "gce" || framework.TestContext.Provider == "gke" {
|
2015-07-06 12:32:56 +00:00
|
|
|
// TODO: make this hit the compute API directly instead of shelling out to gcloud.
|
2015-06-13 14:24:35 +00:00
|
|
|
// TODO: make gce/gke implement InstanceGroups, so we can eliminate the per-provider logic
|
2015-07-22 11:40:22 +00:00
|
|
|
output, err := exec.Command("gcloud", "compute", "instance-groups", "managed",
|
2016-05-23 12:10:40 +00:00
|
|
|
"list-instances", group, "--project="+framework.TestContext.CloudConfig.ProjectID,
|
2016-04-07 17:21:31 +00:00
|
|
|
"--zone="+framework.TestContext.CloudConfig.Zone).CombinedOutput()
|
2015-06-13 14:24:35 +00:00
|
|
|
if err != nil {
|
|
|
|
return -1, err
|
|
|
|
}
|
2015-07-22 11:40:22 +00:00
|
|
|
re := regexp.MustCompile("RUNNING")
|
|
|
|
return len(re.FindAllString(string(output), -1)), nil
|
2016-04-07 17:21:31 +00:00
|
|
|
} else if framework.TestContext.Provider == "aws" {
|
2016-03-12 10:57:59 +00:00
|
|
|
client := autoscaling.New(session.New())
|
2016-05-23 12:10:40 +00:00
|
|
|
instanceGroup, err := awscloud.DescribeInstanceGroup(client, group)
|
2015-06-13 14:24:35 +00:00
|
|
|
if err != nil {
|
|
|
|
return -1, fmt.Errorf("error describing instance group: %v", err)
|
|
|
|
}
|
|
|
|
if instanceGroup == nil {
|
2016-05-23 12:10:40 +00:00
|
|
|
return -1, fmt.Errorf("instance group not found: %s", group)
|
2015-06-13 14:24:35 +00:00
|
|
|
}
|
|
|
|
return instanceGroup.CurrentSize()
|
2016-03-12 10:57:59 +00:00
|
|
|
} else {
|
|
|
|
return -1, fmt.Errorf("provider does not support InstanceGroups")
|
2015-04-23 14:28:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-23 12:10:40 +00:00
|
|
|
func WaitForGroupSize(group string, size int32) error {
|
2015-08-03 07:51:17 +00:00
|
|
|
timeout := 10 * time.Minute
|
2015-07-27 02:24:26 +00:00
|
|
|
for start := time.Now(); time.Since(start) < timeout; time.Sleep(5 * time.Second) {
|
2016-05-23 12:10:40 +00:00
|
|
|
currentSize, err := GroupSize(group)
|
2015-04-23 14:28:16 +00:00
|
|
|
if err != nil {
|
2016-04-07 17:21:31 +00:00
|
|
|
framework.Logf("Failed to get node instance group size: %v", err)
|
2015-04-23 14:28:16 +00:00
|
|
|
continue
|
|
|
|
}
|
2016-04-27 04:35:14 +00:00
|
|
|
if currentSize != int(size) {
|
2016-04-07 17:21:31 +00:00
|
|
|
framework.Logf("Waiting for node instance group size %d, current size %d", size, currentSize)
|
2015-04-23 14:28:16 +00:00
|
|
|
continue
|
|
|
|
}
|
2016-04-07 17:21:31 +00:00
|
|
|
framework.Logf("Node instance group has reached the desired size %d", size)
|
2015-04-23 14:28:16 +00:00
|
|
|
return nil
|
|
|
|
}
|
2015-07-27 02:24:26 +00:00
|
|
|
return fmt.Errorf("timeout waiting %v for node instance group size to be %d", timeout, size)
|
2015-04-23 14:28:16 +00:00
|
|
|
}
|
|
|
|
|
2016-11-18 20:55:17 +00:00
|
|
|
func svcByName(name string, port int) *v1.Service {
|
|
|
|
return &v1.Service{
|
|
|
|
ObjectMeta: v1.ObjectMeta{
|
2015-10-26 01:01:02 +00:00
|
|
|
Name: name,
|
2015-04-23 14:28:16 +00:00
|
|
|
},
|
2016-11-18 20:55:17 +00:00
|
|
|
Spec: v1.ServiceSpec{
|
|
|
|
Type: v1.ServiceTypeNodePort,
|
2015-04-23 14:28:16 +00:00
|
|
|
Selector: map[string]string{
|
|
|
|
"name": name,
|
|
|
|
},
|
2016-11-18 20:55:17 +00:00
|
|
|
Ports: []v1.ServicePort{{
|
2016-04-27 04:35:14 +00:00
|
|
|
Port: int32(port),
|
2015-11-10 06:28:45 +00:00
|
|
|
TargetPort: intstr.FromInt(port),
|
2015-04-23 14:28:16 +00:00
|
|
|
}},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-18 13:00:38 +00:00
|
|
|
func newSVCByName(c clientset.Interface, ns, name string) error {
|
|
|
|
_, err := c.Core().Services(ns).Create(svcByName(name, testPort))
|
2015-04-23 14:28:16 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2016-11-18 20:55:17 +00:00
|
|
|
func rcByNamePort(name string, replicas int32, image string, port int, protocol v1.Protocol,
|
|
|
|
labels map[string]string, gracePeriod *int64) *v1.ReplicationController {
|
2015-06-17 07:13:26 +00:00
|
|
|
|
2016-11-18 20:55:17 +00:00
|
|
|
return rcByNameContainer(name, replicas, image, labels, v1.Container{
|
2015-06-17 07:13:26 +00:00
|
|
|
Name: name,
|
|
|
|
Image: image,
|
2016-11-18 20:55:17 +00:00
|
|
|
Ports: []v1.ContainerPort{{ContainerPort: int32(port), Protocol: protocol}},
|
2016-11-01 00:26:04 +00:00
|
|
|
}, gracePeriod)
|
2015-06-17 07:13:26 +00:00
|
|
|
}
|
|
|
|
|
2016-11-18 20:55:17 +00:00
|
|
|
func rcByNameContainer(name string, replicas int32, image string, labels map[string]string, c v1.Container,
|
|
|
|
gracePeriod *int64) *v1.ReplicationController {
|
2016-11-01 00:26:04 +00:00
|
|
|
|
|
|
|
zeroGracePeriod := int64(0)
|
|
|
|
|
2015-06-17 07:13:26 +00:00
|
|
|
// Add "name": name to the labels, overwriting if it exists.
|
|
|
|
labels["name"] = name
|
2016-11-01 00:26:04 +00:00
|
|
|
if gracePeriod == nil {
|
|
|
|
gracePeriod = &zeroGracePeriod
|
|
|
|
}
|
2016-11-18 20:55:17 +00:00
|
|
|
return &v1.ReplicationController{
|
2016-12-03 18:57:26 +00:00
|
|
|
TypeMeta: metav1.TypeMeta{
|
2015-06-17 07:13:26 +00:00
|
|
|
Kind: "ReplicationController",
|
2016-11-18 20:55:17 +00:00
|
|
|
APIVersion: registered.GroupOrDie(v1.GroupName).GroupVersion.String(),
|
2015-06-17 07:13:26 +00:00
|
|
|
},
|
2016-11-18 20:55:17 +00:00
|
|
|
ObjectMeta: v1.ObjectMeta{
|
2015-04-23 14:28:16 +00:00
|
|
|
Name: name,
|
|
|
|
},
|
2016-11-18 20:55:17 +00:00
|
|
|
Spec: v1.ReplicationControllerSpec{
|
|
|
|
Replicas: func(i int32) *int32 { return &i }(replicas),
|
2015-04-23 14:28:16 +00:00
|
|
|
Selector: map[string]string{
|
|
|
|
"name": name,
|
|
|
|
},
|
2016-11-18 20:55:17 +00:00
|
|
|
Template: &v1.PodTemplateSpec{
|
|
|
|
ObjectMeta: v1.ObjectMeta{
|
2015-06-17 07:13:26 +00:00
|
|
|
Labels: labels,
|
2015-04-23 14:28:16 +00:00
|
|
|
},
|
2016-11-18 20:55:17 +00:00
|
|
|
Spec: v1.PodSpec{
|
|
|
|
Containers: []v1.Container{c},
|
2016-11-01 00:26:04 +00:00
|
|
|
TerminationGracePeriodSeconds: gracePeriod,
|
2015-04-23 14:28:16 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-17 07:13:26 +00:00
|
|
|
// newRCByName creates a replication controller with a selector by name of name.
|
2016-11-18 20:55:17 +00:00
|
|
|
func newRCByName(c clientset.Interface, ns, name string, replicas int32, gracePeriod *int64) (*v1.ReplicationController, error) {
|
2015-04-23 14:28:16 +00:00
|
|
|
By(fmt.Sprintf("creating replication controller %s", name))
|
2016-10-18 13:00:38 +00:00
|
|
|
return c.Core().ReplicationControllers(ns).Create(rcByNamePort(
|
2016-11-18 20:55:17 +00:00
|
|
|
name, replicas, serveHostnameImage, 9376, v1.ProtocolTCP, map[string]string{}, gracePeriod))
|
2015-04-23 14:28:16 +00:00
|
|
|
}
|
|
|
|
|
2016-10-18 13:00:38 +00:00
|
|
|
func resizeRC(c clientset.Interface, ns, name string, replicas int32) error {
|
2016-12-07 14:40:26 +00:00
|
|
|
rc, err := c.Core().ReplicationControllers(ns).Get(name, metav1.GetOptions{})
|
2015-04-23 14:28:16 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2016-11-18 20:55:17 +00:00
|
|
|
*(rc.Spec.Replicas) = replicas
|
2016-10-18 13:00:38 +00:00
|
|
|
_, err = c.Core().ReplicationControllers(rc.Namespace).Update(rc)
|
2015-04-23 14:28:16 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2016-04-07 17:21:31 +00:00
|
|
|
var _ = framework.KubeDescribe("Nodes [Disruptive]", func() {
|
|
|
|
f := framework.NewDefaultFramework("resize-nodes")
|
2016-04-27 04:35:14 +00:00
|
|
|
var systemPodsNo int32
|
2016-10-18 13:00:38 +00:00
|
|
|
var c clientset.Interface
|
2015-04-23 14:28:16 +00:00
|
|
|
var ns string
|
2016-05-26 18:24:49 +00:00
|
|
|
ignoreLabels := framework.ImagePullerLabels
|
2016-05-23 12:10:40 +00:00
|
|
|
var group string
|
|
|
|
|
2015-04-23 14:28:16 +00:00
|
|
|
BeforeEach(func() {
|
2016-10-18 13:00:38 +00:00
|
|
|
c = f.ClientSet
|
2016-04-07 17:21:31 +00:00
|
|
|
ns = f.Namespace.Name
|
2016-05-26 18:24:49 +00:00
|
|
|
systemPods, err := framework.GetPodsInNamespace(c, ns, ignoreLabels)
|
2015-11-23 20:46:23 +00:00
|
|
|
Expect(err).NotTo(HaveOccurred())
|
2016-05-26 18:24:49 +00:00
|
|
|
systemPodsNo = int32(len(systemPods))
|
2016-05-23 12:10:40 +00:00
|
|
|
if strings.Index(framework.TestContext.CloudConfig.NodeInstanceGroup, ",") >= 0 {
|
|
|
|
framework.Failf("Test dose not support cluster setup with more than one MIG: %s", framework.TestContext.CloudConfig.NodeInstanceGroup)
|
|
|
|
} else {
|
|
|
|
group = framework.TestContext.CloudConfig.NodeInstanceGroup
|
|
|
|
}
|
2015-04-23 14:28:16 +00:00
|
|
|
})
|
|
|
|
|
2015-12-20 19:00:00 +00:00
|
|
|
// Slow issue #13323 (8 min)
|
2016-04-07 17:21:31 +00:00
|
|
|
framework.KubeDescribe("Resize [Slow]", func() {
|
2015-06-22 21:14:54 +00:00
|
|
|
var skipped bool
|
|
|
|
|
2015-06-08 08:52:37 +00:00
|
|
|
BeforeEach(func() {
|
2015-06-22 21:14:54 +00:00
|
|
|
skipped = true
|
2016-04-07 17:21:31 +00:00
|
|
|
framework.SkipUnlessProviderIs("gce", "gke", "aws")
|
|
|
|
framework.SkipUnlessNodeCountIsAtLeast(2)
|
2015-06-22 21:14:54 +00:00
|
|
|
skipped = false
|
2015-06-08 08:52:37 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
AfterEach(func() {
|
2015-06-22 21:14:54 +00:00
|
|
|
if skipped {
|
2015-06-08 08:52:37 +00:00
|
|
|
return
|
|
|
|
}
|
2015-06-22 21:14:54 +00:00
|
|
|
|
2015-06-08 08:52:37 +00:00
|
|
|
By("restoring the original node instance group size")
|
2016-05-23 12:10:40 +00:00
|
|
|
if err := ResizeGroup(group, int32(framework.TestContext.CloudConfig.NumNodes)); err != nil {
|
2016-04-07 17:21:31 +00:00
|
|
|
framework.Failf("Couldn't restore the original node instance group size: %v", err)
|
2015-06-08 08:52:37 +00:00
|
|
|
}
|
2016-01-11 23:30:23 +00:00
|
|
|
// In GKE, our current tunneling setup has the potential to hold on to a broken tunnel (from a
|
|
|
|
// rebooted/deleted node) for up to 5 minutes before all tunnels are dropped and recreated.
|
|
|
|
// Most tests make use of some proxy feature to verify functionality. So, if a reboot test runs
|
|
|
|
// right before a test that tries to get logs, for example, we may get unlucky and try to use a
|
2016-04-07 17:21:31 +00:00
|
|
|
// closed tunnel to a node that was recently rebooted. There's no good way to framework.Poll for proxies
|
2016-01-11 23:30:23 +00:00
|
|
|
// being closed, so we sleep.
|
|
|
|
//
|
|
|
|
// TODO(cjcullen) reduce this sleep (#19314)
|
2016-04-07 17:21:31 +00:00
|
|
|
if framework.ProviderIs("gke") {
|
2016-01-11 23:30:23 +00:00
|
|
|
By("waiting 5 minutes for all dead tunnels to be dropped")
|
|
|
|
time.Sleep(5 * time.Minute)
|
|
|
|
}
|
2016-05-23 12:10:40 +00:00
|
|
|
if err := WaitForGroupSize(group, int32(framework.TestContext.CloudConfig.NumNodes)); err != nil {
|
2016-04-07 17:21:31 +00:00
|
|
|
framework.Failf("Couldn't restore the original node instance group size: %v", err)
|
2015-06-08 08:52:37 +00:00
|
|
|
}
|
2016-04-07 17:21:31 +00:00
|
|
|
if err := framework.WaitForClusterSize(c, framework.TestContext.CloudConfig.NumNodes, 10*time.Minute); err != nil {
|
|
|
|
framework.Failf("Couldn't restore the original cluster size: %v", err)
|
2015-06-08 08:52:37 +00:00
|
|
|
}
|
2015-11-10 04:50:40 +00:00
|
|
|
// Many e2e tests assume that the cluster is fully healthy before they start. Wait until
|
|
|
|
// the cluster is restored to health.
|
|
|
|
By("waiting for system pods to successfully restart")
|
2016-11-23 02:39:25 +00:00
|
|
|
err := framework.WaitForPodsRunningReady(c, api.NamespaceSystem, systemPodsNo, framework.PodReadyBeforeTimeout, ignoreLabels, true)
|
2015-11-10 04:50:40 +00:00
|
|
|
Expect(err).NotTo(HaveOccurred())
|
2016-06-03 18:03:35 +00:00
|
|
|
By("waiting for image prepulling pods to complete")
|
|
|
|
framework.WaitForPodsSuccess(c, api.NamespaceSystem, framework.ImagePullerLabels, imagePrePullingTimeout)
|
2015-06-08 08:52:37 +00:00
|
|
|
})
|
|
|
|
|
2015-06-22 21:14:54 +00:00
|
|
|
It("should be able to delete nodes", func() {
|
2015-06-08 08:52:37 +00:00
|
|
|
// Create a replication controller for a service that serves its hostname.
|
2015-07-06 12:32:56 +00:00
|
|
|
// The source for the Docker container kubernetes/serve_hostname is in contrib/for-demos/serve_hostname
|
2015-06-08 08:52:37 +00:00
|
|
|
name := "my-hostname-delete-node"
|
2016-04-27 04:35:14 +00:00
|
|
|
replicas := int32(framework.TestContext.CloudConfig.NumNodes)
|
2016-11-01 00:26:04 +00:00
|
|
|
newRCByName(c, ns, name, replicas, nil)
|
2016-04-07 17:21:31 +00:00
|
|
|
err := framework.VerifyPods(c, ns, name, true, replicas)
|
2015-06-08 08:52:37 +00:00
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
|
|
|
|
By(fmt.Sprintf("decreasing cluster size to %d", replicas-1))
|
2016-05-23 12:10:40 +00:00
|
|
|
err = ResizeGroup(group, replicas-1)
|
2015-06-08 08:52:37 +00:00
|
|
|
Expect(err).NotTo(HaveOccurred())
|
2016-05-23 12:10:40 +00:00
|
|
|
err = WaitForGroupSize(group, replicas-1)
|
2015-06-08 08:52:37 +00:00
|
|
|
Expect(err).NotTo(HaveOccurred())
|
2016-04-27 04:35:14 +00:00
|
|
|
err = framework.WaitForClusterSize(c, int(replicas-1), 10*time.Minute)
|
2015-06-08 08:52:37 +00:00
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
|
2016-11-03 23:45:16 +00:00
|
|
|
By("waiting 1 minute for the watch in the podGC to catch up, remove any pods scheduled on " +
|
|
|
|
"the now non-existent node and the RC to recreate it")
|
|
|
|
time.Sleep(time.Minute)
|
2016-11-01 00:26:04 +00:00
|
|
|
|
2015-06-08 08:52:37 +00:00
|
|
|
By("verifying whether the pods from the removed node are recreated")
|
2016-04-07 17:21:31 +00:00
|
|
|
err = framework.VerifyPods(c, ns, name, true, replicas)
|
2015-06-08 08:52:37 +00:00
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
})
|
|
|
|
|
2015-06-22 21:14:54 +00:00
|
|
|
// TODO: Bug here - testName is not correct
|
|
|
|
It("should be able to add nodes", func() {
|
2015-06-08 08:52:37 +00:00
|
|
|
// Create a replication controller for a service that serves its hostname.
|
2015-07-06 12:32:56 +00:00
|
|
|
// The source for the Docker container kubernetes/serve_hostname is in contrib/for-demos/serve_hostname
|
2015-06-08 08:52:37 +00:00
|
|
|
name := "my-hostname-add-node"
|
2015-06-17 07:13:26 +00:00
|
|
|
newSVCByName(c, ns, name)
|
2016-04-27 04:35:14 +00:00
|
|
|
replicas := int32(framework.TestContext.CloudConfig.NumNodes)
|
2016-11-01 00:26:04 +00:00
|
|
|
newRCByName(c, ns, name, replicas, nil)
|
2016-04-07 17:21:31 +00:00
|
|
|
err := framework.VerifyPods(c, ns, name, true, replicas)
|
2015-06-08 08:52:37 +00:00
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
|
|
|
|
By(fmt.Sprintf("increasing cluster size to %d", replicas+1))
|
2016-05-23 12:10:40 +00:00
|
|
|
err = ResizeGroup(group, replicas+1)
|
2015-06-08 08:52:37 +00:00
|
|
|
Expect(err).NotTo(HaveOccurred())
|
2016-05-23 12:10:40 +00:00
|
|
|
err = WaitForGroupSize(group, replicas+1)
|
2015-06-08 08:52:37 +00:00
|
|
|
Expect(err).NotTo(HaveOccurred())
|
2016-04-27 04:35:14 +00:00
|
|
|
err = framework.WaitForClusterSize(c, int(replicas+1), 10*time.Minute)
|
2015-06-08 08:52:37 +00:00
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
|
|
|
|
By(fmt.Sprintf("increasing size of the replication controller to %d and verifying all pods are running", replicas+1))
|
2015-06-17 07:13:26 +00:00
|
|
|
err = resizeRC(c, ns, name, replicas+1)
|
2015-06-08 08:52:37 +00:00
|
|
|
Expect(err).NotTo(HaveOccurred())
|
2016-04-07 17:21:31 +00:00
|
|
|
err = framework.VerifyPods(c, ns, name, true, replicas+1)
|
2015-06-08 08:52:37 +00:00
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
})
|
2015-04-23 14:28:16 +00:00
|
|
|
})
|
|
|
|
})
|