KafkaBridgeCluster extends AbstractModel { public Deployment generateDeployment(Map<String, String> annotations, boolean isOpenShift, ImagePullPolicy imagePullPolicy, List<LocalObjectReference> imagePullSecrets) { DeploymentStrategy updateStrategy = new DeploymentStrategyBuilder() .withType("RollingUpdate") .withRollingUpdate(new RollingUpdateDeploymentBuilder() .withMaxSurge(new IntOrString(1)) .withMaxUnavailable(new IntOrString(0)) .build()) .build(); return createDeployment( updateStrategy, Collections.emptyMap(), annotations, getMergedAffinity(), getInitContainers(imagePullPolicy), getContainers(imagePullPolicy), getVolumes(isOpenShift), imagePullSecrets); } protected  KafkaBridgeCluster(HasMetadata resource); static KafkaBridgeCluster fromCrd(KafkaBridge kafkaBridge, KafkaVersion.Lookup versions); Service generateService(); Deployment generateDeployment(Map<String, String> annotations, boolean isOpenShift, ImagePullPolicy imagePullPolicy, List<LocalObjectReference> imagePullSecrets); @Override String getAncillaryConfigMapKeyLogConfig(); PodDisruptionBudget generatePodDisruptionBudget(); KafkaBridgeHttpConfig getHttp(); @Override String createLog4jProperties(OrderedProperties properties); static final String APPLICATION_NAME; static final int DEFAULT_REST_API_PORT; static final Probe DEFAULT_HEALTHCHECK_OPTIONS; }
@Test public void testGenerateDeployment() { Deployment dep = kbc.generateDeployment(new HashMap<String, String>(), true, null, null); assertThat(dep.getMetadata().getName(), is(KafkaBridgeResources.deploymentName(cluster))); assertThat(dep.getMetadata().getNamespace(), is(namespace)); Map<String, String> expectedDeploymentLabels = expectedLabels(KafkaBridgeResources.deploymentName(cluster)); assertThat(dep.getMetadata().getLabels(), is(expectedDeploymentLabels)); assertThat(dep.getSpec().getSelector().getMatchLabels(), is(expectedSelectorLabels())); assertThat(dep.getSpec().getReplicas(), is(Integer.valueOf(replicas))); assertThat(dep.getSpec().getTemplate().getMetadata().getLabels(), is(expectedDeploymentLabels)); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().size(), is(1)); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getName(), is(KafkaBridgeResources.deploymentName(cluster))); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getImage(), is(kbc.image)); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv(), is(getExpectedEnvVars())); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getLivenessProbe().getInitialDelaySeconds(), is(Integer.valueOf(healthDelay))); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getLivenessProbe().getTimeoutSeconds(), is(Integer.valueOf(healthTimeout))); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getReadinessProbe().getInitialDelaySeconds(), is(Integer.valueOf(healthDelay))); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getReadinessProbe().getTimeoutSeconds(), is(Integer.valueOf(healthTimeout))); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getPorts().size(), is(1)); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getPorts().get(0).getContainerPort(), is(Integer.valueOf(KafkaBridgeCluster.DEFAULT_REST_API_PORT))); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getPorts().get(0).getName(), is(KafkaBridgeCluster.REST_API_PORT_NAME)); assertThat(dep.getSpec().getTemplate().getSpec().getContainers().get(0).getPorts().get(0).getProtocol(), is("TCP")); assertThat(dep.getSpec().getStrategy().getType(), is("RollingUpdate")); assertThat(dep.getSpec().getStrategy().getRollingUpdate().getMaxSurge().getIntVal(), is(Integer.valueOf(1))); assertThat(dep.getSpec().getStrategy().getRollingUpdate().getMaxUnavailable().getIntVal(), is(Integer.valueOf(0))); assertThat(AbstractModel.containerEnvVars(dep.getSpec().getTemplate().getSpec().getContainers().get(0)).get(KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_TLS), is(nullValue())); checkOwnerReference(kbc.createOwnerReference(), dep); }