use of io.strimzi.test.mockkube2.MockKube2 in project strimzi by strimzi.
the class PartialRollingUpdateMockTest method beforeEach.
@BeforeEach
public void beforeEach(VertxTestContext context) throws InterruptedException, ExecutionException, TimeoutException {
this.cluster = new KafkaBuilder().withMetadata(new ObjectMetaBuilder().withName(CLUSTER_NAME).withNamespace(NAMESPACE).build()).withNewSpec().withNewKafka().withReplicas(5).withListeners(new GenericKafkaListenerBuilder().withName("plain").withPort(9092).withType(KafkaListenerType.INTERNAL).withTls(false).build(), new GenericKafkaListenerBuilder().withName("tls").withPort(9093).withType(KafkaListenerType.INTERNAL).withTls(true).build()).withNewPersistentClaimStorage().withSize("123").withStorageClass("foo").withDeleteClaim(true).endPersistentClaimStorage().endKafka().withNewZookeeper().withReplicas(3).withNewPersistentClaimStorage().withSize("123").withStorageClass("foo").withDeleteClaim(true).endPersistentClaimStorage().endZookeeper().endSpec().build();
// Configure the Kubernetes Mock
mockKube = new MockKube2.MockKube2Builder(client).withKafkaCrd().withInitialKafkas(cluster).withStrimziPodSetCrd().withDeploymentController().withPodController().withStatefulSetController().withServiceController().build();
mockKube.start();
ResourceOperatorSupplier supplier = supplier(client);
kco = new KafkaAssemblyOperator(vertx, new PlatformFeaturesAvailability(false, KubernetesVersion.V1_16), new MockCertManager(), new PasswordGenerator(10, "a", "a"), supplier, ResourceUtils.dummyClusterOperatorConfig(VERSIONS, 2_000));
LOGGER.info("Initial reconciliation");
CountDownLatch createAsync = new CountDownLatch(1);
kco.reconcile(new Reconciliation("initialization", Kafka.RESOURCE_KIND, NAMESPACE, CLUSTER_NAME)).onComplete(ar -> {
context.verify(() -> assertThat(ar.succeeded(), is(true)));
createAsync.countDown();
});
if (!createAsync.await(60, TimeUnit.SECONDS)) {
context.failNow(new Throwable("Test timeout"));
}
LOGGER.info("Initial reconciliation complete");
context.completeNow();
}
use of io.strimzi.test.mockkube2.MockKube2 in project strimzi by strimzi.
the class StrimziPodSetControllerMockTest method beforeEach.
@BeforeEach
public void beforeEach() {
// Configure the Kubernetes Mock
mockKube = new MockKube2.MockKube2Builder(client).withKafkaCrd().withStrimziPodSetCrd().withPodController().build();
mockKube.start();
vertx = Vertx.vertx();
kafkaOperator = new CrdOperator<>(vertx, client, Kafka.class, KafkaList.class, Kafka.RESOURCE_KIND);
podSetOperator = new StrimziPodSetOperator(vertx, client, 10_000L);
podOperator = new PodOperator(vertx, client);
kafkaOp().inNamespace(NAMESPACE).create(kafka(KAFKA_NAME, MATCHING_LABELS));
kafkaOp().inNamespace(NAMESPACE).create(kafka(OTHER_KAFKA_NAME, OTHER_LABELS));
startController();
}
use of io.strimzi.test.mockkube2.MockKube2 in project strimzi-kafka-operator by strimzi.
the class KafkaRebalanceAssemblyOperatorTest method beforeEach.
@BeforeEach
public void beforeEach(Vertx vertx) {
ccServer.reset();
// Configure the Kubernetes Mock
mockKube = new MockKube2.MockKube2Builder(client).withKafkaRebalanceCrd().build();
mockKube.start();
ResourceOperatorSupplier supplier = ResourceUtils.supplierWithMocks(false);
// Override to inject mocked cruise control address so real cruise control not required
kcrao = new KafkaRebalanceAssemblyOperator(vertx, supplier, ResourceUtils.dummyClusterOperatorConfig()) {
@Override
public String cruiseControlHost(String clusterName, String clusterNamespace) {
return HOST;
}
@Override
public CruiseControlApi cruiseControlClientProvider(Secret ccSecret, Secret ccApiSecret, boolean apiAuthEnabled, boolean apiSslEnabled) {
return new CruiseControlApiImpl(vertx, 1, ccSecret, ccApiSecret, true, true);
}
};
mockRebalanceOps = supplier.kafkaRebalanceOperator;
mockKafkaOps = supplier.kafkaOperator;
mockCmOps = supplier.configMapOperations;
mockSecretOps = supplier.secretOperations;
}
use of io.strimzi.test.mockkube2.MockKube2 in project strimzi-kafka-operator by strimzi.
the class KafkaAssemblyOperatorCustomCertMockTest method setup.
@BeforeEach
public void setup() {
kafka = createKafka();
// Configure the Kubernetes Mock
mockKube = new MockKube2.MockKube2Builder(client).withKafkaCrd().withInitialKafkas(kafka).withStrimziPodSetCrd().withPodController().withStatefulSetController().build();
mockKube.start();
client.secrets().inNamespace(namespace).create(getTlsSecret());
client.secrets().inNamespace(namespace).create(getExternalSecret());
Secret secret = new SecretBuilder().withNewMetadata().withNamespace(namespace).withName("testkafka-cluster-operator-certs").endMetadata().addToData("foo", "bar").build();
client.secrets().inNamespace(namespace).create(secret);
ResourceOperatorSupplier supplier = new ResourceOperatorSupplier(vertx, client, mock(ZookeeperLeaderFinder.class), mock(AdminClientProvider.class), mock(ZookeeperScalerProvider.class), mock(MetricsProvider.class), new PlatformFeaturesAvailability(false, KubernetesVersion.V1_20), 10000);
operator = new MockKafkaAssemblyOperator(vertx, new PlatformFeaturesAvailability(false, kubernetesVersion), certManager, passwordGenerator, supplier, config);
}
use of io.strimzi.test.mockkube2.MockKube2 in project strimzi-kafka-operator by strimzi.
the class PartialRollingUpdateMockTest method beforeEach.
@BeforeEach
public void beforeEach(VertxTestContext context) throws InterruptedException, ExecutionException, TimeoutException {
this.cluster = new KafkaBuilder().withMetadata(new ObjectMetaBuilder().withName(CLUSTER_NAME).withNamespace(NAMESPACE).build()).withNewSpec().withNewKafka().withReplicas(5).withListeners(new GenericKafkaListenerBuilder().withName("plain").withPort(9092).withType(KafkaListenerType.INTERNAL).withTls(false).build(), new GenericKafkaListenerBuilder().withName("tls").withPort(9093).withType(KafkaListenerType.INTERNAL).withTls(true).build()).withNewPersistentClaimStorage().withSize("123").withStorageClass("foo").withDeleteClaim(true).endPersistentClaimStorage().endKafka().withNewZookeeper().withReplicas(3).withNewPersistentClaimStorage().withSize("123").withStorageClass("foo").withDeleteClaim(true).endPersistentClaimStorage().endZookeeper().endSpec().build();
// Configure the Kubernetes Mock
mockKube = new MockKube2.MockKube2Builder(client).withKafkaCrd().withInitialKafkas(cluster).withStrimziPodSetCrd().withDeploymentController().withPodController().withStatefulSetController().withServiceController().build();
mockKube.start();
ResourceOperatorSupplier supplier = supplier(client);
kco = new KafkaAssemblyOperator(vertx, new PlatformFeaturesAvailability(false, KubernetesVersion.V1_16), new MockCertManager(), new PasswordGenerator(10, "a", "a"), supplier, ResourceUtils.dummyClusterOperatorConfig(VERSIONS, 2_000));
LOGGER.info("Initial reconciliation");
CountDownLatch createAsync = new CountDownLatch(1);
kco.reconcile(new Reconciliation("initialization", Kafka.RESOURCE_KIND, NAMESPACE, CLUSTER_NAME)).onComplete(ar -> {
context.verify(() -> assertThat(ar.succeeded(), is(true)));
createAsync.countDown();
});
if (!createAsync.await(60, TimeUnit.SECONDS)) {
context.failNow(new Throwable("Test timeout"));
}
LOGGER.info("Initial reconciliation complete");
context.completeNow();
}
Aggregations