From d620c9cda76e208d14e5ac83be43859f80a01ead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Greffier?= Date: Tue, 20 Aug 2024 14:17:19 +0200 Subject: [PATCH] Remove old config --- .../integration/AclIntegrationTest.java | 2 -- .../ApiResourcesIntegrationTest.java | 2 -- .../integration/ConnectorIntegrationTest.java | 2 -- .../ExceptionHandlerIntegrationTest.java | 2 -- .../integration/LoginIntegrationTest.java | 2 -- .../integration/NamespaceIntegrationTest.java | 2 -- .../integration/SchemaIntegrationTest.java | 2 -- .../integration/StreamIntegrationTest.java | 2 -- .../integration/TopicIntegrationTest.java | 24 +++++++++++-------- .../integration/UserIntegrationTest.java | 2 -- src/test/resources/application-test.yml | 7 ++++-- 11 files changed, 19 insertions(+), 30 deletions(-) diff --git a/src/test/java/com/michelin/ns4kafka/integration/AclIntegrationTest.java b/src/test/java/com/michelin/ns4kafka/integration/AclIntegrationTest.java index 83a740a9..727b1396 100644 --- a/src/test/java/com/michelin/ns4kafka/integration/AclIntegrationTest.java +++ b/src/test/java/com/michelin/ns4kafka/integration/AclIntegrationTest.java @@ -22,7 +22,6 @@ import com.michelin.ns4kafka.model.RoleBinding.Verb; import com.michelin.ns4kafka.service.executor.AccessControlEntryAsyncExecutor; import com.michelin.ns4kafka.validation.TopicValidator; -import io.micronaut.context.annotation.Property; import io.micronaut.http.HttpMethod; import io.micronaut.http.HttpRequest; import io.micronaut.http.HttpResponse; @@ -48,7 +47,6 @@ import org.junit.jupiter.api.Test; @MicronautTest -@Property(name = "micronaut.security.gitlab.enabled", value = "false") class AclIntegrationTest extends KafkaIntegrationTest { @Inject @Client("/") diff --git a/src/test/java/com/michelin/ns4kafka/integration/ApiResourcesIntegrationTest.java b/src/test/java/com/michelin/ns4kafka/integration/ApiResourcesIntegrationTest.java index 4d854f1a..b2d6942a 100644 --- a/src/test/java/com/michelin/ns4kafka/integration/ApiResourcesIntegrationTest.java +++ b/src/test/java/com/michelin/ns4kafka/integration/ApiResourcesIntegrationTest.java @@ -8,7 +8,6 @@ import com.michelin.ns4kafka.model.Namespace; import com.michelin.ns4kafka.model.RoleBinding; import com.michelin.ns4kafka.validation.TopicValidator; -import io.micronaut.context.annotation.Property; import io.micronaut.core.type.Argument; import io.micronaut.http.HttpMethod; import io.micronaut.http.HttpRequest; @@ -22,7 +21,6 @@ import org.junit.jupiter.api.Test; @MicronautTest -@Property(name = "micronaut.security.gitlab.enabled", value = "false") class ApiResourcesIntegrationTest extends KafkaIntegrationTest { @Inject @Client("/") diff --git a/src/test/java/com/michelin/ns4kafka/integration/ConnectorIntegrationTest.java b/src/test/java/com/michelin/ns4kafka/integration/ConnectorIntegrationTest.java index 09699a58..55c456c8 100644 --- a/src/test/java/com/michelin/ns4kafka/integration/ConnectorIntegrationTest.java +++ b/src/test/java/com/michelin/ns4kafka/integration/ConnectorIntegrationTest.java @@ -33,7 +33,6 @@ import com.michelin.ns4kafka.validation.ConnectValidator; import com.michelin.ns4kafka.validation.TopicValidator; import io.micronaut.context.ApplicationContext; -import io.micronaut.context.annotation.Property; import io.micronaut.http.HttpMethod; import io.micronaut.http.HttpRequest; import io.micronaut.http.HttpResponse; @@ -54,7 +53,6 @@ @Slf4j @MicronautTest -@Property(name = "micronaut.security.gitlab.enabled", value = "false") class ConnectorIntegrationTest extends KafkaConnectIntegrationTest { @Inject private ApplicationContext applicationContext; diff --git a/src/test/java/com/michelin/ns4kafka/integration/ExceptionHandlerIntegrationTest.java b/src/test/java/com/michelin/ns4kafka/integration/ExceptionHandlerIntegrationTest.java index 93c23367..6b091ab2 100644 --- a/src/test/java/com/michelin/ns4kafka/integration/ExceptionHandlerIntegrationTest.java +++ b/src/test/java/com/michelin/ns4kafka/integration/ExceptionHandlerIntegrationTest.java @@ -24,7 +24,6 @@ import com.michelin.ns4kafka.model.Topic; import com.michelin.ns4kafka.model.Topic.TopicSpec; import com.michelin.ns4kafka.validation.TopicValidator; -import io.micronaut.context.annotation.Property; import io.micronaut.http.HttpMethod; import io.micronaut.http.HttpRequest; import io.micronaut.http.HttpResponse; @@ -42,7 +41,6 @@ import org.junit.jupiter.api.Test; @MicronautTest -@Property(name = "micronaut.security.gitlab.enabled", value = "false") class ExceptionHandlerIntegrationTest extends KafkaIntegrationTest { @Inject @Client("/") diff --git a/src/test/java/com/michelin/ns4kafka/integration/LoginIntegrationTest.java b/src/test/java/com/michelin/ns4kafka/integration/LoginIntegrationTest.java index f7097ac5..afcb4314 100644 --- a/src/test/java/com/michelin/ns4kafka/integration/LoginIntegrationTest.java +++ b/src/test/java/com/michelin/ns4kafka/integration/LoginIntegrationTest.java @@ -3,7 +3,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import com.michelin.ns4kafka.integration.container.KafkaIntegrationTest; -import io.micronaut.context.annotation.Property; import io.micronaut.http.HttpRequest; import io.micronaut.http.HttpResponse; import io.micronaut.http.HttpStatus; @@ -15,7 +14,6 @@ import org.junit.jupiter.api.Test; @MicronautTest -@Property(name = "micronaut.security.gitlab.enabled", value = "false") class LoginIntegrationTest extends KafkaIntegrationTest { @Inject @Client("/") diff --git a/src/test/java/com/michelin/ns4kafka/integration/NamespaceIntegrationTest.java b/src/test/java/com/michelin/ns4kafka/integration/NamespaceIntegrationTest.java index 694cf288..1bc60111 100644 --- a/src/test/java/com/michelin/ns4kafka/integration/NamespaceIntegrationTest.java +++ b/src/test/java/com/michelin/ns4kafka/integration/NamespaceIntegrationTest.java @@ -12,7 +12,6 @@ import com.michelin.ns4kafka.model.Status; import com.michelin.ns4kafka.model.Topic; import com.michelin.ns4kafka.validation.TopicValidator; -import io.micronaut.context.annotation.Property; import io.micronaut.http.HttpMethod; import io.micronaut.http.HttpRequest; import io.micronaut.http.HttpResponse; @@ -30,7 +29,6 @@ import org.junit.jupiter.api.Test; @MicronautTest -@Property(name = "micronaut.security.gitlab.enabled", value = "false") class NamespaceIntegrationTest extends KafkaIntegrationTest { @Inject @Client("/") diff --git a/src/test/java/com/michelin/ns4kafka/integration/SchemaIntegrationTest.java b/src/test/java/com/michelin/ns4kafka/integration/SchemaIntegrationTest.java index 06d2703b..18ea97f1 100644 --- a/src/test/java/com/michelin/ns4kafka/integration/SchemaIntegrationTest.java +++ b/src/test/java/com/michelin/ns4kafka/integration/SchemaIntegrationTest.java @@ -19,7 +19,6 @@ import io.confluent.kafka.schemaregistry.client.rest.entities.requests.RegisterSchemaRequest; import io.confluent.kafka.schemaregistry.client.rest.entities.requests.RegisterSchemaResponse; import io.micronaut.context.ApplicationContext; -import io.micronaut.context.annotation.Property; import io.micronaut.core.type.Argument; import io.micronaut.http.HttpMethod; import io.micronaut.http.HttpRequest; @@ -37,7 +36,6 @@ import org.junit.jupiter.api.Test; @MicronautTest -@Property(name = "micronaut.security.gitlab.enabled", value = "false") class SchemaIntegrationTest extends SchemaRegistryIntegrationTest { @Inject private ApplicationContext applicationContext; diff --git a/src/test/java/com/michelin/ns4kafka/integration/StreamIntegrationTest.java b/src/test/java/com/michelin/ns4kafka/integration/StreamIntegrationTest.java index a226c930..3faf89d7 100644 --- a/src/test/java/com/michelin/ns4kafka/integration/StreamIntegrationTest.java +++ b/src/test/java/com/michelin/ns4kafka/integration/StreamIntegrationTest.java @@ -16,7 +16,6 @@ import com.michelin.ns4kafka.model.Namespace.NamespaceSpec; import com.michelin.ns4kafka.service.executor.AccessControlEntryAsyncExecutor; import com.michelin.ns4kafka.validation.TopicValidator; -import io.micronaut.context.annotation.Property; import io.micronaut.http.HttpMethod; import io.micronaut.http.HttpRequest; import io.micronaut.http.HttpResponse; @@ -37,7 +36,6 @@ import org.junit.jupiter.api.Test; @MicronautTest -@Property(name = "micronaut.security.gitlab.enabled", value = "false") class StreamIntegrationTest extends KafkaIntegrationTest { @Inject @Client("/") diff --git a/src/test/java/com/michelin/ns4kafka/integration/TopicIntegrationTest.java b/src/test/java/com/michelin/ns4kafka/integration/TopicIntegrationTest.java index c59d7bd2..f1c7f4c0 100644 --- a/src/test/java/com/michelin/ns4kafka/integration/TopicIntegrationTest.java +++ b/src/test/java/com/michelin/ns4kafka/integration/TopicIntegrationTest.java @@ -29,7 +29,6 @@ import com.michelin.ns4kafka.model.Topic.TopicSpec; import com.michelin.ns4kafka.service.executor.TopicAsyncExecutor; import com.michelin.ns4kafka.validation.TopicValidator; -import io.micronaut.context.annotation.Property; import io.micronaut.core.type.Argument; import io.micronaut.http.HttpMethod; import io.micronaut.http.HttpRequest; @@ -57,7 +56,6 @@ import org.junit.jupiter.api.Test; @MicronautTest -@Property(name = "micronaut.security.gitlab.enabled", value = "false") class TopicIntegrationTest extends KafkaIntegrationTest { @Inject @Client("/") @@ -263,7 +261,7 @@ void shouldCreateTopic() throws InterruptedException, ExecutionException { assertEquals("created", response.header("X-Ns4kafka-Result")); - topicAsyncExecutorList.forEach(TopicAsyncExecutor::run); + forceTopicSynchronization(); Admin kafkaClient = getAdminClient(); @@ -319,7 +317,7 @@ void shouldUpdateTopic() throws InterruptedException, ExecutionException { assertEquals("created", response.header("X-Ns4kafka-Result")); - topicAsyncExecutorList.forEach(TopicAsyncExecutor::run); + forceTopicSynchronization(); response = ns4KafkaClient .toBlocking() @@ -354,8 +352,7 @@ void shouldUpdateTopic() throws InterruptedException, ExecutionException { assertEquals("changed", response.header("X-Ns4kafka-Result")); - // Force Topic Sync - topicAsyncExecutorList.forEach(TopicAsyncExecutor::run); + forceTopicSynchronization(); Admin kafkaClient = getAdminClient(); @@ -496,7 +493,7 @@ void shouldUpdateTopicWithNoChange() { } @Test - void shouldDeleteRecords() { + void shouldDeleteRecords() throws InterruptedException { Topic topicToDelete = Topic.builder() .metadata(Metadata.builder() .name("ns1-topicToDelete") @@ -520,7 +517,7 @@ void shouldDeleteRecords() { assertEquals("created", response.header("X-Ns4kafka-Result")); - topicAsyncExecutorList.forEach(TopicAsyncExecutor::run); + forceTopicSynchronization(); List deleteRecordsResponse = ns4KafkaClient .toBlocking() @@ -565,7 +562,7 @@ void shouldDeleteRecords() { } @Test - void shouldDeleteRecordsOnCompactTopic() { + void shouldDeleteRecordsOnCompactTopic() throws InterruptedException { Topic topicToDelete = Topic.builder() .metadata(Metadata.builder() .name("ns1-compactTopicToDelete") @@ -590,7 +587,7 @@ void shouldDeleteRecordsOnCompactTopic() { assertEquals("created", response.header("X-Ns4kafka-Result")); - topicAsyncExecutorList.forEach(TopicAsyncExecutor::run); + forceTopicSynchronization(); HttpClientResponseException exception = assertThrows(HttpClientResponseException.class, () -> ns4KafkaClient @@ -602,6 +599,13 @@ void shouldDeleteRecordsOnCompactTopic() { assertEquals(HttpStatus.UNPROCESSABLE_ENTITY, exception.getStatus()); } + private void forceTopicSynchronization() throws InterruptedException { + topicAsyncExecutorList.forEach(TopicAsyncExecutor::run); + + // Wait for topics to be updated in Kafka broker + Thread.sleep(2000); + } + @Data @NoArgsConstructor @AllArgsConstructor diff --git a/src/test/java/com/michelin/ns4kafka/integration/UserIntegrationTest.java b/src/test/java/com/michelin/ns4kafka/integration/UserIntegrationTest.java index ce384d11..e78c227f 100644 --- a/src/test/java/com/michelin/ns4kafka/integration/UserIntegrationTest.java +++ b/src/test/java/com/michelin/ns4kafka/integration/UserIntegrationTest.java @@ -13,7 +13,6 @@ import com.michelin.ns4kafka.model.quota.ResourceQuota; import com.michelin.ns4kafka.service.executor.UserAsyncExecutor; import com.michelin.ns4kafka.validation.TopicValidator; -import io.micronaut.context.annotation.Property; import io.micronaut.http.HttpMethod; import io.micronaut.http.HttpRequest; import io.micronaut.http.HttpResponse; @@ -36,7 +35,6 @@ import org.junit.jupiter.api.Test; @MicronautTest -@Property(name = "micronaut.security.gitlab.enabled", value = "false") class UserIntegrationTest extends KafkaIntegrationTest { @Inject @Client("/") diff --git a/src/test/resources/application-test.yml b/src/test/resources/application-test.yml index 7a643d25..48e9fcf3 100644 --- a/src/test/resources/application-test.yml +++ b/src/test/resources/application-test.yml @@ -1,6 +1,9 @@ +micronaut: + security: + gitlab: + enabled: false + kafka: - embedded: - enabled: false bootstrap.servers: "localhost:9092" # Replaced by Testcontainers sasl.mechanism: "PLAIN" security.protocol: "SASL_PLAINTEXT"