use of io.strimzi.api.kafka.model.KafkaConnector in project strimzi-kafka-operator by strimzi.
the class KafkaConnectorIT method test.
@Test
public void test(VertxTestContext context) {
KafkaConnectApiImpl connectClient = new KafkaConnectApiImpl(vertx);
PlatformFeaturesAvailability pfa = new PlatformFeaturesAvailability(false, KubernetesVersion.V1_20);
String namespace = "ns";
String connectorName = "my-connector";
LinkedHashMap<String, Object> config = new LinkedHashMap<>();
config.put(TestingConnector.START_TIME_MS, 1_000);
config.put(TestingConnector.STOP_TIME_MS, 0);
config.put(TestingConnector.TASK_START_TIME_MS, 1_000);
config.put(TestingConnector.TASK_STOP_TIME_MS, 0);
config.put(TestingConnector.TASK_POLL_TIME_MS, 1_000);
config.put(TestingConnector.TASK_POLL_RECORDS, 100);
config.put(TestingConnector.NUM_PARTITIONS, 1);
config.put(TestingConnector.TOPIC_NAME, "my-topic");
KafkaConnector connector = createKafkaConnector(namespace, connectorName, config);
Crds.kafkaConnectorOperation(client).inNamespace(namespace).create(connector);
MetricsProvider metrics = new MicrometerMetricsProvider();
ResourceOperatorSupplier ros = new ResourceOperatorSupplier(vertx, client, 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(), metrics, pfa, 10_000);
KafkaConnectAssemblyOperator operator = new KafkaConnectAssemblyOperator(vertx, pfa, ros, ClusterOperatorConfig.fromMap(Collections.emptyMap(), KafkaVersionTestUtils.getKafkaVersionLookup()), connect -> new KafkaConnectApiImpl(vertx), connectCluster.getPort(2)) {
};
Checkpoint async = context.checkpoint();
operator.reconcileConnectorAndHandleResult(new Reconciliation("test", "KafkaConnect", namespace, "bogus"), "localhost", connectClient, true, connectorName, connector).onComplete(context.succeeding(v -> assertConnectorIsRunning(context, client, namespace, connectorName))).compose(v -> {
config.remove(TestingConnector.START_TIME_MS, 1_000);
config.put(TestingConnector.START_TIME_MS, 1_000);
Crds.kafkaConnectorOperation(client).inNamespace(namespace).withName(connectorName).patch(createKafkaConnector(namespace, connectorName, config));
return operator.reconcileConnectorAndHandleResult(new Reconciliation("test", "KafkaConnect", namespace, "bogus"), "localhost", connectClient, true, connectorName, connector);
}).onComplete(context.succeeding(v -> context.verify(() -> {
assertConnectorIsRunning(context, client, namespace, connectorName);
// Assert metrics from Connector Operator
MeterRegistry registry = metrics.meterRegistry();
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations").tag("kind", KafkaConnector.RESOURCE_KIND).counter().count(), CoreMatchers.is(2.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.successful").tag("kind", KafkaConnector.RESOURCE_KIND).counter().count(), CoreMatchers.is(2.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", KafkaConnector.RESOURCE_KIND).timer().count(), CoreMatchers.is(2L));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", KafkaConnector.RESOURCE_KIND).timer().totalTime(TimeUnit.MILLISECONDS), greaterThan(0.0));
async.flag();
})));
}
use of io.strimzi.api.kafka.model.KafkaConnector in project strimzi-kafka-operator by strimzi.
the class KafkaConnectorIT method assertConnectorIsRunning.
private void assertConnectorIsRunning(VertxTestContext context, KubernetesClient client, String namespace, String connectorName) {
context.verify(() -> {
KafkaConnector kafkaConnector = Crds.kafkaConnectorOperation(client).inNamespace(namespace).withName(connectorName).get();
assertThat(kafkaConnector, notNullValue());
assertThat(kafkaConnector.getStatus(), notNullValue());
assertThat(kafkaConnector.getStatus().getTasksMax(), is(1));
assertThat(kafkaConnector.getStatus().getConnectorStatus(), notNullValue());
assertThat(kafkaConnector.getStatus().getConnectorStatus().get("connector"), instanceOf(Map.class));
assertThat(((Map) kafkaConnector.getStatus().getConnectorStatus().get("connector")).get("state"), is("RUNNING"));
});
}
use of io.strimzi.api.kafka.model.KafkaConnector in project cos-fleetshard by bf2fc6cc711aee1a0c2a.
the class DebeziumOperandController method status.
@Override
public void status(ManagedConnector connector) {
KafkaConnector kctr = lookupConnector(getKubernetesClient(), connector).filter(_kctr -> _kctr.getStatus() != null).orElse(null);
KafkaConnect kc = lookupKafkaConnect(getKubernetesClient(), connector).filter(_kc -> _kc.getStatus() != null).orElse(null);
computeStatus(connector.getStatus().getConnectorStatus(), kc, kctr);
}
use of io.strimzi.api.kafka.model.KafkaConnector in project cos-fleetshard by bf2fc6cc711aee1a0c2a.
the class KafkaConnectorSteps method kc_config_contains.
@And("the kctr has config containing:")
public void kc_config_contains(DataTable table) {
KafkaConnector res = kctr();
assertThat(res).isNotNull();
assertThatDataTable(table, ctx::resolvePlaceholders).matches(res.getSpec().getConfig());
}
use of io.strimzi.api.kafka.model.KafkaConnector in project strimzi-kafka-operator by strimzi.
the class ConnectorMockTest method testConnectorResourceMetrics.
@Test
void testConnectorResourceMetrics(VertxTestContext context) {
String connectName1 = "cluster1";
String connectName2 = "cluster2";
String connectorName1 = "connector1";
String connectorName2 = "connector2";
KafkaConnect kafkaConnect1 = new KafkaConnectBuilder().withNewMetadata().withNamespace(NAMESPACE).withName(connectName1).addToAnnotations(Annotations.STRIMZI_IO_USE_CONNECTOR_RESOURCES, "true").endMetadata().withNewSpec().withReplicas(1).endSpec().build();
KafkaConnect kafkaConnect2 = new KafkaConnectBuilder(kafkaConnect1).editMetadata().withName(connectName2).endMetadata().build();
Crds.kafkaConnectOperation(client).inNamespace(NAMESPACE).create(kafkaConnect1);
Crds.kafkaConnectOperation(client).inNamespace(NAMESPACE).create(kafkaConnect2);
waitForConnectReady(connectName1);
waitForConnectReady(connectName2);
KafkaConnector connector1 = defaultKafkaConnectorBuilder().editMetadata().withName(connectorName1).addToLabels(Labels.STRIMZI_CLUSTER_LABEL, connectName1).addToAnnotations(Annotations.ANNO_STRIMZI_IO_PAUSE_RECONCILIATION, "true").endMetadata().build();
KafkaConnector connector2 = defaultKafkaConnectorBuilder().editMetadata().withName(connectorName2).addToLabels(Labels.STRIMZI_CLUSTER_LABEL, connectName2).addToAnnotations(Annotations.ANNO_STRIMZI_IO_PAUSE_RECONCILIATION, "true").endMetadata().build();
Crds.kafkaConnectorOperation(client).inNamespace(NAMESPACE).create(connector1);
Crds.kafkaConnectorOperation(client).inNamespace(NAMESPACE).create(connector2);
waitForConnectorPaused(connectorName1);
waitForConnectorPaused(connectorName2);
MeterRegistry meterRegistry = metricsProvider.meterRegistry();
Tags tags = Tags.of("kind", KafkaConnector.RESOURCE_KIND, "namespace", NAMESPACE);
Promise<Void> reconciled1 = Promise.promise();
Promise<Void> reconciled2 = Promise.promise();
kafkaConnectOperator.reconcileAll("test", NAMESPACE, ignored -> reconciled1.complete());
Checkpoint async = context.checkpoint();
reconciled1.future().onComplete(context.succeeding(v -> context.verify(() -> {
Gauge resources = meterRegistry.get("strimzi.resources").tags(tags).gauge();
assertThat(resources.value(), is(2.0));
Gauge resourcesPaused = meterRegistry.get("strimzi.resources.paused").tags(tags).gauge();
assertThat(resourcesPaused.value(), is(2.0));
Crds.kafkaConnectorOperation(client).inNamespace(NAMESPACE).delete(connector1);
waitForConnectorDeleted(connectorName1);
kafkaConnectOperator.reconcileAll("test", NAMESPACE, ignored -> reconciled2.complete());
reconciled2.future().onComplete(context.succeeding(v1 -> context.verify(() -> {
assertThat(resources.value(), is(1.0));
assertThat(resourcesPaused.value(), is(1.0));
async.flag();
})));
})));
}
Aggregations