Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.strimzi.test.CrdUtils;
import io.strimzi.test.ReadWriteUtils;
import io.strimzi.test.TestUtils;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand All @@ -34,6 +35,11 @@ void testKafkaBridgeScaling() {
createScaleDelete(KafkaBridge.class, "KafkaBridge.yaml");
}

@Test
void testKafkaBridgeV1() {
createDeleteCustomResource("KafkaBridge-v1.yaml");
}

@Test
void testKafkaBridgeMinimal() {
createDeleteCustomResource("KafkaBridge-minimal.yaml");
Expand Down Expand Up @@ -118,6 +124,36 @@ void testKafkaBridgeWithMetrics() {
createDeleteCustomResource("KafkaBridge-with-metrics.yaml");
}

@Test
void testKafkaBridgeV1NoSpec() {
Throwable exception = assertThrows(
KubernetesClientException.class,
() -> createDeleteCustomResource("KafkaBridge-v1-no-spec.yaml"));

assertMissingRequiredPropertiesMessage(exception.getMessage(), "spec");
}

@Test
void testKafkaBridgeV1NoReplicas() {
Throwable exception = assertThrows(
KubernetesClientException.class,
() -> createDeleteCustomResource("KafkaBridge-v1-no-replicas.yaml"));

assertMissingRequiredPropertiesMessage(exception.getMessage(), "replicas");
}

@Test
public void testKafkaBridgeV1WrongAuth() {
Throwable exception = assertThrows(
KubernetesClientException.class,
() -> createDeleteCustomResource("KafkaBridge-v1-wrong-auth.yaml"));

assertThat(exception.getMessage(), allOf(
CoreMatchers.containsStringIgnoringCase("Unsupported value: \"oauth\""),
CoreMatchers.containsStringIgnoringCase("supported values: \"tls\", \"scram-sha-256\", \"scram-sha-512\", \"plain\", \"custom\""))
);
}

@BeforeAll
void setupEnvironment() {
client = new KubernetesClientBuilder().withConfig(new ConfigBuilder().withNamespace(NAMESPACE).build()).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
import io.strimzi.api.kafka.model.AbstractCrdIT;
import io.strimzi.test.CrdUtils;
import io.strimzi.test.TestUtils;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.containsStringIgnoringCase;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand All @@ -32,6 +34,11 @@ void testKafkaConnectScaling() {
createScaleDelete(KafkaConnect.class, "KafkaConnect.yaml");
}

@Test
void testKafkaConnectV1() {
createDeleteCustomResource("KafkaConnect-v1.yaml");
}

@Test
void testKafkaConnectMinimal() {
createDeleteCustomResource("KafkaConnect-minimal.yaml");
Expand Down Expand Up @@ -103,6 +110,36 @@ public void testKafkaConnectWithDnsConfig() {
createDeleteCustomResource("KafkaConnect-with-dnsConfig.yaml");
}

@Test
void testKafkaConnectV1NoSpec() {
Throwable exception = assertThrows(
KubernetesClientException.class,
() -> createDeleteCustomResource("KafkaConnect-v1-no-spec.yaml"));

assertMissingRequiredPropertiesMessage(exception.getMessage(), "spec");
}

@Test
void testKafkaConnectV1NoReplicasGroupEtc() {
Throwable exception = assertThrows(
KubernetesClientException.class,
() -> createDeleteCustomResource("KafkaConnect-v1-no-replicas-group-etc.yaml"));

assertMissingRequiredPropertiesMessage(exception.getMessage(), "replicas", "groupId", "configStorageTopic", "statusStorageTopic", "offsetStorageTopic");
}

@Test
public void testKafkaConnectV1WrongAuth() {
Throwable exception = assertThrows(
KubernetesClientException.class,
() -> createDeleteCustomResource("KafkaConnect-v1-wrong-auth.yaml"));

assertThat(exception.getMessage(), allOf(
CoreMatchers.containsStringIgnoringCase("Unsupported value: \"oauth\""),
CoreMatchers.containsStringIgnoringCase("supported values: \"tls\", \"scram-sha-256\", \"scram-sha-512\", \"plain\", \"custom\""))
);
}

@BeforeAll
void setupEnvironment() {
client = new KubernetesClientBuilder().withConfig(new ConfigBuilder().withNamespace(NAMESPACE).build()).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@

import io.fabric8.kubernetes.client.ConfigBuilder;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.strimzi.api.kafka.model.AbstractCrdIT;
import io.strimzi.test.CrdUtils;
import io.strimzi.test.TestUtils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertThrows;

/**
* The purpose of this test is to confirm that we can create a
* resource from the POJOs, serialize it and create the resource in K8S.
Expand All @@ -27,11 +30,25 @@ void testKafkaConnector() {
createDeleteCustomResource("KafkaConnector.yaml");
}

@Test
void testKafkaConnectorv1() {
createDeleteCustomResource("KafkaConnector-v1.yaml");
}

@Test
void testKafkaConnectorScaling() {
createScaleDelete(KafkaConnector.class, "KafkaConnector.yaml");
}

@Test
void testKafkaConnectorV1NoSpec() {
Throwable exception = assertThrows(
KubernetesClientException.class,
() -> createDeleteCustomResource("KafkaConnector-v1-no-spec.yaml"));

assertMissingRequiredPropertiesMessage(exception.getMessage(), "spec");
}

@BeforeAll
void setupEnvironment() {
client = new KubernetesClientBuilder().withConfig(new ConfigBuilder().withNamespace(NAMESPACE).build()).build();
Expand Down
30 changes: 30 additions & 0 deletions api/src/test/java/io/strimzi/api/kafka/model/kafka/KafkaCrdIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
import io.strimzi.api.kafka.model.AbstractCrdIT;
import io.strimzi.test.CrdUtils;
import io.strimzi.test.TestUtils;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsStringIgnoringCase;
Expand All @@ -33,6 +35,11 @@ void testKafka() {
createDeleteCustomResource("Kafka.yaml");
}

@Test
void testKafkaV1() {
createDeleteCustomResource("Kafka-v1.yaml");
}

@Test
void testKafkaWithZooKeeper() {
createDeleteCustomResource("Kafka-with-zookeeper.yaml");
Expand Down Expand Up @@ -124,6 +131,29 @@ public void testKafkaWithAutoRebalanceEmpty() {
assertThat(exception.getMessage(), containsStringIgnoringCase("spec.cruiseControl.autoRebalance in body should have at least 1 items"));
}

@Test
void testKafkaV1NoSpec() {
Throwable exception = assertThrows(
KubernetesClientException.class,
() -> createDeleteCustomResource("Kafka-v1-no-spec.yaml"));

assertMissingRequiredPropertiesMessage(exception.getMessage(), "spec");
}

@Test
public void testKafkaV1WrongTypes() {
Throwable exception = assertThrows(
KubernetesClientException.class,
() -> createDeleteCustomResource("Kafka-v1-wrong-types.yaml"));

assertThat(exception.getMessage(), allOf(
CoreMatchers.containsStringIgnoringCase("Unsupported value: \"opa\""),
CoreMatchers.containsStringIgnoringCase("supported values: \"simple\", \"custom\""),
CoreMatchers.containsStringIgnoringCase("Unsupported value: \"oauth\""),
CoreMatchers.containsStringIgnoringCase("supported values: \"tls\", \"scram-sha-512\", \"custom\""))
);
}

@BeforeAll
void setupEnvironment() {
client = new KubernetesClientBuilder().withConfig(new ConfigBuilder().withNamespace(NAMESPACE).build()).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ void testKafkaMirrorMaker2Scaling() {
createScaleDelete(KafkaMirrorMaker2.class, "KafkaMirrorMaker2.yaml");
}

@Test
void testKafkaMirrorMaker2V1() {
createDeleteCustomResource("KafkaMirrorMaker2-v1.yaml");
}

@Test
void testKafkaMirrorMaker2Minimal() {
createDeleteCustomResource("KafkaMirrorMaker2-minimal.yaml");
Expand Down Expand Up @@ -103,6 +108,33 @@ void testKafkaMirrorMaker2WithDnsConfig() {
createDeleteCustomResource("KafkaMirrorMaker2-with-dnsConfig.yaml");
}

@Test
void testKafkaMirrorMaker2V1NoSpec() {
Throwable exception = assertThrows(
KubernetesClientException.class,
() -> createDeleteCustomResource("KafkaMirrorMaker2-v1-no-spec.yaml"));

assertMissingRequiredPropertiesMessage(exception.getMessage(), "spec");
}

@Test
void testKafkaMirrorMaker2V1MissingRequiredTopLevel() {
Throwable exception = assertThrows(
KubernetesClientException.class,
() -> createDeleteCustomResource("KafkaMirrorMaker2-v1-missing-required-top-level.yaml"));

assertMissingRequiredPropertiesMessage(exception.getMessage(), "source", "target");
}

@Test
void testKafkaMirrorMaker2V1MissingRequiredLowerLevel() {
Throwable exception = assertThrows(
KubernetesClientException.class,
() -> createDeleteCustomResource("KafkaMirrorMaker2-v1-missing-required-lower-level.yaml"));

assertMissingRequiredPropertiesMessage(exception.getMessage(), "groupId", "configStorageTopic", "statusStorageTopic", "offsetStorageTopic", "alias");
}

@BeforeAll
void setupEnvironment() {
client = new KubernetesClientBuilder().withConfig(new ConfigBuilder().withNamespace(NAMESPACE).build()).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ void testKafkaNodePool() {
createDeleteCustomResource("KafkaNodePool.yaml");
}

@Test
void testKafkaNodePoolV1() {
createDeleteCustomResource("KafkaNodePool-v1.yaml");
}

@Test
void testKafkaNodePoolScaling() {
createScaleDelete(KafkaNodePool.class, "KafkaNodePool.yaml");
Expand All @@ -46,6 +51,15 @@ public void testKafkaWithInvalidRole() {
containsStringIgnoringCase("spec.roles[0]: Unsupported value: \"helper\": supported values: \"controller\", \"broker\"")));
}

@Test
void testKafkaNodePoolNoSpec() {
Throwable exception = assertThrows(
KubernetesClientException.class,
() -> createDeleteCustomResource("KafkaNodePool-v1-no-spec.yaml"));

assertMissingRequiredPropertiesMessage(exception.getMessage(), "spec");
}

@BeforeAll
void setupEnvironment() {
client = new KubernetesClientBuilder().withConfig(new ConfigBuilder().withNamespace(NAMESPACE).build()).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ void testStrimziPodSetMinimal() {
createDeleteCustomResource("StrimziPodSet.yaml");
}

@Test
void testStrimziPodSetV1() {
createDeleteCustomResource("StrimziPodSet-v1.yaml");
}

@Test
void testStrimziPodSettWithMissingRequired() {
Throwable exception = assertThrows(
Expand Down Expand Up @@ -69,6 +74,15 @@ void testZeroReplicas() {
Crds.strimziPodSetOperation(client).inNamespace(NAMESPACE).withName("my-pod-set").delete();
}

@Test
void testNoSpec() {
Throwable exception = assertThrows(
KubernetesClientException.class,
() -> createDeleteCustomResource("StrimziPodSet-v1-no-spec.yaml"));

assertMissingRequiredPropertiesMessage(exception.getMessage(), "spec");
}

@BeforeAll
void setupEnvironment() {
client = new KubernetesClientBuilder().withConfig(new ConfigBuilder().withNamespace(NAMESPACE).build()).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ void testKafkaRebalanceMinimal() {
createDeleteCustomResource("KafkaRebalance-minimal.yaml");
}

@Test
void testKafkaRebalanceV1() {
createDeleteCustomResource("KafkaRebalance-v1.yaml");
}

@Test
void testKafkaRebalanceWithGoals() {
createDeleteCustomResource("KafkaRebalance-with-goals.yaml");
Expand Down Expand Up @@ -103,6 +108,15 @@ void testKafkaRebalanceWrongMode() {
assertThat(exception.getMessage(), containsString("spec.mode: Unsupported value: \"wrong-mode\": supported values: \"full\", \"add-brokers\", \"remove-brokers\""));
}

@Test
void testKafkaRebalanceV1NoSpec() {
Throwable exception = assertThrows(
KubernetesClientException.class,
() -> createDeleteCustomResource("KafkaRebalance-v1-no-spec.yaml"));

assertMissingRequiredPropertiesMessage(exception.getMessage(), "spec");
}

@BeforeAll
void setupEnvironment() {
client = new KubernetesClientBuilder().withConfig(new ConfigBuilder().withNamespace(NAMESPACE).build()).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,26 @@ void testKafkaTopicV1beta1() {
createDeleteCustomResource("KafkaTopicV1beta1.yaml");
}

@Test
void testKafkaTopicV1() {
createDeleteCustomResource("KafkaTopic-v1.yaml");
}


@Test
void testKafkaTopicMinimal() {
createDeleteCustomResource("KafkaTopic-minimal.yaml");
}

@Test
void testKafkaTopicV1NoSpec() {
Throwable exception = assertThrows(
KubernetesClientException.class,
() -> createDeleteCustomResource("KafkaTopic-v1-no-spec.yaml"));

assertMissingRequiredPropertiesMessage(exception.getMessage(), "spec");
}

@BeforeAll
void setupEnvironment() {
client = new KubernetesClientBuilder().withConfig(new ConfigBuilder().withNamespace(NAMESPACE).build()).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,25 @@ void testKafkaUserV1beta1() {
createDeleteCustomResource("KafkaUserV1beta1.yaml");
}

@Test
void testKafkaUserV1() {
createDeleteCustomResource("KafkaUser-v1.yaml");
}

@Test
void testKafkaUserMinimal() {
createDeleteCustomResource("KafkaUser-minimal.yaml");
}

@Test
void testKafkaUserV1NoSpec() {
Throwable exception = assertThrows(
KubernetesClientException.class,
() -> createDeleteCustomResource("KafkaUser-v1-no-spec.yaml"));

assertMissingRequiredPropertiesMessage(exception.getMessage(), "spec");
}

@BeforeAll
void setupEnvironment() {
client = new KubernetesClientBuilder().withConfig(new ConfigBuilder().withNamespace(NAMESPACE).build()).build();
Expand Down
Loading