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);
}
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");
});
}
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));
}
}
}
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");
});
}
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));
}
}
}
Aggregations