Skip to content

Commit

Permalink
Refactor KafkaCluster tests to not use internal methods (strimzi#10590)
Browse files Browse the repository at this point in the history
Signed-off-by: MichaelMorris <michael.morris@est.tech>
  • Loading branch information
MichaelMorrisEst authored Sep 17, 2024
1 parent ff63bf5 commit e6c7ce8
Show file tree
Hide file tree
Showing 5 changed files with 545 additions and 450 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ private static void validateConfigurationOfQuotasPlugin(KafkaConfiguration confi
}
}

protected static void validateIntConfigProperty(String propertyName, KafkaClusterSpec kafkaClusterSpec, long numberOfBrokers) {
private static void validateIntConfigProperty(String propertyName, KafkaClusterSpec kafkaClusterSpec, long numberOfBrokers) {
String orLess = numberOfBrokers > 1 ? " or less" : "";
if (kafkaClusterSpec.getConfig() != null && kafkaClusterSpec.getConfig().get(propertyName) != null) {
try {
Expand Down Expand Up @@ -672,7 +672,7 @@ public Service generateService() {
*
* @return JSON with discovery annotation
*/
/*test*/ Map<String, String> getInternalDiscoveryAnnotation() {
private Map<String, String> getInternalDiscoveryAnnotation() {
JsonArray anno = new JsonArray();

for (GenericKafkaListener listener : listeners) {
Expand Down Expand Up @@ -1231,7 +1231,7 @@ public Secret generateCertificatesSecret(ClusterCa clusterCa, ClientsCa clientsC
*
* @return List of container ports
*/
/* test */ List<ContainerPort> getContainerPortList(KafkaPool pool) {
private List<ContainerPort> getContainerPortList(KafkaPool pool) {
List<ContainerPort> ports = new ArrayList<>(listeners.size() + 3);

ports.add(ContainerUtils.createContainerPort(KAFKA_AGENT_PORT_NAME, KAFKA_AGENT_PORT));
Expand Down Expand Up @@ -1313,7 +1313,7 @@ private List<PersistentVolumeClaim> generatePersistentVolumeClaimsForPool(KafkaP
*
* @return List of non-data volumes used by the ZooKeeper pods
*/
/* test */ List<Volume> getNonDataVolumes(boolean isOpenShift, String podName, PodTemplate templatePod) {
private List<Volume> getNonDataVolumes(boolean isOpenShift, String podName, PodTemplate templatePod) {
List<Volume> volumeList = new ArrayList<>();

if (rack != null || isExposedWithNodePort()) {
Expand Down Expand Up @@ -1459,7 +1459,7 @@ private List<VolumeMount> getInitContainerVolumeMounts(KafkaPool pool) {
*
* @return Combined affinity
*/
protected Affinity getMergedAffinity(KafkaPool pool) {
private Affinity getMergedAffinity(KafkaPool pool) {
Affinity userAffinity = pool.templatePod != null && pool.templatePod.getAffinity() != null ? pool.templatePod.getAffinity() : new Affinity();
AffinityBuilder builder = new AffinityBuilder(userAffinity);
if (rack != null) {
Expand All @@ -1484,7 +1484,7 @@ protected Affinity getMergedAffinity(KafkaPool pool) {
return builder.build();
}

protected List<EnvVar> getInitContainerEnvVars(KafkaPool pool) {
private List<EnvVar> getInitContainerEnvVars(KafkaPool pool) {
List<EnvVar> varList = new ArrayList<>();
varList.add(ContainerUtils.createEnvVarFromFieldRef(ENV_VAR_KAFKA_INIT_NODE_NAME, "spec.nodeName"));

Expand All @@ -1504,7 +1504,7 @@ protected List<EnvVar> getInitContainerEnvVars(KafkaPool pool) {
return varList;
}

/* test */ Container createInitContainer(ImagePullPolicy imagePullPolicy, KafkaPool pool) {
private Container createInitContainer(ImagePullPolicy imagePullPolicy, KafkaPool pool) {
if (rack != null || !ListenersUtils.nodePortListeners(listeners).isEmpty()) {
return ContainerUtils.createContainer(
INIT_NAME,
Expand Down Expand Up @@ -1532,7 +1532,7 @@ protected List<EnvVar> getInitContainerEnvVars(KafkaPool pool) {
*
* @return Kafka container
*/
/* test */ Container createContainer(ImagePullPolicy imagePullPolicy, KafkaPool pool) {
private Container createContainer(ImagePullPolicy imagePullPolicy, KafkaPool pool) {
return ContainerUtils.createContainer(
KAFKA_NAME,
image,
Expand All @@ -1555,7 +1555,7 @@ protected List<EnvVar> getInitContainerEnvVars(KafkaPool pool) {
*
* @return List of environment variables
*/
protected List<EnvVar> getEnvVars(KafkaPool pool) {
private List<EnvVar> getEnvVars(KafkaPool pool) {
List<EnvVar> varList = new ArrayList<>();
varList.add(ContainerUtils.createEnvVar(ENV_VAR_KAFKA_METRICS_ENABLED, String.valueOf(metrics.isEnabled())));
varList.add(ContainerUtils.createEnvVar(ENV_VAR_STRIMZI_KAFKA_GC_LOG_ENABLED, String.valueOf(pool.gcLoggingEnabled)));
Expand Down Expand Up @@ -1708,24 +1708,6 @@ private boolean isExposedWithNodePort() {
return ListenersUtils.hasNodePortListener(listeners);
}

/**
* Returns true when the Kafka cluster is exposed to the outside of Kubernetes using Ingress
*
* @return true when the Kafka cluster is exposed using Kubernetes Ingress.
*/
/* test */ boolean isExposedWithIngress() {
return ListenersUtils.hasIngressListener(listeners);
}

/**
* Returns true when the Kafka cluster is exposed to the outside of Kubernetes using ClusterIP services
*
* @return true when the Kafka cluster is exposed using Kubernetes Ingress with TCP mode.
*/
/* test */ boolean isExposedWithClusterIP() {
return ListenersUtils.hasClusterIPListener(listeners);
}

/**
* Returns the configuration of the Kafka cluster. This method is currently used by the KafkaSpecChecker to get the
* Kafka configuration and check it for warnings.
Expand Down
Loading

0 comments on commit e6c7ce8

Please sign in to comment.