Link all the ReplicaSet controller boilerplate together.

1. Enable replica set in controller manager.
2. Enable replica set etcd storage in master package.
3. Add replica set support to kubectl commands.
This commit is contained in:
Madhusudan.C.S
2016-01-18 16:06:57 -08:00
parent fcf9c4a1e4
commit 4f9b8b2bfc
11 changed files with 330 additions and 0 deletions

View File

@@ -264,6 +264,116 @@ func TestReplicationControllerStop(t *testing.T) {
}
}
func TestReplicaSetStop(t *testing.T) {
name := "foo"
ns := "default"
tests := []struct {
Name string
Objs []runtime.Object
StopError error
ExpectedActions []string
}{
{
Name: "OnlyOneRS",
Objs: []runtime.Object{
&extensions.ReplicaSet{ // GET
ObjectMeta: api.ObjectMeta{
Name: name,
Namespace: ns,
},
Spec: extensions.ReplicaSetSpec{
Replicas: 0,
Selector: &unversioned.LabelSelector{MatchLabels: map[string]string{"k1": "v1"}},
},
},
&extensions.ReplicaSetList{ // LIST
Items: []extensions.ReplicaSet{
{
ObjectMeta: api.ObjectMeta{
Name: name,
Namespace: ns,
},
Spec: extensions.ReplicaSetSpec{
Replicas: 0,
Selector: &unversioned.LabelSelector{MatchLabels: map[string]string{"k1": "v1"}},
},
},
},
},
},
StopError: nil,
ExpectedActions: []string{"get", "get", "update", "get", "get", "delete"},
},
{
Name: "NoOverlapping",
Objs: []runtime.Object{
&extensions.ReplicaSet{ // GET
ObjectMeta: api.ObjectMeta{
Name: name,
Namespace: ns,
},
Spec: extensions.ReplicaSetSpec{
Replicas: 0,
Selector: &unversioned.LabelSelector{MatchLabels: map[string]string{"k1": "v1"}},
},
},
&extensions.ReplicaSetList{ // LIST
Items: []extensions.ReplicaSet{
{
ObjectMeta: api.ObjectMeta{
Name: "baz",
Namespace: ns,
},
Spec: extensions.ReplicaSetSpec{
Replicas: 0,
Selector: &unversioned.LabelSelector{MatchLabels: map[string]string{"k3": "v3"}},
},
},
{
ObjectMeta: api.ObjectMeta{
Name: name,
Namespace: ns,
},
Spec: extensions.ReplicaSetSpec{
Replicas: 0,
Selector: &unversioned.LabelSelector{MatchLabels: map[string]string{"k1": "v1"}},
},
},
},
},
},
StopError: nil,
ExpectedActions: []string{"get", "get", "update", "get", "get", "delete"},
},
// TODO: Implement tests for overlapping replica sets, similar to replication controllers,
// when the overlapping checks are implemented for replica sets.
}
for _, test := range tests {
fake := testclient.NewSimpleFake(test.Objs...)
reaper := ReplicaSetReaper{fake, time.Millisecond, time.Millisecond}
err := reaper.Stop(ns, name, 0, nil)
if !reflect.DeepEqual(err, test.StopError) {
t.Errorf("%s unexpected error: %v", test.Name, err)
continue
}
actions := fake.Actions()
if len(actions) != len(test.ExpectedActions) {
t.Errorf("%s unexpected actions: %v, expected %d actions got %d", test.Name, actions, len(test.ExpectedActions), len(actions))
continue
}
for i, verb := range test.ExpectedActions {
if actions[i].GetResource() != "replicasets" {
t.Errorf("%s unexpected action: %+v, expected %s-replicaSet", test.Name, actions[i], verb)
}
if actions[i].GetVerb() != verb {
t.Errorf("%s unexpected action: %+v, expected %s-replicaSet", test.Name, actions[i], verb)
}
}
}
}
func TestJobStop(t *testing.T) {
name := "foo"
ns := "default"