ZookeeperCluster extends AbstractModel { public Service generateService() { List<ServicePort> ports = new ArrayList<>(1); ports.add(createServicePort(CLIENT_TLS_PORT_NAME, CLIENT_TLS_PORT, CLIENT_TLS_PORT, "TCP")); return createService("ClusterIP", ports, templateServiceAnnotations); } private  ZookeeperCluster(HasMetadata resource); static String zookeeperClusterName(String cluster); static String zookeeperMetricAndLogConfigsName(String cluster); static String serviceName(String cluster); static String headlessServiceName(String cluster); static String podDnsName(String namespace, String cluster, int podId); static String podDnsNameWithoutSuffix(String namespace, String cluster, int podId); static String zookeeperPodName(String cluster, int pod); static String nodesSecretName(String cluster); static ZookeeperCluster fromCrd(Kafka kafkaAssembly, KafkaVersion.Lookup versions); @SuppressWarnings({"checkstyle:MethodLength", "checkstyle:CyclomaticComplexity"}) static ZookeeperCluster fromCrd(Kafka kafkaAssembly, KafkaVersion.Lookup versions, Storage oldStorage, int oldReplicas); Service generateService(); static String policyName(String cluster); NetworkPolicy generateNetworkPolicy(boolean namespaceAndPodSelectorNetworkPolicySupported); Service generateHeadlessService(); StatefulSet generateStatefulSet(boolean isOpenShift, ImagePullPolicy imagePullPolicy, List<LocalObjectReference> imagePullSecrets); Secret generateNodesSecret(ClusterCa clusterCa, Kafka kafka, boolean isMaintenanceTimeWindowsSatisfied); List<PersistentVolumeClaim> generatePersistentVolumeClaims(); PodDisruptionBudget generatePodDisruptionBudget(); static String containerServiceAccountName(String zookeeperResourceName); @Override void setImage(String image); void setVersion(String version); String getVersion(); ConfigMap generateConfigurationConfigMap(ConfigMap cm); static final int CLIENT_PLAINTEXT_PORT; static final int CLIENT_TLS_PORT; static final int CLUSTERING_PORT; static final int LEADER_ELECTION_PORT; static final String ZOOKEEPER_NAME; static final Probe DEFAULT_HEALTHCHECK_OPTIONS; static final String ENV_VAR_ZOOKEEPER_METRICS_ENABLED; static final String ENV_VAR_ZOOKEEPER_CONFIGURATION; static final String ENV_VAR_ZOOKEEPER_SNAPSHOT_CHECK_ENABLED; static final String CONFIG_MAP_KEY_ZOOKEEPER_NODE_COUNT; }
@Test public void testGenerateService() { Service headful = zc.generateService(); assertThat(headful.getSpec().getType(), is("ClusterIP")); assertThat(headful.getSpec().getSelector(), is(expectedSelectorLabels())); assertThat(headful.getSpec().getPorts().size(), is(1)); assertThat(headful.getSpec().getPorts().get(0).getName(), is(ZookeeperCluster.CLIENT_TLS_PORT_NAME)); assertThat(headful.getSpec().getPorts().get(0).getPort(), is(Integer.valueOf(ZookeeperCluster.CLIENT_TLS_PORT))); assertThat(headful.getSpec().getPorts().get(0).getProtocol(), is("TCP")); assertThat(headful.getMetadata().getAnnotations(), is(nullValue())); checkOwnerReference(zc.createOwnerReference(), headful); }