use of io.fabric8.kubernetes.api.model.networking.v1.IngressRule in project che-server by eclipse-che.
the class KubernetesInternalRuntimeTest method mockIngress.
private static Ingress mockIngress() {
final Ingress ingress = mock(Ingress.class);
mockName(INGRESS_NAME, ingress);
final IngressSpec spec = mock(IngressSpec.class);
final IngressBackend backend = mock(IngressBackend.class);
final IngressServiceBackend ingressServiceBackend = mock(IngressServiceBackend.class);
final ServiceBackendPort serviceBackendPort = mock(ServiceBackendPort.class);
when(spec.getDefaultBackend()).thenReturn(backend);
when(backend.getService()).thenReturn(ingressServiceBackend);
when(ingressServiceBackend.getPort()).thenReturn(serviceBackendPort);
when(ingressServiceBackend.getName()).thenReturn(SERVICE_NAME);
when(serviceBackendPort.getNumber()).thenReturn(EXPOSED_PORT_1);
final IngressRule rule = mock(IngressRule.class);
when(rule.getHost()).thenReturn(INGRESS_HOST);
when(spec.getRules()).thenReturn(singletonList(rule));
when(ingress.getSpec()).thenReturn(spec);
when(ingress.getMetadata().getLabels()).thenReturn(ImmutableMap.of(CHE_ORIGINAL_NAME_LABEL, INGRESS_NAME));
return ingress;
}
use of io.fabric8.kubernetes.api.model.networking.v1.IngressRule in project che-server by eclipse-che.
the class IngressesTest method createIngress.
private Ingress createIngress(IngressBackend backend) {
Ingress ingress = new Ingress();
ObjectMeta ingressMeta = new ObjectMeta();
ingressMeta.setName("ingressname");
ingress.setMetadata(ingressMeta);
IngressSpec ingressSpec = new IngressSpec();
IngressRule ingressRule = new IngressRule();
ingressRule.setHost("ingresshost");
ingressRule.setHttp(new HTTPIngressRuleValue(singletonList(new HTTPIngressPath(backend, null, null))));
ingressSpec.setRules(singletonList(ingressRule));
ingress.setSpec(ingressSpec);
return ingress;
}
use of io.fabric8.kubernetes.api.model.networking.v1.IngressRule in project che-server by eclipse-che.
the class IngressesTest method emptyWhenPortByStringAndNotFound.
@Test
public void emptyWhenPortByStringAndNotFound() {
final String SERVER_PORT_NAME = "server-8080";
final int PORT = 8080;
Service service = createService(SERVER_PORT_NAME, PORT);
Ingress ingress = createIngress(new IngressBackend(null, new IngressServiceBackend("servicename", new ServiceBackendPort("does not exist", null))));
Optional<IngressRule> foundRule = Ingresses.findIngressRuleForServicePort(singletonList(ingress), service, PORT);
assertFalse(foundRule.isPresent());
}
use of io.fabric8.kubernetes.api.model.networking.v1.IngressRule in project che-server by eclipse-che.
the class IngressesTest method emptyWhenPortByIntAndNotFound.
@Test
public void emptyWhenPortByIntAndNotFound() {
final String SERVER_PORT_NAME = "server-8080";
final int PORT = 8080;
Service service = createService(SERVER_PORT_NAME, PORT);
Ingress ingress = createIngress(new IngressBackend(null, new IngressServiceBackend("servicename", new ServiceBackendPort(null, 666))));
Optional<IngressRule> foundRule = Ingresses.findIngressRuleForServicePort(singletonList(ingress), service, PORT);
assertFalse(foundRule.isPresent());
}
use of io.fabric8.kubernetes.api.model.networking.v1.IngressRule in project devspaces-images by redhat-developer.
the class KubernetesInternalRuntimeTest method mockIngress.
private static Ingress mockIngress() {
final Ingress ingress = mock(Ingress.class);
mockName(INGRESS_NAME, ingress);
final IngressSpec spec = mock(IngressSpec.class);
final IngressBackend backend = mock(IngressBackend.class);
final IngressServiceBackend ingressServiceBackend = mock(IngressServiceBackend.class);
final ServiceBackendPort serviceBackendPort = mock(ServiceBackendPort.class);
when(spec.getDefaultBackend()).thenReturn(backend);
when(backend.getService()).thenReturn(ingressServiceBackend);
when(ingressServiceBackend.getPort()).thenReturn(serviceBackendPort);
when(ingressServiceBackend.getName()).thenReturn(SERVICE_NAME);
when(serviceBackendPort.getNumber()).thenReturn(EXPOSED_PORT_1);
final IngressRule rule = mock(IngressRule.class);
when(rule.getHost()).thenReturn(INGRESS_HOST);
when(spec.getRules()).thenReturn(singletonList(rule));
when(ingress.getSpec()).thenReturn(spec);
when(ingress.getMetadata().getLabels()).thenReturn(ImmutableMap.of(CHE_ORIGINAL_NAME_LABEL, INGRESS_NAME));
return ingress;
}
Aggregations