io.fabric8.kubernetes.api.model.policy.PodDisruptionBudget Java Examples

The following examples show how to use io.fabric8.kubernetes.api.model.policy.PodDisruptionBudget. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RabbitMQClusterFactory.java    From rabbitmq-operator with Apache License 2.0 6 votes vote down vote up
private PodDisruptionBudget buildPodDisruptionBudget(final RabbitMQCustomResource resource) {
    final String namespace = resource.getMetadata().getNamespace();
    return new PodDisruptionBudgetBuilder()
            .withNewMetadata()
            .withName(String.format("%s-poddisruptionbudget", resource.getName()))
            .withNamespace(namespace)
            .withOwnerReferences(
                    new OwnerReference(
                            resource.getApiVersion(),
                            true,
                            true,
                            resource.getKind(),
                            resource.getName(),
                            resource.getMetadata().getUid()
                    )
            )
            .endMetadata()
            .withNewSpec()
            .withMaxUnavailable(new IntOrString(1))
            .withNewSelector()
            .withMatchLabels(Collections.singletonMap(Labels.Kubernetes.INSTANCE, resource.getName()))
            .endSelector()
            .endSpec()
            .build();
}
 
Example #2
Source File: ZookeeperClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testPodDisruptionBudget() {
    Kafka kafkaAssembly = new KafkaBuilder(ResourceUtils.createKafkaCluster(namespace, cluster, replicas,
            image, healthDelay, healthTimeout, metricsCmJson, configurationJson, emptyMap()))
            .editSpec()
                .editZookeeper()
                    .withNewTemplate()
                        .withNewPodDisruptionBudget()
                            .withMaxUnavailable(2)
                        .endPodDisruptionBudget()
                    .endTemplate()
                .endZookeeper()
            .endSpec()
            .build();
    ZookeeperCluster zc = ZookeeperCluster.fromCrd(kafkaAssembly, VERSIONS);

    PodDisruptionBudget pdb = zc.generatePodDisruptionBudget();
    assertThat(pdb.getSpec().getMaxUnavailable(), is(new IntOrString(2)));
}
 
Example #3
Source File: KafkaMirrorMaker2ClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testPodDisruptionBudget() {
    KafkaMirrorMaker2 resource = new KafkaMirrorMaker2Builder(this.resource)
            .editSpec()
                .withNewTemplate()
                    .withNewPodDisruptionBudget()
                        .withMaxUnavailable(2)
                    .endPodDisruptionBudget()
                .endTemplate()
            .endSpec()
            .build();
    KafkaMirrorMaker2Cluster kmm2 = KafkaMirrorMaker2Cluster.fromCrd(resource, VERSIONS);

    PodDisruptionBudget pdb = kmm2.generatePodDisruptionBudget();
    assertThat(pdb.getSpec().getMaxUnavailable(), is(new IntOrString(2)));
}
 
Example #4
Source File: KafkaConnectS2IClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testPodDisruptionBudget() {
    KafkaConnectS2I resource = new KafkaConnectS2IBuilder(this.resource)
            .editSpec()
                .withNewTemplate()
                    .withNewPodDisruptionBudget()
                        .withMaxUnavailable(2)
                    .endPodDisruptionBudget()
                .endTemplate()
            .endSpec()
            .build();
    KafkaConnectS2ICluster kc = KafkaConnectS2ICluster.fromCrd(resource, VERSIONS);

    PodDisruptionBudget pdb = kc.generatePodDisruptionBudget();
    assertThat(pdb.getSpec().getMaxUnavailable(), is(new IntOrString(2)));
}
 
Example #5
Source File: KafkaConnectClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testPodDisruptionBudget() {
    KafkaConnect resource = new KafkaConnectBuilder(this.resource)
            .editSpec()
                .withNewTemplate()
                    .withNewPodDisruptionBudget()
                        .withMaxUnavailable(2)
                    .endPodDisruptionBudget()
                .endTemplate()
            .endSpec()
            .build();
    KafkaConnectCluster kc = KafkaConnectCluster.fromCrd(resource, VERSIONS);

    PodDisruptionBudget pdb = kc.generatePodDisruptionBudget();
    assertThat(pdb.getSpec().getMaxUnavailable(), is(new IntOrString(2)));
}
 
Example #6
Source File: AbstractModel.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the PodDisruptionBudget
 *
 * @return The default PodDisruptionBudget
 */
protected PodDisruptionBudget createPodDisruptionBudget()   {
    return new PodDisruptionBudgetBuilder()
            .withNewMetadata()
                .withName(name)
                .withLabels(getLabelsWithStrimziName(name, templatePodDisruptionBudgetLabels).toMap())
                .withNamespace(namespace)
                .withAnnotations(templatePodDisruptionBudgetAnnotations)
                .withOwnerReferences(createOwnerReference())
            .endMetadata()
            .withNewSpec()
                .withNewMaxUnavailable(templatePodDisruptionBudgetMaxUnavailable)
                .withSelector(new LabelSelectorBuilder().withMatchLabels(getSelectorLabels().toMap()).build())
            .endSpec()
            .build();
}
 
Example #7
Source File: KafkaClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testPodDisruptionBudget() {
    Kafka kafkaAssembly = new KafkaBuilder(ResourceUtils.createKafkaCluster(namespace, cluster, replicas,
            image, healthDelay, healthTimeout, metricsCm, configuration, emptyMap()))
            .editSpec()
                .editKafka()
                .withNewTemplate()
                    .withNewPodDisruptionBudget()
                        .withMaxUnavailable(2)
                    .endPodDisruptionBudget()
                .endTemplate()
                .endKafka()
            .endSpec()
            .build();
    KafkaCluster kc = KafkaCluster.fromCrd(kafkaAssembly, VERSIONS);

    PodDisruptionBudget pdb = kc.generatePodDisruptionBudget();
    assertThat(pdb.getSpec().getMaxUnavailable(), is(new IntOrString(2)));
}
 
Example #8
Source File: PodDisruptionBudgetOperator.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Override
protected Future<ReconcileResult<PodDisruptionBudget>> internalPatch(String namespace, String name, PodDisruptionBudget current, PodDisruptionBudget desired, boolean cascading) {
    Promise<ReconcileResult<PodDisruptionBudget>> promise = Promise.promise();
    internalDelete(namespace, name).onComplete(delRes -> {
        if (delRes.succeeded())    {
            internalCreate(namespace, name, desired).onComplete(createRes -> {
                if (createRes.succeeded())  {
                    promise.complete(createRes.result());
                } else {
                    promise.fail(createRes.cause());
                }
            });
        } else {
            promise.fail(delRes.cause());
        }
    });

    return promise.future();
}
 
Example #9
Source File: KafkaMirrorMakerClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testPodDisruptionBudget() {
    KafkaMirrorMaker resource = new KafkaMirrorMakerBuilder(this.resource)
            .editSpec()
                .withNewTemplate()
                    .withNewPodDisruptionBudget()
                        .withMaxUnavailable(2)
                    .endPodDisruptionBudget()
                .endTemplate()
            .endSpec()
            .build();
    KafkaMirrorMakerCluster mmc = KafkaMirrorMakerCluster.fromCrd(resource, VERSIONS);

    PodDisruptionBudget pdb = mmc.generatePodDisruptionBudget();
    assertThat(pdb.getSpec().getMaxUnavailable(), is(new IntOrString(2)));
}
 
Example #10
Source File: PodDisruptionBudgetTest.java    From kubernetes-client with Apache License 2.0 6 votes vote down vote up
@Test
public void testGet() {
  server.expect().withPath("/apis/policy/v1beta1/namespaces/test/poddisruptionbudgets/poddisruptionbudget1").andReturn(200, new PodDisruptionBudgetBuilder().build()).once();
  server.expect().withPath("/apis/policy/v1beta1/namespaces/ns1/poddisruptionbudgets/poddisruptionbudget2").andReturn(200, new PodDisruptionBudgetBuilder().build()).once();

  KubernetesClient client = server.getClient();

  PodDisruptionBudget podDisruptionBudget = client.policy().podDisruptionBudget().withName("poddisruptionbudget1").get();
  assertNotNull(podDisruptionBudget);

  podDisruptionBudget = client.policy().podDisruptionBudget().withName("poddisruptionbudget2").get();
  assertNull(podDisruptionBudget);

  podDisruptionBudget = client.policy().podDisruptionBudget().inNamespace("ns1").withName("poddisruptionbudget2").get();
  assertNotNull(podDisruptionBudget);
}
 
Example #11
Source File: KafkaBridgeClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 6 votes vote down vote up
@Test
public void testPodDisruptionBudget() {
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource)
            .editSpec()
                .withNewTemplate()
                    .withNewPodDisruptionBudget()
                        .withMaxUnavailable(2)
                    .endPodDisruptionBudget()
                .endTemplate()
            .endSpec()
            .build();
    KafkaBridgeCluster kbc = KafkaBridgeCluster.fromCrd(resource, VERSIONS);

    PodDisruptionBudget pdb = kbc.generatePodDisruptionBudget();
    assertThat(pdb.getSpec().getMaxUnavailable(), is(new IntOrString(2)));
}
 
Example #12
Source File: KafkaMirrorMakerClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefaultPodDisruptionBudget() {
    KafkaMirrorMaker resource = new KafkaMirrorMakerBuilder(this.resource).build();
    KafkaMirrorMakerCluster mmc = KafkaMirrorMakerCluster.fromCrd(resource, VERSIONS);

    PodDisruptionBudget pdb = mmc.generatePodDisruptionBudget();
    assertThat(pdb.getSpec().getMaxUnavailable(), is(new IntOrString(1)));
}
 
Example #13
Source File: KafkaBridgeClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefaultPodDisruptionBudget() {
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource).build();
    KafkaBridgeCluster kbc = KafkaBridgeCluster.fromCrd(resource, VERSIONS);

    PodDisruptionBudget pdb = kbc.generatePodDisruptionBudget();
    assertThat(pdb.getSpec().getMaxUnavailable(), is(new IntOrString(1)));
}
 
Example #14
Source File: KafkaConnectClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefaultPodDisruptionBudget() {
    KafkaConnect resource = new KafkaConnectBuilder(this.resource).build();
    KafkaConnectCluster kc = KafkaConnectCluster.fromCrd(resource, VERSIONS);

    PodDisruptionBudget pdb = kc.generatePodDisruptionBudget();
    assertThat(pdb.getSpec().getMaxUnavailable(), is(new IntOrString(1)));
}
 
Example #15
Source File: RabbitMQCluster.java    From rabbitmq-operator with Apache License 2.0 5 votes vote down vote up
private RabbitMQCluster(
        final String name,
        final String namespace,
        final Secret adminSecret,
        final Secret erlangCookieSecret,
        final Service mainService,
        final Service discoveryService,
        final Optional<Service> loadBalancerService,
        final Optional<Service> nodePortService,
        final StatefulSet statefulSet,
        final PodDisruptionBudget podDisruptionBudget,
        final List<ShovelSpec> shovels,
        final List<RabbitMQUser> users,
        final List<PolicySpec> policies,
        final List<OperatorPolicySpec> operatorPolicies
) {
    this.name = name;
    this.namespace = namespace;
    this.adminSecret = adminSecret;
    this.erlangCookieSecret = erlangCookieSecret;
    this.mainService = mainService;
    this.discoveryService = discoveryService;
    this.loadBalancerService = loadBalancerService;
    this.nodePortService = nodePortService;
    this.statefulSet = statefulSet;
    this.podDisruptionBudget = podDisruptionBudget;
    this.shovels = shovels;
    this.users = users;
    this.policies = policies;
    this.operatorPolicies = operatorPolicies;
}
 
Example #16
Source File: CruiseControlTest.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
@Test
public void testPodDisruptionBudget() {
    int maxUnavailable = 2;
    CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder()
            .withImage(ccImage)
                .withNewTemplate()
                    .withNewPodDisruptionBudget()
                    .withMaxUnavailable(maxUnavailable)
                .endPodDisruptionBudget()
            .endTemplate()
            .build();

    Kafka resource =
            new KafkaBuilder(ResourceUtils.createKafkaCluster(namespace, cluster, replicas, image, healthDelay, healthTimeout))
                    .editSpec()
                    .editKafka()
                    .withVersion(version)
                    .endKafka()
                    .withCruiseControl(cruiseControlSpec)
                    .endSpec()
                    .build();

    CruiseControl cc = CruiseControl.fromCrd(resource, VERSIONS);
    Deployment dep = cc.generateDeployment(true,  null, null, null);
    List<Container> containers = dep.getSpec().getTemplate().getSpec().getContainers();
    Container ccContainer = containers.stream().filter(container -> ccImage.equals(container.getImage())).findFirst().get();

    PodDisruptionBudget pdb = cc.generatePodDisruptionBudget();
    assertThat(pdb.getSpec().getMaxUnavailable(), is(new IntOrString(maxUnavailable)));
}
 
Example #17
Source File: ZookeeperClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefaultPodDisruptionBudget() {
    Kafka kafkaAssembly = new KafkaBuilder(ResourceUtils.createKafkaCluster(namespace, cluster, replicas,
            image, healthDelay, healthTimeout, metricsCmJson, configurationJson, emptyMap()))
            .build();
    ZookeeperCluster zc = ZookeeperCluster.fromCrd(kafkaAssembly, VERSIONS);

    PodDisruptionBudget pdb = zc.generatePodDisruptionBudget();
    assertThat(pdb.getSpec().getMaxUnavailable(), is(new IntOrString(1)));
}
 
Example #18
Source File: PodDisruptionBudgetExample.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
public static void main(String args[]) throws InterruptedException {
  String master = "https://192.168.99.100:8443/";
  if (args.length == 1) {
    master = args[0];
  }

  log("Using master with url ", master);
  Config config = new ConfigBuilder().withMasterUrl(master).build();
  try (final KubernetesClient client = new DefaultKubernetesClient(config)) {
    final String namespace = "default";

    PodDisruptionBudget podDisruptionBudget = new PodDisruptionBudgetBuilder()
      .withNewMetadata().withName("zk-pkb").endMetadata()
      .withNewSpec()
      .withMaxUnavailable(new IntOrString("1%"))
      .withNewSelector()
      .withMatchLabels(Collections.singletonMap("app", "zookeeper"))
      .endSelector()
      .endSpec()
      .build();

    log("Current namespace is", namespace);
    client.policy().podDisruptionBudget().inNamespace(namespace).create(podDisruptionBudget);

  } catch (KubernetesClientException e) {
    log("Could not create resource", e.getMessage());
  }
}
 
Example #19
Source File: KafkaMirrorMaker2ClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefaultPodDisruptionBudget() {
    KafkaMirrorMaker2 resource = new KafkaMirrorMaker2Builder(this.resource).build();
    KafkaMirrorMaker2Cluster kmm2 = KafkaMirrorMaker2Cluster.fromCrd(resource, VERSIONS);

    PodDisruptionBudget pdb = kmm2.generatePodDisruptionBudget();
    assertThat(pdb.getSpec().getMaxUnavailable(), is(new IntOrString(1)));
}
 
Example #20
Source File: KafkaConnectS2IClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefaultPodDisruptionBudget() {
    KafkaConnectS2I resource = new KafkaConnectS2IBuilder(this.resource).build();
    KafkaConnectS2ICluster kc = KafkaConnectS2ICluster.fromCrd(resource, VERSIONS);

    PodDisruptionBudget pdb = kc.generatePodDisruptionBudget();
    assertThat(pdb.getSpec().getMaxUnavailable(), is(new IntOrString(1)));
}
 
Example #21
Source File: KafkaClusterTest.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefaultPodDisruptionBudget() {
    Kafka kafkaAssembly = new KafkaBuilder(ResourceUtils.createKafkaCluster(namespace, cluster, replicas,
            image, healthDelay, healthTimeout, metricsCm, configuration, emptyMap()))
            .build();
    KafkaCluster kc = KafkaCluster.fromCrd(kafkaAssembly, VERSIONS);

    PodDisruptionBudget pdb = kc.generatePodDisruptionBudget();
    assertThat(pdb.getSpec().getMaxUnavailable(), is(new IntOrString(1)));
}
 
Example #22
Source File: PodDisruptionBudgetOperatorTest.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
@Override
protected PodDisruptionBudget resource() {
    return new PodDisruptionBudgetBuilder()
            .withNewMetadata()
                .withName(RESOURCE_NAME)
                .withNamespace(NAMESPACE)
                .withLabels(singletonMap("foo", "bar"))
            .endMetadata()
            .withNewSpec()
                .withNewMaxUnavailable(1)
            .endSpec()
            .build();
}
 
Example #23
Source File: PodDisruptionBudgetOperatorTest.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
@Override
public void createWhenExistsIsAPatch(VertxTestContext context, boolean cascade) {
    PodDisruptionBudget resource = resource();
    Resource mockResource = mock(resourceType());
    when(mockResource.get()).thenReturn(resource);
    when(mockResource.create(any())).thenReturn(resource);

    Deletable mockDeletable = mock(Deletable.class);
    EditReplacePatchDeletable mockERPD = mock(EditReplacePatchDeletable.class);
    when(mockERPD.withGracePeriod(anyLong())).thenReturn(mockDeletable);
    when(mockResource.cascading(cascade)).thenReturn(mockERPD);

    NonNamespaceOperation mockNameable = mock(NonNamespaceOperation.class);
    when(mockNameable.withName(matches(resource.getMetadata().getName()))).thenReturn(mockResource);

    MixedOperation mockCms = mock(MixedOperation.class);
    when(mockCms.inNamespace(matches(resource.getMetadata().getNamespace()))).thenReturn(mockNameable);

    KubernetesClient mockClient = mock(clientType());
    mocker(mockClient, mockCms);

    AbstractResourceOperator<KubernetesClient, PodDisruptionBudget, PodDisruptionBudgetList, DoneablePodDisruptionBudget, Resource<PodDisruptionBudget, DoneablePodDisruptionBudget>> op = createResourceOperations(vertx, mockClient);

    Checkpoint async = context.checkpoint();
    Future<ReconcileResult<PodDisruptionBudget>> fut = op.createOrUpdate(resource());
    fut.onComplete(ar -> {
        if (!ar.succeeded()) {
            ar.cause().printStackTrace();
        }
        assertThat(ar.succeeded(), is(true));
        verify(mockResource).get();
        verify(mockDeletable).delete();
        verify(mockResource).create(any());
        verify(mockResource, never()).patch(any());
        verify(mockResource, never()).createNew();
        verify(mockResource, never()).createOrReplace(any());
        async.flag();
    });
}
 
Example #24
Source File: PodDisruptionBudgetTest.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeleteWithNamespaceMismatch() {
  Assertions.assertThrows(KubernetesClientException.class, () -> {
    PodDisruptionBudget podDisruptionBudget1 = new PodDisruptionBudgetBuilder().withNewMetadata().withName("podDisruptionBudget1").withNamespace("test").and().build();
    KubernetesClient client = server.getClient();

    Boolean deleted = client.policy().podDisruptionBudget().inNamespace("test1").delete(podDisruptionBudget1);
    assertFalse(deleted);
  });

}
 
Example #25
Source File: PodDisruptionBudgetTest.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateWithNameMismatch() {
  Assertions.assertThrows(KubernetesClientException.class, () -> {
    PodDisruptionBudget podDisruptionBudget1 = new PodDisruptionBudgetBuilder().withNewMetadata().withName("podDisruptionBudget1").withNamespace("test").and().build();
    KubernetesClient client = server.getClient();

    client.policy().podDisruptionBudget().inNamespace("test1").withName("mypodDisruptionBudget1").create(podDisruptionBudget1);
  });
}
 
Example #26
Source File: PodDisruptionBudgetOperator.java    From strimzi-kafka-operator with Apache License 2.0 4 votes vote down vote up
@Override
protected MixedOperation<PodDisruptionBudget, PodDisruptionBudgetList, DoneablePodDisruptionBudget, Resource<PodDisruptionBudget, DoneablePodDisruptionBudget>> operation() {
    return client.policy().podDisruptionBudget();
}
 
Example #27
Source File: RabbitMQCluster.java    From rabbitmq-operator with Apache License 2.0 4 votes vote down vote up
public PodDisruptionBudget getPodDisruptionBudget() {
    return podDisruptionBudget;
}
 
Example #28
Source File: RabbitMQCluster.java    From rabbitmq-operator with Apache License 2.0 4 votes vote down vote up
public Builder withPodDisruptionBudget(final PodDisruptionBudget podDisruptionBudget) {
    this.podDisruptionBudget = podDisruptionBudget;
    return this;
}
 
Example #29
Source File: PodDisruptionBudgetOperatorTest.java    From strimzi-kafka-operator with Apache License 2.0 4 votes vote down vote up
@Override
protected AbstractResourceOperator<KubernetesClient, PodDisruptionBudget, PodDisruptionBudgetList, DoneablePodDisruptionBudget, Resource<PodDisruptionBudget, DoneablePodDisruptionBudget>> createResourceOperations(Vertx vertx, KubernetesClient mockClient) {
    return new PodDisruptionBudgetOperator(vertx, mockClient);
}
 
Example #30
Source File: KafkaBridgeAssemblyOperatorTest.java    From strimzi-kafka-operator with Apache License 2.0 4 votes vote down vote up
@Test
public void testCreateOrUpdateCreatesCluster(VertxTestContext context) {
    ResourceOperatorSupplier supplier = ResourceUtils.supplierWithMocks(true);
    CrdOperator mockBridgeOps = supplier.kafkaBridgeOperator;
    DeploymentOperator mockDcOps = supplier.deploymentOperations;
    PodDisruptionBudgetOperator mockPdbOps = supplier.podDisruptionBudgetOperator;
    ConfigMapOperator mockCmOps = supplier.configMapOperations;
    ServiceOperator mockServiceOps = supplier.serviceOperations;

    String clusterCmName = "foo";
    String clusterCmNamespace = "test";
    Map<String, Object> metricsCm = new HashMap<>();
    metricsCm.put("foo", "bar");
    KafkaBridge clusterCm = ResourceUtils.createKafkaBridgeCluster(clusterCmNamespace, clusterCmName, image, 1,
            BOOTSTRAP_SERVERS, KAFKA_BRIDGE_PRODUCER_SPEC, KAFKA_BRIDGE_CONSUMER_SPEC, KAFKA_BRIDGE_HTTP_SPEC, metricsCm);

    when(mockBridgeOps.get(clusterCmNamespace, clusterCmName)).thenReturn(clusterCm);
    when(mockBridgeOps.getAsync(anyString(), anyString())).thenReturn(Future.succeededFuture(clusterCm));

    ArgumentCaptor<Service> serviceCaptor = ArgumentCaptor.forClass(Service.class);
    when(mockServiceOps.reconcile(anyString(), anyString(), serviceCaptor.capture())).thenReturn(Future.succeededFuture());

    ArgumentCaptor<Deployment> dcCaptor = ArgumentCaptor.forClass(Deployment.class);
    when(mockDcOps.reconcile(anyString(), anyString(), dcCaptor.capture())).thenReturn(Future.succeededFuture());
    when(mockDcOps.scaleUp(anyString(), anyString(), anyInt())).thenReturn(Future.succeededFuture(42));
    when(mockDcOps.scaleDown(anyString(), anyString(), anyInt())).thenReturn(Future.succeededFuture(42));
    when(mockDcOps.readiness(anyString(), anyString(), anyLong(), anyLong())).thenReturn(Future.succeededFuture());
    when(mockDcOps.waitForObserved(anyString(), anyString(), anyLong(), anyLong())).thenReturn(Future.succeededFuture());

    ArgumentCaptor<PodDisruptionBudget> pdbCaptor = ArgumentCaptor.forClass(PodDisruptionBudget.class);
    when(mockPdbOps.reconcile(anyString(), any(), pdbCaptor.capture())).thenReturn(Future.succeededFuture());

    when(mockCmOps.reconcile(anyString(), any(), any())).thenReturn(Future.succeededFuture(ReconcileResult.created(new ConfigMap())));

    ArgumentCaptor<KafkaBridge> bridgeCaptor = ArgumentCaptor.forClass(KafkaBridge.class);
    when(mockBridgeOps.updateStatusAsync(bridgeCaptor.capture())).thenReturn(Future.succeededFuture());
    KafkaBridgeAssemblyOperator ops = new KafkaBridgeAssemblyOperator(vertx,
            new PlatformFeaturesAvailability(true, kubernetesVersion),
            new MockCertManager(), new PasswordGenerator(10, "a", "a"),
            supplier,
            ResourceUtils.dummyClusterOperatorConfig(VERSIONS));

    KafkaBridgeCluster bridge = KafkaBridgeCluster.fromCrd(clusterCm,
            VERSIONS);

    Checkpoint async = context.checkpoint();
    ops.createOrUpdate(new Reconciliation("test-trigger", KafkaBridge.RESOURCE_KIND, clusterCmNamespace, clusterCmName), clusterCm)
        .onComplete(context.succeeding(v -> context.verify(() -> {
            // Verify service
            List<Service> capturedServices = serviceCaptor.getAllValues();
            assertThat(capturedServices, hasSize(1));
            Service service = capturedServices.get(0);
            assertThat(service.getMetadata().getName(), is(bridge.getServiceName()));
            assertThat(service, is(bridge.generateService()));

            // No metrics config  => no CMs created
            Set<String> metricsNames = new HashSet<>();
            if (bridge.isMetricsEnabled()) {
                metricsNames.add(KafkaBridgeResources.metricsAndLogConfigMapName(clusterCmName));
            }

            // Verify Deployment
            List<Deployment> capturedDc = dcCaptor.getAllValues();
            assertThat(capturedDc, hasSize(1));
            Deployment dc = capturedDc.get(0);
            assertThat(dc.getMetadata().getName(), is(bridge.getName()));
            Map annotations = new HashMap();
            annotations.put(Annotations.STRIMZI_LOGGING_ANNOTATION, LOGGING_CONFIG);
            assertThat(dc, is(bridge.generateDeployment(annotations, true, null, null)));

            // Verify PodDisruptionBudget
            List<PodDisruptionBudget> capturedPdb = pdbCaptor.getAllValues();
            assertThat(capturedPdb.size(), is(1));
            PodDisruptionBudget pdb = capturedPdb.get(0);
            assertThat(pdb.getMetadata().getName(), is(bridge.getName()));
            assertThat(pdb, is(bridge.generatePodDisruptionBudget()));

            // Verify status
            List<KafkaBridge> capturedStatuses = bridgeCaptor.getAllValues();
            assertThat(capturedStatuses.get(0).getStatus().getUrl(), is("http://foo-bridge-service.test.svc:8080"));
            assertThat(capturedStatuses.get(0).getStatus().getReplicas(), is(bridge.getReplicas()));
            assertThat(capturedStatuses.get(0).getStatus().getPodSelector().getMatchLabels(), is(bridge.getSelectorLabels().toMap()));
            assertThat(capturedStatuses.get(0).getStatus().getConditions().get(0).getStatus(), is("True"));
            assertThat(capturedStatuses.get(0).getStatus().getConditions().get(0).getType(), is("Ready"));

            async.flag();
        })));
}