use of io.fabric8.kubernetes.api.model.networking.v1.IngressServiceBackend in project che-server by eclipse-che.
the class IngressServerResolverTest method createIngress.
private Ingress createIngress(String name, String machineName, Pair<String, ServerConfig> server) {
Serializer serializer = Annotations.newSerializer();
serializer.machineName(machineName);
serializer.server(server.first, server.second);
return new IngressBuilder().withNewMetadata().withName(name).withAnnotations(serializer.annotations()).endMetadata().withNewSpec().withRules(new IngressRule(null, new HTTPIngressRuleValue(singletonList(new HTTPIngressPath(new IngressBackend(null, new IngressServiceBackend(name, new ServiceBackendPort("8080", 8080))), INGRESS_PATH_PREFIX, null))))).endSpec().withNewStatus().withLoadBalancer(new LoadBalancerStatusBuilder().addNewIngress().withIp("127.0.0.1").endIngress().build()).endStatus().build();
}
use of io.fabric8.kubernetes.api.model.networking.v1.IngressServiceBackend 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.IngressServiceBackend 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.IngressServiceBackend 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.IngressServiceBackend 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