mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-10 15:32:05 -03:30
fix: adjusting the startup of the local api server for ci (#41364)
closes: #39766 Signed-off-by: Steve Hawkins <shawkins@redhat.com>
This commit is contained in:
parent
7cdb994ba6
commit
a770204d0e
@ -7,19 +7,37 @@ import java.util.Optional;
|
||||
import org.keycloak.operator.Utils;
|
||||
|
||||
import io.fabric8.kubeapitest.KubeAPIServer;
|
||||
import io.fabric8.kubeapitest.KubeAPIServerConfigBuilder;
|
||||
import io.fabric8.kubeapitest.KubeAPITestException;
|
||||
import io.fabric8.kubernetes.api.model.apps.StatefulSet;
|
||||
import io.fabric8.kubernetes.client.Config;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
|
||||
import io.fabric8.kubernetes.client.informers.ResourceEventHandler;
|
||||
import io.quarkus.logging.Log;
|
||||
|
||||
public class ApiServerHelper {
|
||||
|
||||
static final int MAX_START_RETRIES = 2;
|
||||
|
||||
private KubeAPIServer kubeApi;
|
||||
|
||||
public ApiServerHelper() {
|
||||
kubeApi = new KubeAPIServer();
|
||||
kubeApi.start();
|
||||
long start = System.currentTimeMillis();
|
||||
for (int i = 0; i < MAX_START_RETRIES; i++) {
|
||||
kubeApi = new KubeAPIServer(
|
||||
KubeAPIServerConfigBuilder.anAPIServerConfig().withStartupTimeout(90_000).build());
|
||||
try {
|
||||
kubeApi.start();
|
||||
} catch (KubeAPITestException e) {
|
||||
if (i == MAX_START_RETRIES - 1) {
|
||||
throw e;
|
||||
}
|
||||
kubeApi.stop();
|
||||
Log.warnf("api server failed to become ready %s", e.getMessage());
|
||||
}
|
||||
}
|
||||
Log.infof("api server started in %s ms", System.currentTimeMillis() - start);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
|
||||
@ -137,7 +137,7 @@ public class BaseOperatorTest implements QuarkusTestAfterEachCallback {
|
||||
|
||||
setDefaultAwaitilityTimings();
|
||||
|
||||
if (operatorDeployment == OperatorDeployment.local_apiserver) {
|
||||
if (operatorDeployment == OperatorDeployment.local_apiserver && kubeApi == null) {
|
||||
kubeApi = new ApiServerHelper();
|
||||
}
|
||||
|
||||
@ -486,10 +486,11 @@ public class BaseOperatorTest implements QuarkusTestAfterEachCallback {
|
||||
k8sclient = null;
|
||||
}
|
||||
|
||||
if (kubeApi != null) {
|
||||
// scope the api server to the entire test run
|
||||
/*if (kubeApi != null) {
|
||||
kubeApi.stop();
|
||||
kubeApi = null;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private static void stopOperator() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user