use of io.fabric8.kubernetes.api.model.apps.StatefulSetStatus in project strimzi by strimzi.
the class KafkaAssemblyOperatorMockTest method initialReconcile.
private Future<Void> initialReconcile(VertxTestContext context) {
LOGGER.info("Reconciling initially -> create");
return operator.reconcile(new Reconciliation("test-trigger", Kafka.RESOURCE_KIND, NAMESPACE, CLUSTER_NAME)).onComplete(context.succeeding(v -> context.verify(() -> {
StatefulSet kafkaSts = client.apps().statefulSets().inNamespace(NAMESPACE).withName(KafkaCluster.kafkaClusterName(CLUSTER_NAME)).get();
kafkaSts.setStatus(new StatefulSetStatus());
assertThat(kafkaSts, is(notNullValue()));
assertThat(kafkaSts.getSpec().getTemplate().getMetadata().getAnnotations(), hasEntry(StatefulSetOperator.ANNO_STRIMZI_IO_GENERATION, "0"));
assertThat(kafkaSts.getSpec().getTemplate().getMetadata().getAnnotations(), hasEntry(Ca.ANNO_STRIMZI_IO_CLUSTER_CA_CERT_GENERATION, "0"));
assertThat(kafkaSts.getSpec().getTemplate().getMetadata().getAnnotations(), hasEntry(Ca.ANNO_STRIMZI_IO_CLIENTS_CA_CERT_GENERATION, "0"));
StatefulSet zkSts = client.apps().statefulSets().inNamespace(NAMESPACE).withName(ZookeeperCluster.zookeeperClusterName(CLUSTER_NAME)).get();
assertThat(zkSts, is(notNullValue()));
assertThat(zkSts.getSpec().getTemplate().getMetadata().getAnnotations(), hasEntry(StatefulSetOperator.ANNO_STRIMZI_IO_GENERATION, "0"));
assertThat(zkSts.getSpec().getTemplate().getMetadata().getAnnotations(), hasEntry(Ca.ANNO_STRIMZI_IO_CLUSTER_CA_CERT_GENERATION, "0"));
assertThat(client.configMaps().inNamespace(NAMESPACE).withName(KafkaCluster.metricAndLogConfigsName(CLUSTER_NAME)).get(), is(notNullValue()));
assertThat(client.configMaps().inNamespace(NAMESPACE).withName(ZookeeperCluster.zookeeperMetricAndLogConfigsName(CLUSTER_NAME)).get(), is(notNullValue()));
assertResourceRequirements(context, KafkaCluster.kafkaClusterName(CLUSTER_NAME));
assertThat(client.secrets().inNamespace(NAMESPACE).withName(KafkaCluster.clientsCaKeySecretName(CLUSTER_NAME)).get(), is(notNullValue()));
assertThat(client.secrets().inNamespace(NAMESPACE).withName(KafkaCluster.clientsCaCertSecretName(CLUSTER_NAME)).get(), is(notNullValue()));
assertThat(client.secrets().inNamespace(NAMESPACE).withName(KafkaCluster.clusterCaCertSecretName(CLUSTER_NAME)).get(), is(notNullValue()));
assertThat(client.secrets().inNamespace(NAMESPACE).withName(KafkaCluster.brokersSecretName(CLUSTER_NAME)).get(), is(notNullValue()));
assertThat(client.secrets().inNamespace(NAMESPACE).withName(ZookeeperCluster.nodesSecretName(CLUSTER_NAME)).get(), is(notNullValue()));
})));
}
use of io.fabric8.kubernetes.api.model.apps.StatefulSetStatus in project strimzi-kafka-operator by strimzi.
the class KafkaAssemblyOperatorMockTest method initialReconcile.
private Future<Void> initialReconcile(VertxTestContext context) {
LOGGER.info("Reconciling initially -> create");
return operator.reconcile(new Reconciliation("test-trigger", Kafka.RESOURCE_KIND, NAMESPACE, CLUSTER_NAME)).onComplete(context.succeeding(v -> context.verify(() -> {
StatefulSet kafkaSts = client.apps().statefulSets().inNamespace(NAMESPACE).withName(KafkaCluster.kafkaClusterName(CLUSTER_NAME)).get();
kafkaSts.setStatus(new StatefulSetStatus());
assertThat(kafkaSts, is(notNullValue()));
assertThat(kafkaSts.getSpec().getTemplate().getMetadata().getAnnotations(), hasEntry(StatefulSetOperator.ANNO_STRIMZI_IO_GENERATION, "0"));
assertThat(kafkaSts.getSpec().getTemplate().getMetadata().getAnnotations(), hasEntry(Ca.ANNO_STRIMZI_IO_CLUSTER_CA_CERT_GENERATION, "0"));
assertThat(kafkaSts.getSpec().getTemplate().getMetadata().getAnnotations(), hasEntry(Ca.ANNO_STRIMZI_IO_CLIENTS_CA_CERT_GENERATION, "0"));
StatefulSet zkSts = client.apps().statefulSets().inNamespace(NAMESPACE).withName(ZookeeperCluster.zookeeperClusterName(CLUSTER_NAME)).get();
assertThat(zkSts, is(notNullValue()));
assertThat(zkSts.getSpec().getTemplate().getMetadata().getAnnotations(), hasEntry(StatefulSetOperator.ANNO_STRIMZI_IO_GENERATION, "0"));
assertThat(zkSts.getSpec().getTemplate().getMetadata().getAnnotations(), hasEntry(Ca.ANNO_STRIMZI_IO_CLUSTER_CA_CERT_GENERATION, "0"));
assertThat(client.configMaps().inNamespace(NAMESPACE).withName(KafkaCluster.metricAndLogConfigsName(CLUSTER_NAME)).get(), is(notNullValue()));
assertThat(client.configMaps().inNamespace(NAMESPACE).withName(ZookeeperCluster.zookeeperMetricAndLogConfigsName(CLUSTER_NAME)).get(), is(notNullValue()));
assertResourceRequirements(context, KafkaCluster.kafkaClusterName(CLUSTER_NAME));
assertThat(client.secrets().inNamespace(NAMESPACE).withName(KafkaCluster.clientsCaKeySecretName(CLUSTER_NAME)).get(), is(notNullValue()));
assertThat(client.secrets().inNamespace(NAMESPACE).withName(KafkaCluster.clientsCaCertSecretName(CLUSTER_NAME)).get(), is(notNullValue()));
assertThat(client.secrets().inNamespace(NAMESPACE).withName(KafkaCluster.clusterCaCertSecretName(CLUSTER_NAME)).get(), is(notNullValue()));
assertThat(client.secrets().inNamespace(NAMESPACE).withName(KafkaCluster.brokersSecretName(CLUSTER_NAME)).get(), is(notNullValue()));
assertThat(client.secrets().inNamespace(NAMESPACE).withName(ZookeeperCluster.nodesSecretName(CLUSTER_NAME)).get(), is(notNullValue()));
})));
}
use of io.fabric8.kubernetes.api.model.apps.StatefulSetStatus in project strimzi by strimzi.
the class StatefulSetMockBuilder method mockCreate.
@Override
protected void mockCreate(String resourceName, RollableScalableResource<StatefulSet> resource) {
when(resource.create(any(StatefulSet.class))).thenAnswer(cinvocation -> {
checkNotExists(resourceName);
StatefulSet argument = cinvocation.getArgument(0);
LOGGER.debug("create {} {} -> {}", resourceType, resourceName, argument);
StatefulSet value = copyResource(argument);
value.setStatus(new StatefulSetStatus());
db.put(resourceName, value);
for (int i = 0; i < argument.getSpec().getReplicas(); i++) {
final int podNum = i;
String podName = argument.getMetadata().getName() + "-" + podNum;
LOGGER.debug("create Pod {} because it's in StatefulSet {}", podName, resourceName);
mockPods.inNamespace(argument.getMetadata().getNamespace()).createOrReplace(doCreatePod(argument, podName));
if (value.getSpec().getVolumeClaimTemplates().size() > 0) {
for (PersistentVolumeClaim pvcTemplate : value.getSpec().getVolumeClaimTemplates()) {
String pvcName = pvcTemplate.getMetadata().getName() + "-" + podName;
if (mockPvcs.inNamespace(argument.getMetadata().getNamespace()).withName(pvcName).get() == null) {
LOGGER.debug("create Pvc {} because it's in VolumeClaimTemplate of StatefulSet {}", pvcName, resourceName);
PersistentVolumeClaim pvc = new PersistentVolumeClaimBuilder().withNewMetadata().withLabels(argument.getSpec().getSelector().getMatchLabels()).withNamespace(argument.getMetadata().getNamespace()).withName(pvcName).endMetadata().build();
mockPvcs.inNamespace(argument.getMetadata().getNamespace()).withName(pvcName).create(pvc);
}
}
}
}
return argument;
});
}
use of io.fabric8.kubernetes.api.model.apps.StatefulSetStatus in project strimzi-kafka-operator by strimzi.
the class StatefulSetMockBuilder method mockCreate.
@Override
protected void mockCreate(String resourceName, RollableScalableResource<StatefulSet> resource) {
when(resource.create(any(StatefulSet.class))).thenAnswer(cinvocation -> {
checkNotExists(resourceName);
StatefulSet argument = cinvocation.getArgument(0);
LOGGER.debug("create {} {} -> {}", resourceType, resourceName, argument);
StatefulSet value = copyResource(argument);
value.setStatus(new StatefulSetStatus());
db.put(resourceName, value);
for (int i = 0; i < argument.getSpec().getReplicas(); i++) {
final int podNum = i;
String podName = argument.getMetadata().getName() + "-" + podNum;
LOGGER.debug("create Pod {} because it's in StatefulSet {}", podName, resourceName);
mockPods.inNamespace(argument.getMetadata().getNamespace()).createOrReplace(doCreatePod(argument, podName));
if (value.getSpec().getVolumeClaimTemplates().size() > 0) {
for (PersistentVolumeClaim pvcTemplate : value.getSpec().getVolumeClaimTemplates()) {
String pvcName = pvcTemplate.getMetadata().getName() + "-" + podName;
if (mockPvcs.inNamespace(argument.getMetadata().getNamespace()).withName(pvcName).get() == null) {
LOGGER.debug("create Pvc {} because it's in VolumeClaimTemplate of StatefulSet {}", pvcName, resourceName);
PersistentVolumeClaim pvc = new PersistentVolumeClaimBuilder().withNewMetadata().withLabels(argument.getSpec().getSelector().getMatchLabels()).withNamespace(argument.getMetadata().getNamespace()).withName(pvcName).endMetadata().build();
mockPvcs.inNamespace(argument.getMetadata().getNamespace()).withName(pvcName).create(pvc);
}
}
}
}
return argument;
});
}
Aggregations