Search in sources :

Example 1 with ExecResult

use of io.strimzi.test.executor.ExecResult in project strimzi by strimzi.

the class KeycloakUtils method deployKeycloak.

public static void deployKeycloak(String namespace) {
    LOGGER.info("Prepare Keycloak in namespace: {}", namespace);
    // This is needed because from time to time the first try fails on Azure
    TestUtils.waitFor("Keycloak instance readiness", Constants.KEYCLOAK_DEPLOYMENT_POLL, Constants.KEYCLOAK_DEPLOYMENT_TIMEOUT, () -> {
        ExecResult result = Exec.exec(Level.INFO, "/bin/bash", PATH_TO_KEYCLOAK_PREPARE_SCRIPT, namespace, getValidKeycloakVersion());
        if (!result.out().contains("All realms were successfully imported")) {
            LOGGER.info("Errors occurred during Keycloak install: {}", result.err());
            return false;
        }
        return true;
    });
    LOGGER.info("Keycloak in namespace {} is ready", namespace);
}
Also used : ExecResult(io.strimzi.test.executor.ExecResult)

Example 2 with ExecResult

use of io.strimzi.test.executor.ExecResult in project strimzi by strimzi.

the class UserST method testUserWithQuotas.

synchronized void testUserWithQuotas(ExtensionContext extensionContext, KafkaUser user) {
    final Integer prodRate = 1111;
    final Integer consRate = 2222;
    final Integer reqPerc = 42;
    final Double mutRate = 10d;
    // Create user with correct name
    resourceManager.createResource(extensionContext, KafkaUserTemplates.userWithQuotas(user, prodRate, consRate, reqPerc, mutRate).editMetadata().withNamespace(namespace).endMetadata().build());
    final String userName = KafkaUserResource.kafkaUserClient().inNamespace(namespace).withName(user.getMetadata().getName()).get().getStatus().getUsername();
    String command = "bin/kafka-configs.sh --bootstrap-server localhost:9092 --describe --user " + userName;
    LOGGER.debug("Command for kafka-configs.sh {}", command);
    ExecResult result = cmdKubeClient(namespace).execInPod(KafkaResources.kafkaPodName(userClusterName, 0), "/bin/bash", "-c", command);
    assertThat(result.out().contains("Quota configs for user-principal '" + userName + "' are"), is(true));
    assertThat(result.out().contains("request_percentage=" + reqPerc), is(true));
    assertThat(result.out().contains("producer_byte_rate=" + prodRate), is(true));
    assertThat(result.out().contains("consumer_byte_rate=" + consRate), is(true));
    assertThat(result.out().contains("controller_mutation_rate=" + mutRate), is(true));
    // delete user
    KafkaUserResource.kafkaUserClient().inNamespace(namespace).withName(user.getMetadata().getName()).withPropagationPolicy(DeletionPropagation.FOREGROUND).delete();
    KafkaUserUtils.waitForKafkaUserDeletion(namespace, user.getMetadata().getName());
    TestUtils.waitFor("all KafkaUser " + userName + " attributes will be cleaned", Constants.GLOBAL_POLL_INTERVAL, Constants.GLOBAL_TIMEOUT, () -> {
        ExecResult resultAfterDelete = cmdKubeClient(namespace).execInPod(KafkaResources.kafkaPodName(userClusterName, 0), "/bin/bash", "-c", command);
        return !resultAfterDelete.out().contains(userName) && !resultAfterDelete.out().contains("request_percentage") && !resultAfterDelete.out().contains("producer_byte_rate") && !resultAfterDelete.out().contains("consumer_byte_rate") && !resultAfterDelete.out().contains("controller_mutation_rate");
    });
}
Also used : ExecResult(io.strimzi.test.executor.ExecResult)

Example 3 with ExecResult

use of io.strimzi.test.executor.ExecResult in project strimzi-kafka-operator by strimzi.

the class KafkaST method checkKafkaConfiguration.

protected void checkKafkaConfiguration(String namespaceName, String podNamePrefix, Map<String, Object> config, String clusterName) {
    LOGGER.info("Checking kafka configuration");
    List<Pod> pods = kubeClient(namespaceName).listPodsByPrefixInName(namespaceName, podNamePrefix);
    Properties properties = configMap2Properties(kubeClient(namespaceName).getConfigMap(namespaceName, clusterName + "-kafka-config"));
    for (Map.Entry<String, Object> property : config.entrySet()) {
        String key = property.getKey();
        Object val = property.getValue();
        assertThat(properties.keySet().contains(key), is(true));
        assertThat(properties.getProperty(key), is(val));
    }
    for (Pod pod : pods) {
        ExecResult result = cmdKubeClient(namespaceName).execInPod(pod.getMetadata().getName(), "/bin/bash", "-c", "cat /tmp/strimzi.properties");
        Properties execProperties = stringToProperties(result.out());
        for (Map.Entry<String, Object> property : config.entrySet()) {
            String key = property.getKey();
            Object val = property.getValue();
            assertThat(execProperties.keySet().contains(key), is(true));
            assertThat(execProperties.getProperty(key), is(val));
        }
    }
}
Also used : Pod(io.fabric8.kubernetes.api.model.Pod) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.emptyOrNullString(org.hamcrest.Matchers.emptyOrNullString) TestUtils.fromYamlString(io.strimzi.test.TestUtils.fromYamlString) StUtils.configMap2Properties(io.strimzi.systemtest.utils.StUtils.configMap2Properties) StUtils.stringToProperties(io.strimzi.systemtest.utils.StUtils.stringToProperties) Properties(java.util.Properties) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ExecResult(io.strimzi.test.executor.ExecResult)

Example 4 with ExecResult

use of io.strimzi.test.executor.ExecResult in project strimzi-kafka-operator by strimzi.

the class UserST method testUserWithQuotas.

synchronized void testUserWithQuotas(ExtensionContext extensionContext, KafkaUser user) {
    final Integer prodRate = 1111;
    final Integer consRate = 2222;
    final Integer reqPerc = 42;
    final Double mutRate = 10d;
    // Create user with correct name
    resourceManager.createResource(extensionContext, KafkaUserTemplates.userWithQuotas(user, prodRate, consRate, reqPerc, mutRate).editMetadata().withNamespace(namespace).endMetadata().build());
    final String userName = KafkaUserResource.kafkaUserClient().inNamespace(namespace).withName(user.getMetadata().getName()).get().getStatus().getUsername();
    String command = "bin/kafka-configs.sh --bootstrap-server localhost:9092 --describe --user " + userName;
    LOGGER.debug("Command for kafka-configs.sh {}", command);
    ExecResult result = cmdKubeClient(namespace).execInPod(KafkaResources.kafkaPodName(userClusterName, 0), "/bin/bash", "-c", command);
    assertThat(result.out().contains("Quota configs for user-principal '" + userName + "' are"), is(true));
    assertThat(result.out().contains("request_percentage=" + reqPerc), is(true));
    assertThat(result.out().contains("producer_byte_rate=" + prodRate), is(true));
    assertThat(result.out().contains("consumer_byte_rate=" + consRate), is(true));
    assertThat(result.out().contains("controller_mutation_rate=" + mutRate), is(true));
    // delete user
    KafkaUserResource.kafkaUserClient().inNamespace(namespace).withName(user.getMetadata().getName()).withPropagationPolicy(DeletionPropagation.FOREGROUND).delete();
    KafkaUserUtils.waitForKafkaUserDeletion(namespace, user.getMetadata().getName());
    TestUtils.waitFor("all KafkaUser " + userName + " attributes will be cleaned", Constants.GLOBAL_POLL_INTERVAL, Constants.GLOBAL_TIMEOUT, () -> {
        ExecResult resultAfterDelete = cmdKubeClient(namespace).execInPod(KafkaResources.kafkaPodName(userClusterName, 0), "/bin/bash", "-c", command);
        return !resultAfterDelete.out().contains(userName) && !resultAfterDelete.out().contains("request_percentage") && !resultAfterDelete.out().contains("producer_byte_rate") && !resultAfterDelete.out().contains("consumer_byte_rate") && !resultAfterDelete.out().contains("controller_mutation_rate");
    });
}
Also used : ExecResult(io.strimzi.test.executor.ExecResult)

Example 5 with ExecResult

use of io.strimzi.test.executor.ExecResult in project strimzi by strimzi.

the class KafkaST method checkKafkaConfiguration.

protected void checkKafkaConfiguration(String namespaceName, String podNamePrefix, Map<String, Object> config, String clusterName) {
    LOGGER.info("Checking kafka configuration");
    List<Pod> pods = kubeClient(namespaceName).listPodsByPrefixInName(namespaceName, podNamePrefix);
    Properties properties = configMap2Properties(kubeClient(namespaceName).getConfigMap(namespaceName, clusterName + "-kafka-config"));
    for (Map.Entry<String, Object> property : config.entrySet()) {
        String key = property.getKey();
        Object val = property.getValue();
        assertThat(properties.keySet().contains(key), is(true));
        assertThat(properties.getProperty(key), is(val));
    }
    for (Pod pod : pods) {
        ExecResult result = cmdKubeClient(namespaceName).execInPod(pod.getMetadata().getName(), "/bin/bash", "-c", "cat /tmp/strimzi.properties");
        Properties execProperties = stringToProperties(result.out());
        for (Map.Entry<String, Object> property : config.entrySet()) {
            String key = property.getKey();
            Object val = property.getValue();
            assertThat(execProperties.keySet().contains(key), is(true));
            assertThat(execProperties.getProperty(key), is(val));
        }
    }
}
Also used : Pod(io.fabric8.kubernetes.api.model.Pod) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.emptyOrNullString(org.hamcrest.Matchers.emptyOrNullString) TestUtils.fromYamlString(io.strimzi.test.TestUtils.fromYamlString) StUtils.configMap2Properties(io.strimzi.systemtest.utils.StUtils.configMap2Properties) StUtils.stringToProperties(io.strimzi.systemtest.utils.StUtils.stringToProperties) Properties(java.util.Properties) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ExecResult(io.strimzi.test.executor.ExecResult)

Aggregations

ExecResult (io.strimzi.test.executor.ExecResult)8 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)2 Pod (io.fabric8.kubernetes.api.model.Pod)2 StUtils.configMap2Properties (io.strimzi.systemtest.utils.StUtils.configMap2Properties)2 StUtils.stringToProperties (io.strimzi.systemtest.utils.StUtils.stringToProperties)2 TestUtils.fromYamlString (io.strimzi.test.TestUtils.fromYamlString)2 File (java.io.File)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Properties (java.util.Properties)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Matchers.emptyOrNullString (org.hamcrest.Matchers.emptyOrNullString)2