Fix deprecation issue related to KafkaContainer 17/140117/1
authormpriyank <priyank.maheshwari@est.tech>
Thu, 30 Jan 2025 16:37:18 +0000 (16:37 +0000)
committermpriyank <priyank.maheshwari@est.tech>
Thu, 30 Jan 2025 16:38:49 +0000 (16:38 +0000)
- Replaced KafkaContainer with ConfluentKafkaContainer to fix the
  deprecation issue
- Bumped the version of cp-kafka and cp-zookeeper to 7.8.0
- Removing reference of registry.nordix as the NCMP internal pipeline is no
  longer used

Issue-ID: CPS-2608
Change-Id: Ic1f3edbc06d63c5f00c1ecb901e07a6bc17ae6eb
Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/utils/events/MessagingBaseSpec.groovy
docker-compose/docker-compose.yml
integration-test/src/test/java/org/onap/cps/integration/KafkaTestContainer.java

index 377a1a6..d38d544 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- * Copyright (c) 2023 Nordix Foundation.
+ * Copyright (c) 2023-2025 Nordix Foundation.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -29,8 +29,7 @@ import org.springframework.kafka.core.KafkaTemplate
 import org.springframework.kafka.support.serializer.JsonSerializer
 import org.springframework.test.context.DynamicPropertyRegistry
 import org.springframework.test.context.DynamicPropertySource
-import org.testcontainers.containers.KafkaContainer
-import org.testcontainers.utility.DockerImageName
+import org.testcontainers.kafka.ConfluentKafkaContainer
 import spock.lang.Specification
 
 class MessagingBaseSpec extends Specification {
@@ -43,7 +42,7 @@ class MessagingBaseSpec extends Specification {
         kafkaTestContainer.stop()
     }
 
-    static kafkaTestContainer = new KafkaContainer(DockerImageName.parse('registry.nordix.org/onaptest/confluentinc/cp-kafka:6.2.1').asCompatibleSubstituteFor('confluentinc/cp-kafka'))
+    static kafkaTestContainer = new ConfluentKafkaContainer("confluentinc/cp-kafka:7.8.0")
 
     def legacyEventKafkaTemplate = new KafkaTemplate<>(new DefaultKafkaProducerFactory<String, String>(eventProducerConfigProperties(JsonSerializer)))
 
index fe69660..5b7db68 100644 (file)
@@ -96,7 +96,7 @@ services:
 
   ### if kafka is not required comment out zookeeper and kafka ###
   zookeeper:
-    image: confluentinc/cp-zookeeper:6.2.1
+    image: confluentinc/cp-zookeeper:7.8.0
     container_name: ${ZOOKEEPER_CONTAINER_NAME:-zookeeper}
     ports:
       - ${ZOOKEEPER_PORT:-2181}:2181
@@ -104,7 +104,7 @@ services:
       ZOOKEEPER_CLIENT_PORT: 2181
 
   kafka:
-    image: confluentinc/cp-kafka:6.2.1
+    image: confluentinc/cp-kafka:7.8.0
     container_name: ${KAFKA_CONTAINER_NAME:-kafka}
     ports:
       - ${KAFKA_PORT:-9092}:9092
index ff4aec4..60c1637 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2024 Nordix Foundation.
+ *  Copyright (C) 2024-2025 Nordix Foundation.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -25,8 +25,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.kafka.clients.consumer.ConsumerConfig;
 import org.apache.kafka.clients.consumer.KafkaConsumer;
 import org.apache.kafka.common.serialization.StringDeserializer;
-import org.testcontainers.containers.KafkaContainer;
-import org.testcontainers.utility.DockerImageName;
+import org.testcontainers.kafka.ConfluentKafkaContainer;
 
 /**
  * The Apache Kafka test container wrapper.
@@ -35,14 +34,14 @@ import org.testcontainers.utility.DockerImageName;
  * Avoid unnecessary resource and time consumption.
  */
 @Slf4j
-public class KafkaTestContainer extends KafkaContainer {
+public class KafkaTestContainer extends ConfluentKafkaContainer {
 
-    private static final String IMAGE_NAME_AND_VERSION = "registry.nordix.org/onaptest/confluentinc/cp-kafka:6.2.1";
+    private static final String IMAGE_NAME_AND_VERSION = "confluentinc/cp-kafka:7.8.0";
 
     private static volatile KafkaTestContainer kafkaTestContainer;
 
     private KafkaTestContainer() {
-        super(DockerImageName.parse(IMAGE_NAME_AND_VERSION).asCompatibleSubstituteFor("confluentinc/cp-kafka"));
+        super(IMAGE_NAME_AND_VERSION);
     }
 
     /**