Search in sources :

Example 1 with ExecBuilder

use of org.bf2.test.executor.ExecBuilder in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class FleetShardOperatorManager method createEndpoint.

public static String createEndpoint(KubeClient kubeClient) {
    String externalEndpointName = SYNC_NAME + "-external";
    if (kubeClient.isGenericKubernetes()) {
        if (kubeClient.client().services().inNamespace(OPERATOR_NS).list().getItems().stream().anyMatch(service -> service.getMetadata().getName().equals(externalEndpointName))) {
            kubeClient.client().services().inNamespace(OPERATOR_NS).withName(externalEndpointName).delete();
        }
        kubeClient.cmdClient().namespace(OPERATOR_NS).execInCurrentNamespace("expose", "service", SYNC_NAME, "--type=LoadBalancer", "--name", externalEndpointName);
        return new ExecBuilder().withCommand("minikube", "service", "--url", externalEndpointName, "-n", OPERATOR_NS).logToOutput(false).exec().out().trim();
    } else {
        OpenShiftClient openShiftClient = kubeClient.client().adapt(OpenShiftClient.class);
        if (openShiftClient.routes().inNamespace(OPERATOR_NS).list().getItems().stream().anyMatch(service -> service.getMetadata().getName().equals(externalEndpointName))) {
            openShiftClient.routes().inNamespace(OPERATOR_NS).withName(externalEndpointName).delete();
        }
        kubeClient.cmdClient().namespace(OPERATOR_NS).execInCurrentNamespace("expose", "service", SYNC_NAME, "--name", externalEndpointName);
        Route r = openShiftClient.routes().inNamespace(OPERATOR_NS).withName(externalEndpointName).get();
        return String.format("%s://%s:%d", r.getSpec().getPort().getTargetPort().getStrVal(), r.getSpec().getHost(), r.getSpec().getPort().getTargetPort().getStrVal().equals("http") ? 80 : 443);
    }
}
Also used : OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) ExecBuilder(org.bf2.test.executor.ExecBuilder) Route(io.fabric8.openshift.api.model.Route)

Example 2 with ExecBuilder

use of org.bf2.test.executor.ExecBuilder in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class SuiteUnitTest method testExecutorError.

@SequentialTest
void testExecutorError() {
    ExecBuilder command = Exec.builder().withCommand("ppppeeeepppaaa", "jenda").logToOutput(false).throwErrors(true).timeout(60);
    assertThrows(KubeClusterException.class, command::exec);
}
Also used : ExecBuilder(org.bf2.test.executor.ExecBuilder) SequentialTest(org.bf2.systemtest.framework.SequentialTest)

Aggregations

ExecBuilder (org.bf2.test.executor.ExecBuilder)2 Route (io.fabric8.openshift.api.model.Route)1 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)1 SequentialTest (org.bf2.systemtest.framework.SequentialTest)1