Search in sources :

Example 1 with V1beta1HTTPIngressPath

use of io.kubernetes.client.models.V1beta1HTTPIngressPath in project weblogic-kubernetes-operator by oracle.

the class IngressHelperTest method testAddThenRemoveServer.

@Test
public void testAddThenRemoveServer() throws Throwable {
    Packet p = new Packet();
    p.getComponents().put(ProcessingConstants.DOMAIN_COMPONENT_NAME, Component.createFor(info));
    p.put(ProcessingConstants.SERVER_SCAN, info.getScan().getServerConfig(server1Name));
    p.put(ProcessingConstants.CLUSTER_SCAN, info.getScan().getClusterConfig(clusterName));
    p.put(ProcessingConstants.SERVER_NAME, server1Name);
    Fiber f = engine.createFiber();
    Step s = IngressHelper.createClusterStep(null);
    AtomicReference<Throwable> t = new AtomicReference<>();
    f.start(s, p, new CompletionCallback() {

        @Override
        public void onCompletion(Packet packet) {
        // no-op
        }

        @Override
        public void onThrowable(Packet packet, Throwable throwable) {
            t.set(throwable);
        }
    });
    f.get(30, TimeUnit.SECONDS);
    if (t.get() != null) {
        throw t.get();
    }
    // Now check
    CallBuilderFactory factory = new CallBuilderFactory(null);
    V1beta1Ingress v1beta1Ingress = factory.create().readIngress(ingressName, namespace);
    List<V1beta1HTTPIngressPath> v1beta1HTTPIngressPaths = getPathArray(v1beta1Ingress);
    Assert.assertEquals("IngressPaths should have one instance of IngressPath", 1, v1beta1HTTPIngressPaths.size());
    V1beta1HTTPIngressPath v1beta1HTTPIngressPath = v1beta1HTTPIngressPaths.get(0);
    Assert.assertEquals("/", v1beta1HTTPIngressPath.getPath());
    V1beta1IngressBackend v1beta1IngressBackend = v1beta1HTTPIngressPath.getBackend();
    Assert.assertNotNull("IngressBackend Object should not be null", v1beta1IngressBackend);
    Assert.assertEquals("Service name should be " + clusterServiceName, clusterServiceName, v1beta1IngressBackend.getServiceName());
    Assert.assertEquals("Service port should be " + server1Port, server1Port, v1beta1IngressBackend.getServicePort().getIntValue());
}
Also used : Packet(oracle.kubernetes.operator.work.Packet) Fiber(oracle.kubernetes.operator.work.Fiber) V1beta1IngressBackend(io.kubernetes.client.models.V1beta1IngressBackend) AtomicReference(java.util.concurrent.atomic.AtomicReference) Step(oracle.kubernetes.operator.work.Step) V1beta1HTTPIngressPath(io.kubernetes.client.models.V1beta1HTTPIngressPath) V1beta1Ingress(io.kubernetes.client.models.V1beta1Ingress) CompletionCallback(oracle.kubernetes.operator.work.Fiber.CompletionCallback) Test(org.junit.Test)

Example 2 with V1beta1HTTPIngressPath

use of io.kubernetes.client.models.V1beta1HTTPIngressPath in project weblogic-kubernetes-operator by oracle.

the class IngressHelperTest method getPathArray.

private List<V1beta1HTTPIngressPath> getPathArray(V1beta1Ingress v1beta1Ingress) {
    Assert.assertNotNull("Ingress Object should not be null", v1beta1Ingress);
    V1beta1IngressSpec v1beta1IngressSpec = v1beta1Ingress.getSpec();
    Assert.assertNotNull("Spec Object should not be null", v1beta1IngressSpec);
    List<V1beta1IngressRule> v1beta1IngressRules = v1beta1IngressSpec.getRules();
    Assert.assertNotNull("Rules List should not be null", v1beta1IngressRules);
    Assert.assertTrue("Rules List  should have one instance of IngressRule", v1beta1IngressRules.size() == 1);
    V1beta1IngressRule v1beta1IngressRule = v1beta1IngressRules.get(0);
    Assert.assertNotNull("IngressRule Object should not be null", v1beta1IngressRule);
    V1beta1HTTPIngressRuleValue v1beta1HTTPIngressRuleValue = v1beta1IngressRule.getHttp();
    Assert.assertNotNull("IngressRuleValue Object should not be null", v1beta1HTTPIngressRuleValue);
    List<V1beta1HTTPIngressPath> v1beta1HTTPIngressPaths = v1beta1HTTPIngressRuleValue.getPaths();
    Assert.assertNotNull("IngressPath list should not be null", v1beta1HTTPIngressPaths);
    return v1beta1HTTPIngressPaths;
}
Also used : V1beta1HTTPIngressRuleValue(io.kubernetes.client.models.V1beta1HTTPIngressRuleValue) V1beta1IngressRule(io.kubernetes.client.models.V1beta1IngressRule) V1beta1HTTPIngressPath(io.kubernetes.client.models.V1beta1HTTPIngressPath) V1beta1IngressSpec(io.kubernetes.client.models.V1beta1IngressSpec)

Aggregations

V1beta1HTTPIngressPath (io.kubernetes.client.models.V1beta1HTTPIngressPath)2 V1beta1HTTPIngressRuleValue (io.kubernetes.client.models.V1beta1HTTPIngressRuleValue)1 V1beta1Ingress (io.kubernetes.client.models.V1beta1Ingress)1 V1beta1IngressBackend (io.kubernetes.client.models.V1beta1IngressBackend)1 V1beta1IngressRule (io.kubernetes.client.models.V1beta1IngressRule)1 V1beta1IngressSpec (io.kubernetes.client.models.V1beta1IngressSpec)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Fiber (oracle.kubernetes.operator.work.Fiber)1 CompletionCallback (oracle.kubernetes.operator.work.Fiber.CompletionCallback)1 Packet (oracle.kubernetes.operator.work.Packet)1 Step (oracle.kubernetes.operator.work.Step)1 Test (org.junit.Test)1