Search in sources :

Example 1 with DefaultAdminClientProvider

use of io.strimzi.operator.common.DefaultAdminClientProvider in project strimzi by strimzi.

the class KafkaConnectAssemblyOperatorMockTest method createConnectCluster.

private Future<Void> createConnectCluster(VertxTestContext context, KafkaConnectApi kafkaConnectApi, boolean reconciliationPaused) {
    PlatformFeaturesAvailability pfa = new PlatformFeaturesAvailability(true, KubernetesVersion.V1_21);
    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);
    this.kco = new KafkaConnectAssemblyOperator(vertx, pfa, supplier, config, foo -> kafkaConnectApi);
    Promise created = Promise.promise();
    LOGGER.info("Reconciling initially -> create");
    kco.reconcile(new Reconciliation("test-trigger", KafkaConnect.RESOURCE_KIND, NAMESPACE, CLUSTER_NAME)).onComplete(context.succeeding(v -> context.verify(() -> {
        if (!reconciliationPaused) {
            assertThat(mockClient.apps().deployments().inNamespace(NAMESPACE).withName(KafkaConnectResources.deploymentName(CLUSTER_NAME)).get(), is(notNullValue()));
            assertThat(mockClient.configMaps().inNamespace(NAMESPACE).withName(KafkaConnectResources.metricsAndLogConfigMapName(CLUSTER_NAME)).get(), is(notNullValue()));
            assertThat(mockClient.services().inNamespace(NAMESPACE).withName(KafkaConnectResources.serviceName(CLUSTER_NAME)).get(), is(notNullValue()));
            assertThat(mockClient.policy().v1().podDisruptionBudget().inNamespace(NAMESPACE).withName(KafkaConnectResources.deploymentName(CLUSTER_NAME)).get(), is(notNullValue()));
        } else {
            assertThat(mockClient.apps().deployments().inNamespace(NAMESPACE).withName(KafkaConnectResources.deploymentName(CLUSTER_NAME)).get(), is(nullValue()));
            verify(mockClient, never()).resources(KafkaConnect.class);
        }
        created.complete();
    })));
    return created.future();
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) KafkaConnectorList(io.strimzi.api.kafka.KafkaConnectorList) KafkaConnector(io.strimzi.api.kafka.model.KafkaConnector) MockKube(io.strimzi.test.mockkube.MockKube) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) AfterAll(org.junit.jupiter.api.AfterAll) Resource(io.fabric8.kubernetes.client.dsl.Resource) DefaultAdminClientProvider(io.strimzi.operator.common.DefaultAdminClientProvider) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) BeforeAll(org.junit.jupiter.api.BeforeAll) ResourceOperatorSupplier(io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier) ResourceUtils(io.strimzi.operator.cluster.ResourceUtils) KafkaConnect(io.strimzi.api.kafka.model.KafkaConnect) Collections.emptyList(java.util.Collections.emptyList) KafkaVersion(io.strimzi.operator.cluster.model.KafkaVersion) KafkaConnectBuilder(io.strimzi.api.kafka.model.KafkaConnectBuilder) VertxExtension(io.vertx.junit5.VertxExtension) Future(io.vertx.core.Future) Test(org.junit.jupiter.api.Test) List(java.util.List) Logger(org.apache.logging.log4j.Logger) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Checkpoint(io.vertx.junit5.Checkpoint) Condition(io.strimzi.api.kafka.model.status.Condition) KafkaConnectList(io.strimzi.api.kafka.KafkaConnectList) PlatformFeaturesAvailability(io.strimzi.operator.PlatformFeaturesAvailability) ClusterOperatorConfig(io.strimzi.operator.cluster.ClusterOperatorConfig) Mockito.mock(org.mockito.Mockito.mock) VertxTestContext(io.vertx.junit5.VertxTestContext) Assertions.fail(org.junit.jupiter.api.Assertions.fail) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BackOff(io.strimzi.operator.common.BackOff) Crds(io.strimzi.api.kafka.Crds) FeatureGates(io.strimzi.operator.cluster.FeatureGates) KafkaVersionTestUtils(io.strimzi.operator.cluster.KafkaVersionTestUtils) ZookeeperLeaderFinder(io.strimzi.operator.cluster.operator.resource.ZookeeperLeaderFinder) TestUtils(io.strimzi.test.TestUtils) Collections.singletonMap(java.util.Collections.singletonMap) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) ObjectMetaBuilder(io.fabric8.kubernetes.api.model.ObjectMetaBuilder) Promise(io.vertx.core.Promise) KubernetesVersion(io.strimzi.operator.KubernetesVersion) Vertx(io.vertx.core.Vertx) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) Reconciliation(io.strimzi.operator.common.Reconciliation) AfterEach(org.junit.jupiter.api.AfterEach) Mockito.never(org.mockito.Mockito.never) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultZookeeperScalerProvider(io.strimzi.operator.cluster.operator.resource.DefaultZookeeperScalerProvider) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) KafkaConnectResources(io.strimzi.api.kafka.model.KafkaConnectResources) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ResourceOperatorSupplier(io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier) Promise(io.vertx.core.Promise) PlatformFeaturesAvailability(io.strimzi.operator.PlatformFeaturesAvailability) ClusterOperatorConfig(io.strimzi.operator.cluster.ClusterOperatorConfig) Reconciliation(io.strimzi.operator.common.Reconciliation) ZookeeperLeaderFinder(io.strimzi.operator.cluster.operator.resource.ZookeeperLeaderFinder) DefaultZookeeperScalerProvider(io.strimzi.operator.cluster.operator.resource.DefaultZookeeperScalerProvider) BackOff(io.strimzi.operator.common.BackOff) DefaultAdminClientProvider(io.strimzi.operator.common.DefaultAdminClientProvider)

Example 2 with DefaultAdminClientProvider

use of io.strimzi.operator.common.DefaultAdminClientProvider in project strimzi-kafka-operator by strimzi.

the class ConnectorMockTest method setup.

@SuppressWarnings({ "checkstyle:MethodLength" })
@BeforeEach
public void setup(VertxTestContext testContext) {
    vertx = Vertx.vertx();
    client = new MockKube().withCustomResourceDefinition(Crds.kafkaConnect(), KafkaConnect.class, KafkaConnectList.class, KafkaConnect::getStatus, KafkaConnect::setStatus).end().withCustomResourceDefinition(Crds.kafkaConnector(), KafkaConnector.class, KafkaConnectorList.class, KafkaConnector::getStatus, KafkaConnector::setStatus).end().build();
    PlatformFeaturesAvailability pfa = new PlatformFeaturesAvailability(true, KubernetesVersion.V1_18);
    setupMockConnectAPI();
    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(), ResourceUtils.metricsProvider(), pfa, FeatureGates.NONE, 10_000);
    ClusterOperatorConfig config = ClusterOperatorConfig.fromMap(map(ClusterOperatorConfig.STRIMZI_KAFKA_IMAGES, KafkaVersionTestUtils.getKafkaImagesEnvVarString(), ClusterOperatorConfig.STRIMZI_KAFKA_CONNECT_IMAGES, KafkaVersionTestUtils.getKafkaConnectImagesEnvVarString(), ClusterOperatorConfig.STRIMZI_KAFKA_MIRROR_MAKER_2_IMAGES, KafkaVersionTestUtils.getKafkaMirrorMaker2ImagesEnvVarString(), ClusterOperatorConfig.STRIMZI_FULL_RECONCILIATION_INTERVAL_MS, Long.toString(Long.MAX_VALUE)), KafkaVersionTestUtils.getKafkaVersionLookup());
    kafkaConnectOperator = new KafkaConnectAssemblyOperator(vertx, pfa, ros, config, x -> api);
    Checkpoint async = testContext.checkpoint();
    // Fail test if watcher closes for any reason
    kafkaConnectOperator.createWatch(NAMESPACE, e -> testContext.failNow(e)).onComplete(testContext.succeeding()).compose(watch -> AbstractConnectOperator.createConnectorWatch(kafkaConnectOperator, NAMESPACE, null)).onComplete(testContext.succeeding(v -> async.flag()));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) KafkaConnectorList(io.strimzi.api.kafka.KafkaConnectorList) BeforeEach(org.junit.jupiter.api.BeforeEach) ConnectorPluginBuilder(io.strimzi.api.kafka.model.connect.ConnectorPluginBuilder) OrderedProperties(io.strimzi.operator.common.model.OrderedProperties) TestUtils.waitFor(io.strimzi.test.TestUtils.waitFor) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Annotations(io.strimzi.operator.common.Annotations) TimeoutException(java.util.concurrent.TimeoutException) KafkaConnector(io.strimzi.api.kafka.model.KafkaConnector) MockKube(io.strimzi.test.mockkube.MockKube) Collections.singletonList(java.util.Collections.singletonList) Resource(io.fabric8.kubernetes.client.dsl.Resource) DefaultAdminClientProvider(io.strimzi.operator.common.DefaultAdminClientProvider) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Map(java.util.Map) Mockito.atLeast(org.mockito.Mockito.atLeast) ResourceOperatorSupplier(io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier) JsonObject(io.vertx.core.json.JsonObject) ResourceUtils(io.strimzi.operator.cluster.ResourceUtils) KafkaConnect(io.strimzi.api.kafka.model.KafkaConnect) ConnectTimeoutException(io.netty.channel.ConnectTimeoutException) Predicate(java.util.function.Predicate) Mockito.atLeastOnce(org.mockito.Mockito.atLeastOnce) KafkaConnectBuilder(io.strimzi.api.kafka.model.KafkaConnectBuilder) VertxExtension(io.vertx.junit5.VertxExtension) Future(io.vertx.core.Future) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) Objects(java.util.Objects) KafkaConnectCluster(io.strimzi.operator.cluster.model.KafkaConnectCluster) List(java.util.List) Labels(io.strimzi.operator.common.model.Labels) Logger(org.apache.logging.log4j.Logger) Checkpoint(io.vertx.junit5.Checkpoint) Condition(io.strimzi.api.kafka.model.status.Condition) KafkaConnectList(io.strimzi.api.kafka.KafkaConnectList) PlatformFeaturesAvailability(io.strimzi.operator.PlatformFeaturesAvailability) ClusterOperatorConfig(io.strimzi.operator.cluster.ClusterOperatorConfig) CustomResource(io.fabric8.kubernetes.client.CustomResource) Mockito.mock(org.mockito.Mockito.mock) VertxTestContext(io.vertx.junit5.VertxTestContext) Assertions.fail(org.junit.jupiter.api.Assertions.fail) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BackOff(io.strimzi.operator.common.BackOff) HashMap(java.util.HashMap) Crds(io.strimzi.api.kafka.Crds) FeatureGates(io.strimzi.operator.cluster.FeatureGates) KafkaVersionTestUtils(io.strimzi.operator.cluster.KafkaVersionTestUtils) ZookeeperLeaderFinder(io.strimzi.operator.cluster.operator.resource.ZookeeperLeaderFinder) TestUtils(io.strimzi.test.TestUtils) Status(io.strimzi.api.kafka.model.status.Status) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) KafkaConnectorBuilder(io.strimzi.api.kafka.model.KafkaConnectorBuilder) TestUtils.map(io.strimzi.test.TestUtils.map) Collections.emptyMap(java.util.Collections.emptyMap) Matchers.empty(org.hamcrest.Matchers.empty) KubernetesVersion(io.strimzi.operator.KubernetesVersion) Vertx(io.vertx.core.Vertx) ConnectorPlugin(io.strimzi.api.kafka.model.connect.ConnectorPlugin) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) Reconciliation(io.strimzi.operator.common.Reconciliation) AfterEach(org.junit.jupiter.api.AfterEach) Mockito.never(org.mockito.Mockito.never) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultZookeeperScalerProvider(io.strimzi.operator.cluster.operator.resource.DefaultZookeeperScalerProvider) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) KafkaConnectResources(io.strimzi.api.kafka.model.KafkaConnectResources) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ClusterOperatorConfig(io.strimzi.operator.cluster.ClusterOperatorConfig) KafkaConnect(io.strimzi.api.kafka.model.KafkaConnect) BackOff(io.strimzi.operator.common.BackOff) ResourceOperatorSupplier(io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier) MockKube(io.strimzi.test.mockkube.MockKube) KafkaConnectorList(io.strimzi.api.kafka.KafkaConnectorList) Checkpoint(io.vertx.junit5.Checkpoint) PlatformFeaturesAvailability(io.strimzi.operator.PlatformFeaturesAvailability) KafkaConnector(io.strimzi.api.kafka.model.KafkaConnector) KafkaConnectList(io.strimzi.api.kafka.KafkaConnectList) ZookeeperLeaderFinder(io.strimzi.operator.cluster.operator.resource.ZookeeperLeaderFinder) DefaultZookeeperScalerProvider(io.strimzi.operator.cluster.operator.resource.DefaultZookeeperScalerProvider) DefaultAdminClientProvider(io.strimzi.operator.common.DefaultAdminClientProvider) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with DefaultAdminClientProvider

use of io.strimzi.operator.common.DefaultAdminClientProvider in project strimzi-kafka-operator by strimzi.

the class KafkaConnectAssemblyOperatorMockTest method createConnectCluster.

private Future<Void> createConnectCluster(VertxTestContext context, KafkaConnectApi kafkaConnectApi, boolean reconciliationPaused) {
    PlatformFeaturesAvailability pfa = new PlatformFeaturesAvailability(true, KubernetesVersion.V1_21);
    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);
    this.kco = new KafkaConnectAssemblyOperator(vertx, pfa, supplier, config, foo -> kafkaConnectApi);
    Promise created = Promise.promise();
    LOGGER.info("Reconciling initially -> create");
    kco.reconcile(new Reconciliation("test-trigger", KafkaConnect.RESOURCE_KIND, NAMESPACE, CLUSTER_NAME)).onComplete(context.succeeding(v -> context.verify(() -> {
        if (!reconciliationPaused) {
            assertThat(mockClient.apps().deployments().inNamespace(NAMESPACE).withName(KafkaConnectResources.deploymentName(CLUSTER_NAME)).get(), is(notNullValue()));
            assertThat(mockClient.configMaps().inNamespace(NAMESPACE).withName(KafkaConnectResources.metricsAndLogConfigMapName(CLUSTER_NAME)).get(), is(notNullValue()));
            assertThat(mockClient.services().inNamespace(NAMESPACE).withName(KafkaConnectResources.serviceName(CLUSTER_NAME)).get(), is(notNullValue()));
            assertThat(mockClient.policy().v1().podDisruptionBudget().inNamespace(NAMESPACE).withName(KafkaConnectResources.deploymentName(CLUSTER_NAME)).get(), is(notNullValue()));
        } else {
            assertThat(mockClient.apps().deployments().inNamespace(NAMESPACE).withName(KafkaConnectResources.deploymentName(CLUSTER_NAME)).get(), is(nullValue()));
            verify(mockClient, never()).resources(KafkaConnect.class);
        }
        created.complete();
    })));
    return created.future();
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) KafkaConnectorList(io.strimzi.api.kafka.KafkaConnectorList) KafkaConnector(io.strimzi.api.kafka.model.KafkaConnector) MockKube(io.strimzi.test.mockkube.MockKube) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) AfterAll(org.junit.jupiter.api.AfterAll) Resource(io.fabric8.kubernetes.client.dsl.Resource) DefaultAdminClientProvider(io.strimzi.operator.common.DefaultAdminClientProvider) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) BeforeAll(org.junit.jupiter.api.BeforeAll) ResourceOperatorSupplier(io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier) ResourceUtils(io.strimzi.operator.cluster.ResourceUtils) KafkaConnect(io.strimzi.api.kafka.model.KafkaConnect) Collections.emptyList(java.util.Collections.emptyList) KafkaVersion(io.strimzi.operator.cluster.model.KafkaVersion) KafkaConnectBuilder(io.strimzi.api.kafka.model.KafkaConnectBuilder) VertxExtension(io.vertx.junit5.VertxExtension) Future(io.vertx.core.Future) Test(org.junit.jupiter.api.Test) List(java.util.List) Logger(org.apache.logging.log4j.Logger) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Checkpoint(io.vertx.junit5.Checkpoint) Condition(io.strimzi.api.kafka.model.status.Condition) KafkaConnectList(io.strimzi.api.kafka.KafkaConnectList) PlatformFeaturesAvailability(io.strimzi.operator.PlatformFeaturesAvailability) ClusterOperatorConfig(io.strimzi.operator.cluster.ClusterOperatorConfig) Mockito.mock(org.mockito.Mockito.mock) VertxTestContext(io.vertx.junit5.VertxTestContext) Assertions.fail(org.junit.jupiter.api.Assertions.fail) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BackOff(io.strimzi.operator.common.BackOff) Crds(io.strimzi.api.kafka.Crds) FeatureGates(io.strimzi.operator.cluster.FeatureGates) KafkaVersionTestUtils(io.strimzi.operator.cluster.KafkaVersionTestUtils) ZookeeperLeaderFinder(io.strimzi.operator.cluster.operator.resource.ZookeeperLeaderFinder) TestUtils(io.strimzi.test.TestUtils) Collections.singletonMap(java.util.Collections.singletonMap) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) ObjectMetaBuilder(io.fabric8.kubernetes.api.model.ObjectMetaBuilder) Promise(io.vertx.core.Promise) KubernetesVersion(io.strimzi.operator.KubernetesVersion) Vertx(io.vertx.core.Vertx) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) Reconciliation(io.strimzi.operator.common.Reconciliation) AfterEach(org.junit.jupiter.api.AfterEach) Mockito.never(org.mockito.Mockito.never) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultZookeeperScalerProvider(io.strimzi.operator.cluster.operator.resource.DefaultZookeeperScalerProvider) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) KafkaConnectResources(io.strimzi.api.kafka.model.KafkaConnectResources) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ResourceOperatorSupplier(io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier) Promise(io.vertx.core.Promise) PlatformFeaturesAvailability(io.strimzi.operator.PlatformFeaturesAvailability) ClusterOperatorConfig(io.strimzi.operator.cluster.ClusterOperatorConfig) Reconciliation(io.strimzi.operator.common.Reconciliation) ZookeeperLeaderFinder(io.strimzi.operator.cluster.operator.resource.ZookeeperLeaderFinder) DefaultZookeeperScalerProvider(io.strimzi.operator.cluster.operator.resource.DefaultZookeeperScalerProvider) BackOff(io.strimzi.operator.common.BackOff) DefaultAdminClientProvider(io.strimzi.operator.common.DefaultAdminClientProvider)

Example 4 with DefaultAdminClientProvider

use of io.strimzi.operator.common.DefaultAdminClientProvider 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();
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) OrderedProperties(io.strimzi.operator.common.model.OrderedProperties) KafkaMirrorMaker2Builder(io.strimzi.api.kafka.model.KafkaMirrorMaker2Builder) MockKube(io.strimzi.test.mockkube.MockKube) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) AfterAll(org.junit.jupiter.api.AfterAll) Resource(io.fabric8.kubernetes.client.dsl.Resource) DefaultAdminClientProvider(io.strimzi.operator.common.DefaultAdminClientProvider) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) BeforeAll(org.junit.jupiter.api.BeforeAll) ResourceOperatorSupplier(io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier) ResourceUtils(io.strimzi.operator.cluster.ResourceUtils) Collections.emptyList(java.util.Collections.emptyList) KafkaVersion(io.strimzi.operator.cluster.model.KafkaVersion) VertxExtension(io.vertx.junit5.VertxExtension) Future(io.vertx.core.Future) KafkaMirrorMaker2Resources(io.strimzi.api.kafka.model.KafkaMirrorMaker2Resources) KafkaMirrorMaker2List(io.strimzi.api.kafka.KafkaMirrorMaker2List) Test(org.junit.jupiter.api.Test) KafkaMirrorMaker2(io.strimzi.api.kafka.model.KafkaMirrorMaker2) List(java.util.List) Logger(org.apache.logging.log4j.Logger) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Checkpoint(io.vertx.junit5.Checkpoint) Condition(io.strimzi.api.kafka.model.status.Condition) PlatformFeaturesAvailability(io.strimzi.operator.PlatformFeaturesAvailability) ClusterOperatorConfig(io.strimzi.operator.cluster.ClusterOperatorConfig) Mockito.mock(org.mockito.Mockito.mock) VertxTestContext(io.vertx.junit5.VertxTestContext) Assertions.fail(org.junit.jupiter.api.Assertions.fail) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BackOff(io.strimzi.operator.common.BackOff) Crds(io.strimzi.api.kafka.Crds) FeatureGates(io.strimzi.operator.cluster.FeatureGates) KafkaVersionTestUtils(io.strimzi.operator.cluster.KafkaVersionTestUtils) ZookeeperLeaderFinder(io.strimzi.operator.cluster.operator.resource.ZookeeperLeaderFinder) TestUtils(io.strimzi.test.TestUtils) Collections.singletonMap(java.util.Collections.singletonMap) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) ObjectMetaBuilder(io.fabric8.kubernetes.api.model.ObjectMetaBuilder) Promise(io.vertx.core.Promise) KubernetesVersion(io.strimzi.operator.KubernetesVersion) Vertx(io.vertx.core.Vertx) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) Reconciliation(io.strimzi.operator.common.Reconciliation) AfterEach(org.junit.jupiter.api.AfterEach) Mockito.never(org.mockito.Mockito.never) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultZookeeperScalerProvider(io.strimzi.operator.cluster.operator.resource.DefaultZookeeperScalerProvider) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ResourceOperatorSupplier(io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier) PlatformFeaturesAvailability(io.strimzi.operator.PlatformFeaturesAvailability) ClusterOperatorConfig(io.strimzi.operator.cluster.ClusterOperatorConfig) Reconciliation(io.strimzi.operator.common.Reconciliation) ZookeeperLeaderFinder(io.strimzi.operator.cluster.operator.resource.ZookeeperLeaderFinder) DefaultZookeeperScalerProvider(io.strimzi.operator.cluster.operator.resource.DefaultZookeeperScalerProvider) BackOff(io.strimzi.operator.common.BackOff) DefaultAdminClientProvider(io.strimzi.operator.common.DefaultAdminClientProvider)

Example 5 with DefaultAdminClientProvider

use of io.strimzi.operator.common.DefaultAdminClientProvider in project strimzi by strimzi.

the class Main method main.

public static void main(String[] args) {
    LOGGER.info("UserOperator {} is starting", Main.class.getPackage().getImplementationVersion());
    UserOperatorConfig config = UserOperatorConfig.fromMap(System.getenv());
    // Setup Micrometer metrics options
    VertxOptions options = new VertxOptions().setMetricsOptions(new MicrometerMetricsOptions().setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true)).setJvmMetricsEnabled(true).setEnabled(true));
    Vertx vertx = Vertx.vertx(options);
    KubernetesClient client = new DefaultKubernetesClient();
    AdminClientProvider adminClientProvider = new DefaultAdminClientProvider();
    run(vertx, client, adminClientProvider, config).onComplete(ar -> {
        if (ar.failed()) {
            LOGGER.error("Unable to start operator", ar.cause());
            System.exit(1);
        }
    });
}
Also used : DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) VertxPrometheusOptions(io.vertx.micrometer.VertxPrometheusOptions) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) Vertx(io.vertx.core.Vertx) DefaultAdminClientProvider(io.strimzi.operator.common.DefaultAdminClientProvider) AdminClientProvider(io.strimzi.operator.common.AdminClientProvider) VertxOptions(io.vertx.core.VertxOptions) MicrometerMetricsOptions(io.vertx.micrometer.MicrometerMetricsOptions) DefaultAdminClientProvider(io.strimzi.operator.common.DefaultAdminClientProvider)

Aggregations

KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)8 DefaultAdminClientProvider (io.strimzi.operator.common.DefaultAdminClientProvider)8 Vertx (io.vertx.core.Vertx)8 Resource (io.fabric8.kubernetes.client.dsl.Resource)6 Crds (io.strimzi.api.kafka.Crds)6 Condition (io.strimzi.api.kafka.model.status.Condition)6 KubernetesVersion (io.strimzi.operator.KubernetesVersion)6 PlatformFeaturesAvailability (io.strimzi.operator.PlatformFeaturesAvailability)6 ClusterOperatorConfig (io.strimzi.operator.cluster.ClusterOperatorConfig)6 FeatureGates (io.strimzi.operator.cluster.FeatureGates)6 KafkaVersionTestUtils (io.strimzi.operator.cluster.KafkaVersionTestUtils)6 ResourceUtils (io.strimzi.operator.cluster.ResourceUtils)6 DefaultZookeeperScalerProvider (io.strimzi.operator.cluster.operator.resource.DefaultZookeeperScalerProvider)6 ResourceOperatorSupplier (io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier)6 ZookeeperLeaderFinder (io.strimzi.operator.cluster.operator.resource.ZookeeperLeaderFinder)6 BackOff (io.strimzi.operator.common.BackOff)6 Reconciliation (io.strimzi.operator.common.Reconciliation)6 TestUtils (io.strimzi.test.TestUtils)6 MockKube (io.strimzi.test.mockkube.MockKube)6 Future (io.vertx.core.Future)6