Search in sources :

Example 1 with OpenShiftOnly

use of io.strimzi.test.OpenShiftOnly in project strimzi by strimzi.

the class ConnectClusterTest method testDeployConnectClusterViaTemplate.

@Test
@Resources(value = "../examples/templates/cluster-controller", asAdmin = true)
@OpenShiftOnly
public void testDeployConnectClusterViaTemplate() {
    Oc oc = (Oc) this.kubeClient;
    String clusterName = "openshift-my-connect-cluster";
    oc.newApp("strimzi-connect", map("CLUSTER_NAME", clusterName, "KAFKA_CONNECT_BOOTSTRAP_SERVERS", BOOTSTRAP_SERVERS));
    String deploymentName = clusterName + "-connect";
    oc.waitForDeployment(deploymentName);
    oc.deleteByName("cm", clusterName);
    oc.waitForResourceDeletion("deployment", deploymentName);
}
Also used : Oc(io.strimzi.test.k8s.Oc) Test(org.junit.Test) Resources(io.strimzi.test.Resources) OpenShiftOnly(io.strimzi.test.OpenShiftOnly)

Example 2 with OpenShiftOnly

use of io.strimzi.test.OpenShiftOnly in project strimzi by strimzi.

the class KafkaClusterTest method testDeployKafkaClusterViaTemplate.

@Test
@Resources(value = "../examples/templates/cluster-controller", asAdmin = true)
@OpenShiftOnly
public void testDeployKafkaClusterViaTemplate() {
    Oc oc = (Oc) this.kubeClient;
    String clusterName = "openshift-my-cluster";
    oc.newApp("strimzi-ephemeral", map("CLUSTER_NAME", clusterName));
    oc.waitForStatefulSet(zookeeperStatefulSetName(clusterName), 1);
    oc.waitForStatefulSet(kafkaStatefulSetName(clusterName), 3);
    oc.deleteByName("cm", clusterName);
    oc.waitForResourceDeletion("statefulset", kafkaStatefulSetName(clusterName));
    oc.waitForResourceDeletion("statefulset", zookeeperStatefulSetName(clusterName));
}
Also used : Oc(io.strimzi.test.k8s.Oc) Test(org.junit.Test) Resources(io.strimzi.test.Resources) OpenShiftOnly(io.strimzi.test.OpenShiftOnly)

Example 3 with OpenShiftOnly

use of io.strimzi.test.OpenShiftOnly in project strimzi by strimzi.

the class KafkaClusterTest method testDeployKafkaOnPersistentStorage.

@Test
@KafkaCluster(name = "my-cluster-persistent", kafkaNodes = 2, zkNodes = 2, config = { @CmData(key = "kafka-storage", value = "{ \"type\": \"persistent-claim\", \"size\": \"1Gi\", \"delete-claim\": false }"), @CmData(key = "zookeeper-storage", value = "{ \"type\": \"persistent-claim\", \"size\": \"1Gi\", \"delete-claim\": false }"), @CmData(key = "zookeeper-healthcheck-delay", value = "30"), @CmData(key = "zookeeper-healthcheck-timeout", value = "15"), @CmData(key = "kafka-healthcheck-delay", value = "30"), @CmData(key = "kafka-healthcheck-timeout", value = "15"), @CmData(key = "KAFKA_DEFAULT_REPLICATION_FACTOR", value = "2"), @CmData(key = "KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR", value = "5"), @CmData(key = "KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR", value = "5") })
@OpenShiftOnly
public void testDeployKafkaOnPersistentStorage() {
    String clusterName = "my-cluster-persistent";
    int expectedZKPods = 2;
    int expectedKafkaPods = 2;
    Oc oc = (Oc) this.kubeClient;
    List<String> persistentVolumeClaimNames = oc.list("pvc");
    assertTrue(persistentVolumeClaimNames.size() == (expectedZKPods + expectedKafkaPods));
    // Checking Persistent volume claims for Zookeeper nodes
    for (int i = 0; i < expectedZKPods; i++) {
        assertTrue(persistentVolumeClaimNames.contains(zookeeperPVCName(clusterName, i)));
    }
    // Checking Persistent volume claims for Kafka nodes
    for (int i = 0; i < expectedZKPods; i++) {
        assertTrue(persistentVolumeClaimNames.contains(kafkaPVCName(clusterName, i)));
    }
    String configMap = kubeClient.get("cm", clusterName);
    assertThat(configMap, valueOfCmEquals("zookeeper-healthcheck-delay", "30"));
    assertThat(configMap, valueOfCmEquals("zookeeper-healthcheck-timeout", "15"));
    assertThat(configMap, valueOfCmEquals("kafka-healthcheck-delay", "30"));
    assertThat(configMap, valueOfCmEquals("kafka-healthcheck-timeout", "15"));
    assertThat(configMap, valueOfCmEquals("KAFKA_DEFAULT_REPLICATION_FACTOR", "2"));
    assertThat(configMap, valueOfCmEquals("KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR", "5"));
    assertThat(configMap, valueOfCmEquals("KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR", "5"));
}
Also used : Oc(io.strimzi.test.k8s.Oc) KafkaCluster(io.strimzi.test.KafkaCluster) Test(org.junit.Test) OpenShiftOnly(io.strimzi.test.OpenShiftOnly)

Example 4 with OpenShiftOnly

use of io.strimzi.test.OpenShiftOnly in project strimzi by strimzi.

the class KafkaClusterTest method testForUpdateValuesInConfigMap.

@Test
@OpenShiftOnly
@KafkaCluster(name = "my-cluster", kafkaNodes = 2, zkNodes = 2, config = { @CmData(key = "zookeeper-healthcheck-delay", value = "30"), @CmData(key = "zookeeper-healthcheck-timeout", value = "10"), @CmData(key = "kafka-healthcheck-delay", value = "30"), @CmData(key = "kafka-healthcheck-timeout", value = "10"), @CmData(key = "KAFKA_DEFAULT_REPLICATION_FACTOR", value = "2"), @CmData(key = "KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR", value = "5"), @CmData(key = "KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR", value = "5") })
public void testForUpdateValuesInConfigMap() {
    String clusterName = "my-cluster";
    int expectedZKPods = 2;
    int expectedKafkaPods = 2;
    List<Date> zkPodStartTime = new ArrayList<>();
    for (int i = 0; i < expectedZKPods; i++) {
        zkPodStartTime.add(kubeClient.getResourceCreateTimestamp("pod", zookeeperPodName(clusterName, i)));
    }
    List<Date> kafkaPodStartTime = new ArrayList<>();
    for (int i = 0; i < expectedKafkaPods; i++) {
        kafkaPodStartTime.add(kubeClient.getResourceCreateTimestamp("pod", kafkaPodName(clusterName, i)));
    }
    Oc oc = (Oc) this.kubeClient;
    replaceCm(clusterName, "zookeeper-healthcheck-delay", "23");
    replaceCm(clusterName, "kafka-healthcheck-delay", "23");
    replaceCm(clusterName, "KAFKA_DEFAULT_REPLICATION_FACTOR", "1");
    for (int i = 0; i < expectedZKPods; i++) {
        kubeClient.waitForResourceUpdate("pod", zookeeperPodName(clusterName, i), zkPodStartTime.get(i));
        kubeClient.waitForPod(zookeeperPodName(clusterName, i));
    }
    for (int i = 0; i < expectedKafkaPods; i++) {
        kubeClient.waitForResourceUpdate("pod", kafkaPodName(clusterName, i), kafkaPodStartTime.get(i));
        kubeClient.waitForPod(kafkaPodName(clusterName, i));
    }
    String configMap = kubeClient.get("cm", clusterName);
    assertThat(configMap, valueOfCmEquals("zookeeper-healthcheck-delay", "23"));
    assertThat(configMap, valueOfCmEquals("kafka-healthcheck-delay", "23"));
    assertThat(configMap, valueOfCmEquals("KAFKA_DEFAULT_REPLICATION_FACTOR", "1"));
    LOGGER.info("Verified CM and Testing kafka pods");
    for (int i = 0; i < expectedKafkaPods; i++) {
        String kafkaPodJson = oc.getResourceAsJson("pod", kafkaPodName(clusterName, i));
        assertEquals("1", getValueFromJson(kafkaPodJson, globalVariableJsonPathBuilder("KAFKA_DEFAULT_REPLICATION_FACTOR")));
        String initialDelaySecondsPath = "$.spec.containers[*].livenessProbe.initialDelaySeconds";
        assertEquals("23", getValueFromJson(kafkaPodJson, initialDelaySecondsPath));
    }
    LOGGER.info("Testing Zookeepers");
    for (int i = 0; i < expectedZKPods; i++) {
        String zkPodJson = kubeClient.getResourceAsJson("pod", zookeeperPodName(clusterName, i));
        String initialDelaySecondsPath = "$.spec.containers[*].livenessProbe.initialDelaySeconds";
        assertEquals("23", getValueFromJson(zkPodJson, initialDelaySecondsPath));
    }
}
Also used : Oc(io.strimzi.test.k8s.Oc) ArrayList(java.util.ArrayList) Date(java.util.Date) KafkaCluster(io.strimzi.test.KafkaCluster) Test(org.junit.Test) OpenShiftOnly(io.strimzi.test.OpenShiftOnly)

Aggregations

OpenShiftOnly (io.strimzi.test.OpenShiftOnly)4 Oc (io.strimzi.test.k8s.Oc)4 Test (org.junit.Test)4 KafkaCluster (io.strimzi.test.KafkaCluster)2 Resources (io.strimzi.test.Resources)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1