use of io.fabric8.kubernetes.api.model.apps.ReplicaSet in project kubernetes-client by fabric8io.
the class ReplicaSetTest method testGetLogMultiContainer.
@Test
void testGetLogMultiContainer() {
ReplicaSet replicaSet = createReplicaSetBuilder().build();
server.expect().get().withPath("/apis/apps/v1/namespaces/ns1/replicasets/replicaset1").andReturn(HttpURLConnection.HTTP_OK, replicaSet).times(3);
server.expect().get().withPath("/api/v1/namespaces/ns1/pods?labelSelector=" + Utils.toUrlEncoded("app=nginx")).andReturn(HttpURLConnection.HTTP_OK, getReplicaSetPodList(replicaSet)).once();
server.expect().get().withPath("/api/v1/namespaces/ns1/pods/pod1/log?pretty=true&container=c1").andReturn(HttpURLConnection.HTTP_OK, "testlog").once();
// When
String log = client.apps().replicaSets().inNamespace("ns1").withName("replicaset1").inContainer("c1").getLog(true);
// Then
assertNotNull(log);
assertEquals("testlog", log);
}
use of io.fabric8.kubernetes.api.model.apps.ReplicaSet in project kubernetes-client by fabric8io.
the class ReplicaSetTest method testScale.
@Test
void testScale() {
server.expect().withPath("/apis/apps/v1/namespaces/test/replicasets/repl1").andReturn(200, new ReplicaSetBuilder().withNewMetadata().withName("repl1").withResourceVersion("1").endMetadata().withNewSpec().withReplicas(5).endSpec().withNewStatus().withReplicas(1).endStatus().build()).always();
ReplicaSet repl = client.apps().replicaSets().withName("repl1").scale(5);
assertNotNull(repl);
assertNotNull(repl.getSpec());
assertEquals(5, repl.getSpec().getReplicas().intValue());
assertEquals(1, repl.getStatus().getReplicas().intValue());
}
use of io.fabric8.kubernetes.api.model.apps.ReplicaSet in project kubernetes-client by fabric8io.
the class ReplicaSetTest method testRolloutUpdateSingleImage.
@Test
@DisplayName("Should update image based in single argument")
void testRolloutUpdateSingleImage() throws InterruptedException {
// Given
String imageToUpdate = "nginx:latest";
server.expect().get().withPath("/apis/apps/v1/namespaces/ns1/replicasets/replicaset1").andReturn(HttpURLConnection.HTTP_OK, createReplicaSetBuilder().build()).times(3);
server.expect().patch().withPath("/apis/apps/v1/namespaces/ns1/replicasets/replicaset1").andReturn(HttpURLConnection.HTTP_OK, createReplicaSetBuilder().editSpec().editTemplate().editSpec().editContainer(0).withImage(imageToUpdate).endContainer().endSpec().endTemplate().endSpec().build()).times(2);
// When
ReplicaSet replicationController = client.apps().replicaSets().inNamespace("ns1").withName("replicaset1").rolling().updateImage(imageToUpdate);
// Then
assertNotNull(replicationController);
assertEquals(imageToUpdate, replicationController.getSpec().getTemplate().getSpec().getContainers().get(0).getImage());
int requestCount = server.getRequestCount();
assertTrue(server.getLastRequest().getBody().readUtf8().contains(imageToUpdate));
}
use of io.fabric8.kubernetes.api.model.apps.ReplicaSet in project kubernetes-client by fabric8io.
the class ReplicaSetTest method testGet.
@Test
void testGet() {
server.expect().withPath("/apis/apps/v1/namespaces/test/replicasets/repl1").andReturn(200, new ReplicaSetBuilder().build()).once();
server.expect().withPath("/apis/apps/v1/namespaces/ns1/replicasets/repl2").andReturn(200, new ReplicaSetBuilder().build()).once();
ReplicaSet repl1 = client.apps().replicaSets().withName("repl1").get();
assertNotNull(repl1);
repl1 = client.apps().replicaSets().withName("repl2").get();
assertNull(repl1);
repl1 = client.apps().replicaSets().inNamespace("ns1").withName("repl2").get();
assertNotNull(repl1);
}
use of io.fabric8.kubernetes.api.model.apps.ReplicaSet in project kubernetes-client by fabric8io.
the class ReplicaSetV1beta1Test method testCreateOrReplace.
@Test
void testCreateOrReplace() {
ReplicaSet oldReplicaSet = new ReplicaSetBuilder().withApiVersion("extensions/v1beta1").withNewMetadata().withName("test-replicaset").endMetadata().build();
ReplicaSet newReplicaSet = new ReplicaSetBuilder().withApiVersion("extensions/v1beta1").withNewMetadata().withName("test-deployment").withAnnotations(Collections.singletonMap("newAnnotation", "test")).endMetadata().build();
server.expect().post().withPath("/apis/extensions/v1beta1/namespaces/test/replicasets").andReturn(HttpURLConnection.HTTP_CONFLICT, oldReplicaSet).once();
server.expect().get().withPath("/apis/extensions/v1beta1/namespaces/test/replicasets/test-deployment").andReturn(HttpURLConnection.HTTP_OK, oldReplicaSet).times(2);
server.expect().put().withPath("/apis/extensions/v1beta1/namespaces/test/replicasets/test-deployment").andReturn(HttpURLConnection.HTTP_OK, newReplicaSet).once();
ReplicaSet result = client.extensions().replicaSets().inNamespace("test").createOrReplace(newReplicaSet);
assertNotNull(result);
assertEquals(newReplicaSet, result);
}
Aggregations