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);
}
}
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);
}
Aggregations