X Tutup
Skip to content

Commit ec059b0

Browse files
committed
test : Kubectl Scale StatefulSet Should Work
1 parent 84cc9cc commit ec059b0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlScaleTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import io.kubernetes.client.openapi.models.V1Deployment;
2828
import io.kubernetes.client.openapi.models.V1Pod;
2929
import io.kubernetes.client.openapi.models.V1ReplicaSet;
30+
import io.kubernetes.client.openapi.models.V1StatefulSet;
3031
import io.kubernetes.client.util.ClientBuilder;
3132
import java.io.IOException;
3233
import org.junit.Before;
@@ -90,6 +91,29 @@ public void testKubectlScaleReplicaSetShouldWork() throws KubectlException {
9091
assertNotNull(scaled);
9192
}
9293

94+
@Test
95+
public void testKubectlScaleStatefulSetShouldWork() throws KubectlException {
96+
wireMockRule.stubFor(
97+
patch(urlPathEqualTo("/apis/apps/v1/namespaces/default/statefulsets/foo"))
98+
.willReturn(
99+
aResponse()
100+
.withStatus(200)
101+
.withBody("{\"metadata\":{\"name\":\"foo\",\"namespace\":\"default\"}}")));
102+
V1StatefulSet scaled =
103+
Kubectl.scale(V1StatefulSet.class)
104+
.apiClient(apiClient)
105+
.name("foo")
106+
.namespace("default")
107+
.replicas(8)
108+
.execute();
109+
wireMockRule.verify(
110+
1,
111+
patchRequestedFor(urlPathEqualTo("/apis/apps/v1/namespaces/default/statefulsets/foo"))
112+
.withRequestBody(
113+
equalToJson("[{\"op\":\"replace\",\"path\":\"/spec/replicas\",\"value\":8}]")));
114+
assertNotNull(scaled);
115+
}
116+
93117
@Test
94118
public void testKubectlScaleShouldThrow() {
95119
assertThrows(

0 commit comments

Comments
 (0)
X Tutup