Search in sources :

Example 1 with Namespace

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

the class ControllerIT method waitForEvent.

private void waitForEvent(TestContext context, ConfigMap cm, String expectedMessage, Controller.EventType expectedType) {
    waitFor(context, () -> {
        List<Event> items = kubeClient.events().inNamespace(NAMESPACE).withLabels(cmPredicate.labels()).list().getItems();
        List<Event> filtered = items.stream().filter(evt -> !preExistingEvents.contains(evt.getMetadata().getUid()) && "ConfigMap".equals(evt.getInvolvedObject().getKind()) && cm.getMetadata().getName().equals(evt.getInvolvedObject().getName())).collect(Collectors.toList());
        LOGGER.debug("Waiting for events: {}", filtered.stream().map(evt -> evt.getMessage()).collect(Collectors.toList()));
        if (!filtered.isEmpty()) {
            assertEquals(1, filtered.size());
            Event event = filtered.get(0);
            assertEquals(expectedMessage, event.getMessage());
            assertEquals(expectedType.name, event.getType());
            assertNotNull(event.getInvolvedObject());
            assertEquals("ConfigMap", event.getInvolvedObject().getKind());
            assertEquals(cm.getMetadata().getName(), event.getInvolvedObject().getName());
            return true;
        } else {
            return false;
        }
    }, timeout, "Expected an error event");
}
Also used : TestContext(io.vertx.ext.unit.TestContext) ZookeeperServer(io.debezium.kafka.ZookeeperServer) LoggerFactory(org.slf4j.LoggerFactory) ConfigEntry(org.apache.kafka.clients.admin.ConfigEntry) BooleanSupplier(java.util.function.BooleanSupplier) Collections.singletonList(java.util.Collections.singletonList) AdminClient(org.apache.kafka.clients.admin.AdminClient) Locale(java.util.Locale) After(org.junit.After) Map(java.util.Map) DeleteTopicsResult(org.apache.kafka.clients.admin.DeleteTopicsResult) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) ClassRule(org.junit.ClassRule) KafkaCluster(io.debezium.kafka.KafkaCluster) AfterClass(org.junit.AfterClass) Event(io.fabric8.kubernetes.api.model.Event) Namespace(io.strimzi.test.Namespace) Set(java.util.Set) Future(io.vertx.core.Future) Collectors(java.util.stream.Collectors) List(java.util.List) AlterConfigsResult(org.apache.kafka.clients.admin.AlterConfigsResult) UnknownTopicOrPartitionException(org.apache.kafka.common.errors.UnknownTopicOrPartitionException) Async(io.vertx.ext.unit.Async) BeforeClass(org.junit.BeforeClass) NewPartitions(org.apache.kafka.clients.admin.NewPartitions) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) ConfigResource(org.apache.kafka.common.config.ConfigResource) KubeClusterResource(io.strimzi.test.k8s.KubeClusterResource) CreateTopicsResult(org.apache.kafka.clients.admin.CreateTopicsResult) Collections.singletonMap(java.util.Collections.singletonMap) Before(org.junit.Before) Collections.emptyMap(java.util.Collections.emptyMap) Logger(org.slf4j.Logger) Files(java.nio.file.Files) Assert.assertNotNull(org.junit.Assert.assertNotNull) Vertx(io.vertx.core.Vertx) NewTopic(org.apache.kafka.clients.admin.NewTopic) Test(org.junit.Test) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) CreatePartitionsResult(org.apache.kafka.clients.admin.CreatePartitionsResult) Field(java.lang.reflect.Field) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) ExecutionException(java.util.concurrent.ExecutionException) Ignore(org.junit.Ignore) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) Assert.assertEquals(org.junit.Assert.assertEquals) Event(io.fabric8.kubernetes.api.model.Event)

Aggregations

KafkaCluster (io.debezium.kafka.KafkaCluster)1 ZookeeperServer (io.debezium.kafka.ZookeeperServer)1 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)1 ConfigMapBuilder (io.fabric8.kubernetes.api.model.ConfigMapBuilder)1 Event (io.fabric8.kubernetes.api.model.Event)1 DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)1 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)1 Namespace (io.strimzi.test.Namespace)1 KubeClusterResource (io.strimzi.test.k8s.KubeClusterResource)1 Future (io.vertx.core.Future)1 Vertx (io.vertx.core.Vertx)1 Async (io.vertx.ext.unit.Async)1 TestContext (io.vertx.ext.unit.TestContext)1 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)1 Field (java.lang.reflect.Field)1 Files (java.nio.file.Files)1 Collections.emptyMap (java.util.Collections.emptyMap)1 Collections.singletonList (java.util.Collections.singletonList)1 Collections.singletonMap (java.util.Collections.singletonMap)1 HashMap (java.util.HashMap)1