Use scale subresource

- Use scale subresource for ReplicationController, ReplicaSet and Deployment.
This commit is contained in:
Michael Fraenkel
2016-08-22 08:58:35 -04:00
parent 75fba4c953
commit f061f74f56
4 changed files with 130 additions and 270 deletions

View File

@@ -68,6 +68,11 @@ func TestReplicationControllerStop(t *testing.T) {
},
},
},
&extensions.Scale{
Spec: extensions.ScaleSpec{
Replicas: 0,
},
},
},
StopError: nil,
ExpectedActions: []string{"get", "list", "get", "update", "get", "delete"},
@@ -106,6 +111,11 @@ func TestReplicationControllerStop(t *testing.T) {
},
},
},
&extensions.Scale{
Spec: extensions.ScaleSpec{
Replicas: 0,
},
},
},
StopError: nil,
ExpectedActions: []string{"get", "list", "get", "update", "get", "delete"},
@@ -268,7 +278,7 @@ func TestReplicationControllerStop(t *testing.T) {
continue
}
for i, verb := range test.ExpectedActions {
if actions[i].GetResource() != "replicationcontrollers" {
if actions[i].GetResource() != "replicationcontrollers" && actions[i].GetSubresource() != "scale" {
t.Errorf("%s unexpected action: %+v, expected %s-replicationController", test.Name, actions[i], verb)
}
if actions[i].GetVerb() != verb {
@@ -314,6 +324,11 @@ func TestReplicaSetStop(t *testing.T) {
},
},
},
&extensions.Scale{
Spec: extensions.ScaleSpec{
Replicas: 0,
},
},
},
StopError: nil,
ExpectedActions: []string{"get", "get", "update", "get", "get", "delete"},
@@ -355,6 +370,11 @@ func TestReplicaSetStop(t *testing.T) {
},
},
},
&extensions.Scale{
Spec: extensions.ScaleSpec{
Replicas: 0,
},
},
},
StopError: nil,
ExpectedActions: []string{"get", "get", "update", "get", "get", "delete"},
@@ -378,7 +398,7 @@ func TestReplicaSetStop(t *testing.T) {
continue
}
for i, verb := range test.ExpectedActions {
if actions[i].GetResource() != "replicasets" {
if actions[i].GetResource() != "replicasets" && actions[i].GetSubresource() != "scale" {
t.Errorf("%s unexpected action: %+v, expected %s-replicaSet", test.Name, actions[i], verb)
}
if actions[i].GetVerb() != verb {
@@ -570,6 +590,11 @@ func TestDeploymentStop(t *testing.T) {
},
},
},
&extensions.Scale{
Spec: extensions.ScaleSpec{
Replicas: 0,
},
},
},
StopError: nil,
ExpectedActions: []string{"get:deployments", "update:deployments",
@@ -598,7 +623,7 @@ func TestDeploymentStop(t *testing.T) {
if actions[i].GetVerb() != action[0] {
t.Errorf("%s unexpected verb: %+v, expected %s", test.Name, actions[i], expAction)
}
if actions[i].GetResource() != action[1] {
if actions[i].GetResource() != action[1] && actions[i].GetSubresource() != "scale" {
t.Errorf("%s unexpected resource: %+v, expected %s", test.Name, actions[i], expAction)
}
if len(action) == 3 && actions[i].GetSubresource() != action[2] {