Merge pull request #9739 from bprashanth/sno

Fix kubectl stop rc with sequence numbers
This commit is contained in:
Satnam Singh
2015-06-19 15:30:26 -07:00
21 changed files with 212 additions and 21 deletions

View File

@@ -142,7 +142,9 @@ func TestUpdate(t *testing.T) {
[]fakeResponse{
// no existing newRc
{nil, fmt.Errorf("not found")},
// 3 gets for each scale
// 4 gets for each scale
{newRc(1, 1), nil},
{newRc(1, 1), nil},
{newRc(1, 1), nil},
{newRc(1, 1), nil},
{newRc(1, 1), nil},
@@ -164,7 +166,10 @@ Update succeeded. Deleting foo-v1
[]fakeResponse{
// no existing newRc
{nil, fmt.Errorf("not found")},
// 3 gets for each scale
// 4 gets for each scale
{newRc(1, 2), nil},
{newRc(1, 2), nil},
{newRc(1, 2), nil},
{newRc(1, 2), nil},
{newRc(1, 2), nil},
{newRc(1, 2), nil},
@@ -195,7 +200,10 @@ Update succeeded. Deleting foo-v1
[]fakeResponse{
// no existing newRc
{nil, fmt.Errorf("not found")},
// 3 gets for each scale
// 4 gets for each scale
{newRc(1, 2), nil},
{newRc(1, 2), nil},
{newRc(1, 2), nil},
{newRc(1, 2), nil},
{newRc(1, 2), nil},
{newRc(1, 2), nil},
@@ -214,6 +222,7 @@ Update succeeded. Deleting foo-v1
{newRc(7, 7), nil},
{newRc(7, 7), nil},
{newRc(7, 7), nil},
{newRc(7, 7), nil},
// cleanup annotations
{newRc(7, 7), nil},
{newRc(7, 7), nil},
@@ -229,7 +238,10 @@ Update succeeded. Deleting foo-v1
[]fakeResponse{
// no existing newRc
{nil, fmt.Errorf("not found")},
// 3 gets for each update
// 4 gets for each update
{newRc(1, 2), nil},
{newRc(1, 2), nil},
{newRc(1, 2), nil},
{newRc(1, 2), nil},
{newRc(1, 2), nil},
{newRc(1, 2), nil},
@@ -247,6 +259,8 @@ Update succeeded. Deleting foo-v1
// stop oldRc
{oldRc(0), nil},
{oldRc(0), nil},
{oldRc(0), nil},
{oldRc(0), nil},
// cleanup annotations
{newRc(2, 2), nil},
{newRc(2, 2), nil},

View File

@@ -161,7 +161,10 @@ func (scaler *ReplicationControllerScaler) Scale(namespace, name string, newSize
return err
}
if waitForReplicas != nil {
rc := &api.ReplicationController{ObjectMeta: api.ObjectMeta{Namespace: namespace, Name: name}}
rc, err := scaler.c.GetReplicationController(namespace, name)
if err != nil {
return err
}
return wait.Poll(waitForReplicas.Interval, waitForReplicas.Timeout,
scaler.c.ControllerHasDesiredReplicas(rc))
}

View File

@@ -42,10 +42,10 @@ func TestReplicationControllerStop(t *testing.T) {
if s != expected {
t.Errorf("expected %s, got %s", expected, s)
}
if len(fake.Actions) != 5 {
t.Errorf("unexpected actions: %v, expected 4 actions (get, get, update, get, delete)", fake.Actions)
if len(fake.Actions) != 6 {
t.Errorf("unexpected actions: %v, expected 6 actions (get, get, update, get, get, delete)", fake.Actions)
}
for i, action := range []string{"get", "get", "update", "get", "delete"} {
for i, action := range []string{"get", "get", "update", "get", "get", "delete"} {
if fake.Actions[i].Action != action+"-replicationController" {
t.Errorf("unexpected action: %v, expected %s-replicationController", fake.Actions[i], action)
}