EntityTopicOperator extends AbstractModel { @Override protected List<Container> getContainers(ImagePullPolicy imagePullPolicy) { return singletonList(new ContainerBuilder() .withName(TOPIC_OPERATOR_CONTAINER_NAME) .withImage(getImage()) .withArgs("/opt/strimzi/bin/topic_operator_run.sh") .withEnv(getEnvVars()) .withPorts(singletonList(createContainerPort(HEALTHCHECK_PORT_NAME, HEALTHCHECK_PORT, "TCP"))) .withLivenessProbe(ProbeGenerator.httpProbe(livenessProbeOptions, livenessPath + "healthy", HEALTHCHECK_PORT_NAME)) .withReadinessProbe(ProbeGenerator.httpProbe(readinessProbeOptions, readinessPath + "ready", HEALTHCHECK_PORT_NAME)) .withResources(getResources()) .withVolumeMounts(getVolumeMounts()) .withImagePullPolicy(determineImagePullPolicy(imagePullPolicy, getImage())) .withSecurityContext(templateContainerSecurityContext) .build()); } protected  EntityTopicOperator(HasMetadata resource); void setWatchedNamespace(String watchedNamespace); String getWatchedNamespace(); void setResourceLabels(String resourceLabels); String getResourceLabels(); void setReconciliationIntervalMs(int reconciliationIntervalMs); int getReconciliationIntervalMs(); void setZookeeperSessionTimeoutMs(int zookeeperSessionTimeoutMs); int getZookeeperSessionTimeoutMs(); void setKafkaBootstrapServers(String kafkaBootstrapServers); String getKafkaBootstrapServers(); void setTopicMetadataMaxAttempts(int topicMetadataMaxAttempts); int getTopicMetadataMaxAttempts(); void setZookeeperConnect(String zookeeperConnect); String getZookeeperConnect(); static String topicOperatorName(String cluster); static String metricAndLogConfigsName(String cluster); static String roleBindingName(String cluster); @Override String getAncillaryConfigMapKeyLogConfig(); static EntityTopicOperator fromCrd(Kafka kafkaAssembly); List<Volume> getVolumes(); RoleBinding generateRoleBinding(String namespace, String watchedNamespace); void setContainerEnvVars(List<ContainerEnvVar> envVars); void setContainerSecurityContext(SecurityContext securityContext); @Override String createLog4jProperties(OrderedProperties properties); static final String ENV_VAR_RESOURCE_LABELS; static final String ENV_VAR_KAFKA_BOOTSTRAP_SERVERS; static final String ENV_VAR_ZOOKEEPER_CONNECT; static final String ENV_VAR_WATCHED_NAMESPACE; static final String ENV_VAR_FULL_RECONCILIATION_INTERVAL_MS; static final String ENV_VAR_ZOOKEEPER_SESSION_TIMEOUT_MS; static final String ENV_VAR_TOPIC_METADATA_MAX_ATTEMPTS; static final String ENV_VAR_TLS_ENABLED; static final Probe DEFAULT_HEALTHCHECK_OPTIONS; }
@Test public void testGetContainers() { List<Container> containers = entityTopicOperator.getContainers(null); assertThat(containers.size(), is(1)); Container container = containers.get(0); assertThat(container.getName(), is(EntityTopicOperator.TOPIC_OPERATOR_CONTAINER_NAME)); assertThat(container.getImage(), is(entityTopicOperator.getImage())); assertThat(container.getEnv(), is(getExpectedEnvVars())); assertThat(container.getLivenessProbe().getInitialDelaySeconds(), is(Integer.valueOf(livenessProbe.getInitialDelaySeconds()))); assertThat(container.getLivenessProbe().getTimeoutSeconds(), is(Integer.valueOf(livenessProbe.getTimeoutSeconds()))); assertThat(container.getReadinessProbe().getInitialDelaySeconds(), is(Integer.valueOf(readinessProbe.getInitialDelaySeconds()))); assertThat(container.getReadinessProbe().getTimeoutSeconds(), is(Integer.valueOf(readinessProbe.getTimeoutSeconds()))); assertThat(container.getPorts().size(), is(1)); assertThat(container.getPorts().get(0).getContainerPort(), is(Integer.valueOf(EntityTopicOperator.HEALTHCHECK_PORT))); assertThat(container.getPorts().get(0).getName(), is(EntityTopicOperator.HEALTHCHECK_PORT_NAME)); assertThat(container.getPorts().get(0).getProtocol(), is("TCP")); assertThat(EntityOperatorTest.volumeMounts(container.getVolumeMounts()), is( map("entity-topic-operator-metrics-and-logging", "/opt/topic-operator/custom-config/", EntityOperator.TLS_SIDECAR_CA_CERTS_VOLUME_NAME, EntityOperator.TLS_SIDECAR_CA_CERTS_VOLUME_MOUNT, EntityOperator.TLS_SIDECAR_EO_CERTS_VOLUME_NAME, EntityOperator.TLS_SIDECAR_EO_CERTS_VOLUME_MOUNT))); }