use of io.strimzi.test.k8s.exceptions.NoClusterException in project strimzi by strimzi.
the class KubeCluster method bootstrap.
/**
* Returns the cluster named by the TEST_CLUSTER environment variable, if set, otherwise finds a cluster that's
* both installed and running.
* @return The cluster.
* @throws NoClusterException If no running cluster was found.
*/
static KubeCluster bootstrap() throws NoClusterException {
Logger logger = LogManager.getLogger(KubeCluster.class);
KubeCluster[] clusters = null;
String clusterName = System.getenv(ENV_VAR_TEST_CLUSTER);
if (clusterName != null) {
switch(clusterName.toLowerCase(Locale.ENGLISH)) {
case "oc":
clusters = new KubeCluster[] { new OpenShift() };
break;
case "minikube":
clusters = new KubeCluster[] { new Minikube() };
break;
case "kubernetes":
clusters = new KubeCluster[] { new Kubernetes() };
break;
default:
throw new IllegalArgumentException(ENV_VAR_TEST_CLUSTER + "=" + clusterName + " is not a supported cluster type");
}
}
if (clusters == null) {
clusters = new KubeCluster[] { new Minikube(), new Kubernetes(), new OpenShift() };
}
KubeCluster cluster = null;
for (KubeCluster kc : clusters) {
if (kc.isAvailable()) {
logger.debug("Cluster {} is installed", kc);
if (kc.isClusterUp()) {
logger.debug("Cluster {} is running", kc);
cluster = kc;
break;
} else {
logger.debug("Cluster {} is not running!", kc);
}
} else {
logger.debug("Cluster {} is not installed!", kc);
}
}
if (cluster == null) {
throw new NoClusterException("Unable to find a cluster; tried " + Arrays.toString(clusters));
}
logger.info("Using cluster: {}", cluster);
return cluster;
}
use of io.strimzi.test.k8s.exceptions.NoClusterException in project strimzi by strimzi.
the class TopicOperatorBaseIT method setupKubeCluster.
public static void setupKubeCluster() throws IOException {
cluster = getInstance();
VertxOptions options = new VertxOptions().setMetricsOptions(new MicrometerMetricsOptions().setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true)).setEnabled(true));
vertx = Vertx.vertx(options);
try {
KubeCluster.bootstrap();
} catch (NoClusterException e) {
assumeTrue(false, e.getMessage());
}
cmdKubeClient().createNamespace(NAMESPACE);
oldNamespace = cluster.setNamespace(NAMESPACE);
LOGGER.info("#### Creating " + "../packaging/install/topic-operator/02-Role-strimzi-topic-operator.yaml");
cmdKubeClient().create(TestUtils.USER_PATH + "/../packaging/install/topic-operator/02-Role-strimzi-topic-operator.yaml");
LOGGER.info("#### Creating " + TestUtils.CRD_TOPIC);
cmdKubeClient().create(TestUtils.CRD_TOPIC);
LOGGER.info("#### Creating " + TestUtils.USER_PATH + "/src/test/resources/TopicOperatorIT-rbac.yaml");
cmdKubeClient().create(TestUtils.USER_PATH + "/src/test/resources/TopicOperatorIT-rbac.yaml");
}
use of io.strimzi.test.k8s.exceptions.NoClusterException in project strimzi-kafka-operator by strimzi.
the class KubeCluster method bootstrap.
/**
* Returns the cluster named by the TEST_CLUSTER environment variable, if set, otherwise finds a cluster that's
* both installed and running.
* @return The cluster.
* @throws NoClusterException If no running cluster was found.
*/
static KubeCluster bootstrap() throws NoClusterException {
Logger logger = LogManager.getLogger(KubeCluster.class);
KubeCluster[] clusters = null;
String clusterName = System.getenv(ENV_VAR_TEST_CLUSTER);
if (clusterName != null) {
switch(clusterName.toLowerCase(Locale.ENGLISH)) {
case "oc":
clusters = new KubeCluster[] { new OpenShift() };
break;
case "minikube":
clusters = new KubeCluster[] { new Minikube() };
break;
case "kubernetes":
clusters = new KubeCluster[] { new Kubernetes() };
break;
default:
throw new IllegalArgumentException(ENV_VAR_TEST_CLUSTER + "=" + clusterName + " is not a supported cluster type");
}
}
if (clusters == null) {
clusters = new KubeCluster[] { new Minikube(), new Kubernetes(), new OpenShift() };
}
KubeCluster cluster = null;
for (KubeCluster kc : clusters) {
if (kc.isAvailable()) {
logger.debug("Cluster {} is installed", kc);
if (kc.isClusterUp()) {
logger.debug("Cluster {} is running", kc);
cluster = kc;
break;
} else {
logger.debug("Cluster {} is not running!", kc);
}
} else {
logger.debug("Cluster {} is not installed!", kc);
}
}
if (cluster == null) {
throw new NoClusterException("Unable to find a cluster; tried " + Arrays.toString(clusters));
}
logger.info("Using cluster: {}", cluster);
return cluster;
}
use of io.strimzi.test.k8s.exceptions.NoClusterException in project strimzi-kafka-operator by strimzi.
the class TopicOperatorBaseIT method setupKubeCluster.
public static void setupKubeCluster() throws IOException {
cluster = getInstance();
VertxOptions options = new VertxOptions().setMetricsOptions(new MicrometerMetricsOptions().setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true)).setEnabled(true));
vertx = Vertx.vertx(options);
try {
KubeCluster.bootstrap();
} catch (NoClusterException e) {
assumeTrue(false, e.getMessage());
}
cmdKubeClient().createNamespace(NAMESPACE);
oldNamespace = cluster.setNamespace(NAMESPACE);
LOGGER.info("#### Creating " + "../packaging/install/topic-operator/02-Role-strimzi-topic-operator.yaml");
cmdKubeClient().create(TestUtils.USER_PATH + "/../packaging/install/topic-operator/02-Role-strimzi-topic-operator.yaml");
LOGGER.info("#### Creating " + TestUtils.CRD_TOPIC);
cmdKubeClient().create(TestUtils.CRD_TOPIC);
LOGGER.info("#### Creating " + TestUtils.USER_PATH + "/src/test/resources/TopicOperatorIT-rbac.yaml");
cmdKubeClient().create(TestUtils.USER_PATH + "/src/test/resources/TopicOperatorIT-rbac.yaml");
}
Aggregations