use of io.strimzi.api.kafka.model.KafkaMirrorMaker2 in project strimzi-kafka-operator by strimzi.
the class KafkaMirrorMaker2AssemblyOperatorMockTest method createMirrorMaker2Cluster.
private Future<Void> createMirrorMaker2Cluster(VertxTestContext context, KafkaConnectApi kafkaConnectApi, boolean reconciliationPaused) {
PlatformFeaturesAvailability pfa = new PlatformFeaturesAvailability(true, KubernetesVersion.V1_16);
ResourceOperatorSupplier supplier = new ResourceOperatorSupplier(vertx, this.mockClient, new ZookeeperLeaderFinder(vertx, // Retry up to 3 times (4 attempts), with overall max delay of 35000ms
() -> new BackOff(5_000, 2, 4)), new DefaultAdminClientProvider(), new DefaultZookeeperScalerProvider(), ResourceUtils.metricsProvider(), pfa, FeatureGates.NONE, 60_000L);
ClusterOperatorConfig config = ResourceUtils.dummyClusterOperatorConfig(VERSIONS);
kco = new KafkaMirrorMaker2AssemblyOperator(vertx, pfa, supplier, config, foo -> kafkaConnectApi);
LOGGER.info("Reconciling initially -> create");
Promise<Void> created = Promise.promise();
kco.reconcile(new Reconciliation("test-trigger", KafkaMirrorMaker2.RESOURCE_KIND, NAMESPACE, CLUSTER_NAME)).onComplete(context.succeeding(ar -> context.verify(() -> {
if (!reconciliationPaused) {
assertThat(mockClient.apps().deployments().inNamespace(NAMESPACE).withName(KafkaMirrorMaker2Resources.deploymentName(CLUSTER_NAME)).get(), is(notNullValue()));
assertThat(mockClient.configMaps().inNamespace(NAMESPACE).withName(KafkaMirrorMaker2Resources.metricsAndLogConfigMapName(CLUSTER_NAME)).get(), is(notNullValue()));
assertThat(mockClient.services().inNamespace(NAMESPACE).withName(KafkaMirrorMaker2Resources.serviceName(CLUSTER_NAME)).get(), is(notNullValue()));
assertThat(mockClient.policy().v1beta1().podDisruptionBudget().inNamespace(NAMESPACE).withName(KafkaMirrorMaker2Resources.deploymentName(CLUSTER_NAME)).get(), is(notNullValue()));
} else {
assertThat(mockClient.apps().deployments().inNamespace(NAMESPACE).withName(KafkaMirrorMaker2Resources.deploymentName(CLUSTER_NAME)).get(), is(nullValue()));
verify(mockClient, never()).resources(KafkaMirrorMaker2.class);
}
created.complete();
})));
return created.future();
}
use of io.strimzi.api.kafka.model.KafkaMirrorMaker2 in project strimzi-kafka-operator by strimzi.
the class KafkaMirrorMaker2Templates method kafkaMirrorMaker2WithMetrics.
public static KafkaMirrorMaker2Builder kafkaMirrorMaker2WithMetrics(String name, String targetClusterName, String sourceClusterName, int kafkaMirrorMaker2Replicas) {
KafkaMirrorMaker2 kafkaMirrorMaker2 = getKafkaMirrorMaker2FromYaml(Constants.PATH_TO_KAFKA_MIRROR_MAKER_2_METRICS_CONFIG);
ConfigMap metricsCm = TestUtils.configMapFromYaml(Constants.PATH_TO_KAFKA_MIRROR_MAKER_2_METRICS_CONFIG, "mirror-maker-2-metrics");
KubeClusterResource.kubeClient().getClient().configMaps().inNamespace(kubeClient().getNamespace()).createOrReplace(metricsCm);
return defaultKafkaMirrorMaker2(kafkaMirrorMaker2, name, targetClusterName, sourceClusterName, kafkaMirrorMaker2Replicas, false);
}
use of io.strimzi.api.kafka.model.KafkaMirrorMaker2 in project strimzi-kafka-operator by strimzi.
the class MirrorMaker2IsolatedST method testConfigureDeploymentStrategy.
@ParallelNamespaceTest
void testConfigureDeploymentStrategy(ExtensionContext extensionContext) {
final String namespaceName = StUtils.getNamespaceBasedOnRbac(INFRA_NAMESPACE, extensionContext);
String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
String kafkaClusterSourceName = clusterName + "-source";
String kafkaClusterTargetName = clusterName + "-target";
// Deploy source kafka
resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(kafkaClusterSourceName, 1, 1).build());
// Deploy target kafka
resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(kafkaClusterTargetName, 1, 1).build());
resourceManager.createResource(extensionContext, KafkaMirrorMaker2Templates.kafkaMirrorMaker2(clusterName, kafkaClusterTargetName, kafkaClusterSourceName, 1, false).editSpec().editOrNewTemplate().editOrNewDeployment().withDeploymentStrategy(DeploymentStrategy.RECREATE).endDeployment().endTemplate().endSpec().build());
String mm2DepName = KafkaMirrorMaker2Resources.deploymentName(clusterName);
LOGGER.info("Adding label to MirrorMaker2 resource, the CR should be recreated");
KafkaMirrorMaker2Resource.replaceKafkaMirrorMaker2ResourceInSpecificNamespace(clusterName, mm2 -> mm2.getMetadata().setLabels(Collections.singletonMap("some", "label")), namespaceName);
DeploymentUtils.waitForDeploymentAndPodsReady(namespaceName, mm2DepName, 1);
KafkaMirrorMaker2 kmm2 = KafkaMirrorMaker2Resource.kafkaMirrorMaker2Client().inNamespace(namespaceName).withName(clusterName).get();
LOGGER.info("Checking that observed gen. is still on 1 (recreation) and new label is present");
assertThat(kmm2.getStatus().getObservedGeneration(), is(1L));
assertThat(kmm2.getMetadata().getLabels().toString(), containsString("some=label"));
assertThat(kmm2.getSpec().getTemplate().getDeployment().getDeploymentStrategy(), is(DeploymentStrategy.RECREATE));
LOGGER.info("Changing deployment strategy to {}", DeploymentStrategy.ROLLING_UPDATE);
KafkaMirrorMaker2Resource.replaceKafkaMirrorMaker2ResourceInSpecificNamespace(clusterName, mm2 -> mm2.getSpec().getTemplate().getDeployment().setDeploymentStrategy(DeploymentStrategy.ROLLING_UPDATE), namespaceName);
KafkaMirrorMaker2Utils.waitForKafkaMirrorMaker2Ready(namespaceName, clusterName);
LOGGER.info("Adding another label to MirrorMaker2 resource, pods should be rolled");
KafkaMirrorMaker2Resource.replaceKafkaMirrorMaker2ResourceInSpecificNamespace(clusterName, mm2 -> mm2.getMetadata().getLabels().put("another", "label"), namespaceName);
DeploymentUtils.waitForDeploymentAndPodsReady(namespaceName, mm2DepName, 1);
LOGGER.info("Checking that observed gen. higher (rolling update) and label is changed");
kmm2 = KafkaMirrorMaker2Resource.kafkaMirrorMaker2Client().inNamespace(namespaceName).withName(clusterName).get();
assertThat(kmm2.getStatus().getObservedGeneration(), is(2L));
assertThat(kmm2.getMetadata().getLabels().toString(), containsString("another=label"));
assertThat(kmm2.getSpec().getTemplate().getDeployment().getDeploymentStrategy(), is(DeploymentStrategy.ROLLING_UPDATE));
}
use of io.strimzi.api.kafka.model.KafkaMirrorMaker2 in project strimzi-kafka-operator by strimzi.
the class CustomResourceStatusIsolatedST method testKafkaMirrorMaker2WrongBootstrap.
@ParallelTest
@Tag(MIRROR_MAKER2)
void testKafkaMirrorMaker2WrongBootstrap(ExtensionContext extensionContext) {
String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
String mirrorMaker2Name = clusterName + "-mirror-maker-2";
KafkaMirrorMaker2 kafkaMirrorMaker2 = KafkaMirrorMaker2Templates.kafkaMirrorMaker2(mirrorMaker2Name, "non-existing-source", "non-existing-target", 1, false).build();
resourceManager.createResource(extensionContext, false, kafkaMirrorMaker2);
KafkaMirrorMaker2Utils.waitForKafkaMirrorMaker2NotReady(mirrorMaker2Name);
// delete
KafkaMirrorMaker2Resource.kafkaMirrorMaker2Client().inNamespace(Constants.INFRA_NAMESPACE).withName(mirrorMaker2Name).withPropagationPolicy(DeletionPropagation.FOREGROUND).delete();
DeploymentUtils.waitForDeploymentDeletion(KafkaMirrorMaker2Resources.deploymentName(mirrorMaker2Name));
}
use of io.strimzi.api.kafka.model.KafkaMirrorMaker2 in project strimzi-kafka-operator by strimzi.
the class KafkaMirrorMaker2ClusterTest method testExternalConfigurationInvalidVolumes.
@ParallelTest
public void testExternalConfigurationInvalidVolumes() {
ExternalConfigurationVolumeSource volume = new ExternalConfigurationVolumeSourceBuilder().withName("my-volume").withConfigMap(new ConfigMapVolumeSourceBuilder().withName("my-map").build()).withSecret(new SecretVolumeSourceBuilder().withSecretName("my-secret").build()).build();
KafkaMirrorMaker2 resource = new KafkaMirrorMaker2Builder(this.resource).editSpec().withNewExternalConfiguration().withVolumes(volume).endExternalConfiguration().endSpec().build();
KafkaMirrorMaker2Cluster kmm2 = KafkaMirrorMaker2Cluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
// Check Deployment
Deployment dep = kmm2.generateDeployment(emptyMap(), true, null, null);
List<Volume> volumes = dep.getSpec().getTemplate().getSpec().getVolumes();
List<Volume> selected = volumes.stream().filter(vol -> vol.getName().equals(KafkaMirrorMaker2Cluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume")).collect(Collectors.toList());
assertThat(selected.size(), is(0));
List<VolumeMount> volumeMounths = getContainer(dep).getVolumeMounts();
List<VolumeMount> selectedVolumeMounths = volumeMounths.stream().filter(vol -> vol.getName().equals(KafkaMirrorMaker2Cluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume")).collect(Collectors.toList());
assertThat(selected.size(), is(0));
}
Aggregations