use of io.fabric8.kubernetes.api.model.networking.v1.Ingress in project kubernetes-client by fabric8io.
the class IngressTest method testDeleteWithNamespaceMismatch.
@Test
public void testDeleteWithNamespaceMismatch() {
Ingress ingress1 = new IngressBuilder().withNewMetadata().withName("ingress1").withNamespace("test").and().build();
Boolean deleted = client.extensions().ingress().inNamespace("test1").delete(ingress1);
assertFalse(deleted);
}
use of io.fabric8.kubernetes.api.model.networking.v1.Ingress in project kubernetes-client by fabric8io.
the class IngressTest method testCreateWithNameMismatch.
@Test
public void testCreateWithNameMismatch() {
Assertions.assertThrows(KubernetesClientException.class, () -> {
Ingress ingress1 = new IngressBuilder().withNewMetadata().withName("ingress1").withNamespace("test").and().build();
Ingress ingress2 = new IngressBuilder().withNewMetadata().withName("ingress2").withNamespace("ns1").and().build();
client.extensions().ingress().inNamespace("test1").withName("myingress1").create(ingress1);
});
}
use of io.fabric8.kubernetes.api.model.networking.v1.Ingress in project kubernetes-client by fabric8io.
the class IngressTest method testListWithLables.
@Test
public void testListWithLables() {
server.expect().withPath("/apis/extensions/v1beta1/namespaces/test/ingresses?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new IngressListBuilder().build()).always();
server.expect().withPath("/apis/extensions/v1beta1/namespaces/test/ingresses?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new IngressListBuilder().addNewItem().and().addNewItem().and().addNewItem().and().build()).once();
IngressList ingressList = client.extensions().ingress().withLabel("key1", "value1").withLabel("key2", "value2").withLabel("key3", "value3").list();
assertNotNull(ingressList);
assertEquals(0, ingressList.getItems().size());
ingressList = client.extensions().ingress().withLabel("key1", "value1").withLabel("key2", "value2").list();
assertNotNull(ingressList);
assertEquals(3, ingressList.getItems().size());
}
use of io.fabric8.kubernetes.api.model.networking.v1.Ingress in project kubernetes-client by fabric8io.
the class IngressTest method testDeleteMulti.
@Test
public void testDeleteMulti() {
Ingress ingress1 = new IngressBuilder().withNewMetadata().withName("ingress1").withNamespace("test").and().build();
Ingress ingress2 = new IngressBuilder().withNewMetadata().withName("ingress2").withNamespace("ns1").and().build();
Ingress ingress3 = new IngressBuilder().withNewMetadata().withName("ingress3").withNamespace("any").and().build();
server.expect().withPath("/apis/extensions/v1beta1/namespaces/test/ingresses/ingress1").andReturn(200, ingress1).once();
server.expect().withPath("/apis/extensions/v1beta1/namespaces/ns1/ingresses/ingress2").andReturn(200, ingress2).once();
Boolean deleted = client.extensions().ingress().inAnyNamespace().delete(ingress1, ingress2);
assertTrue(deleted);
deleted = client.extensions().ingress().inAnyNamespace().delete(ingress3);
assertFalse(deleted);
}
use of io.fabric8.kubernetes.api.model.networking.v1.Ingress in project kubernetes-client by fabric8io.
the class V1IngressClassTest method testLoad.
@Test
void testLoad() {
// When
List<HasMetadata> itemList = client.load(getClass().getResourceAsStream("/test-v1-ingressclass.yml")).get();
// Then
assertEquals(1, itemList.size());
assertTrue(itemList.get(0) instanceof IngressClass);
IngressClass ingressClass = (IngressClass) itemList.get(0);
assertEquals("external-lb", ingressClass.getMetadata().getName());
assertEquals("example.com/ingress-controller", ingressClass.getSpec().getController());
}
Aggregations