diff --git a/HACKING.md b/HACKING.md index ba2ba605909..06896922029 100644 --- a/HACKING.md +++ b/HACKING.md @@ -223,3 +223,6 @@ Ex) ### Log level To set the log level of Strimzi for system tests need to add system property `TEST_STRIMZI_LOG_LEVEL` with one of the following values: `ERROR`, `WARNING`, `INFO`, `DEBUG`, `TRACE`. + +### Execute ST with custom Kafka version +To set custom Kafka version in system tests need to add system property `ST_KAFKA_VERSION` with one of the following values: `2.0.0`, `2.0.1`, `2.1.0` \ No newline at end of file diff --git a/systemtest/src/main/java/io/strimzi/systemtest/Resources.java b/systemtest/src/main/java/io/strimzi/systemtest/Resources.java index f1fc7dbb408..e47800e39e1 100644 --- a/systemtest/src/main/java/io/strimzi/systemtest/Resources.java +++ b/systemtest/src/main/java/io/strimzi/systemtest/Resources.java @@ -7,13 +7,13 @@ import io.fabric8.kubernetes.api.model.Doneable; import io.fabric8.kubernetes.api.model.EnvVar; import io.fabric8.kubernetes.api.model.HasMetadata; +import io.fabric8.kubernetes.api.model.KubernetesResourceList; +import io.fabric8.kubernetes.api.model.ObjectMetaBuilder; import io.fabric8.kubernetes.api.model.apps.Deployment; import io.fabric8.kubernetes.api.model.apps.DeploymentBuilder; import io.fabric8.kubernetes.api.model.apps.DeploymentList; import io.fabric8.kubernetes.api.model.apps.DoneableDeployment; import io.fabric8.kubernetes.api.model.batch.Job; -import io.fabric8.kubernetes.api.model.KubernetesResourceList; -import io.fabric8.kubernetes.api.model.ObjectMetaBuilder; import io.fabric8.kubernetes.api.model.rbac.DoneableKubernetesClusterRoleBinding; import io.fabric8.kubernetes.api.model.rbac.DoneableKubernetesRoleBinding; import io.fabric8.kubernetes.api.model.rbac.KubernetesClusterRoleBinding; @@ -76,6 +76,7 @@ public class Resources { private static final long TIMEOUT_FOR_DEPLOYMENT_CONFIG_READINESS = Duration.ofMinutes(7).toMillis(); private static final long TIMEOUT_FOR_RESOURCE_CREATION = Duration.ofMinutes(5).toMillis(); public static final long TIMEOUT_FOR_RESOURCE_READINESS = Duration.ofMinutes(7).toMillis(); + private static final String KAFKA_VERSION = System.getenv().getOrDefault("ST_KAFKA_VERSION", "2.1.0"); public static final String STRIMZI_PATH_TO_CO_CONFIG = "../install/cluster-operator/050-Deployment-strimzi-cluster-operator.yaml"; public static final String STRIMZI_DEPLOYMENT_NAME = "strimzi-cluster-operator"; @@ -245,6 +246,7 @@ public KafkaBuilder defaultKafka(String name, int kafkaReplicas) { .withMetadata(new ObjectMetaBuilder().withName(name).withNamespace(client().getNamespace()).build()) .withNewSpec() .withNewKafka() + .withVersion(KAFKA_VERSION) .withReplicas(kafkaReplicas) .withNewEphemeralStorage().endEphemeralStorage() .addToConfig("offsets.topic.replication.factor", Math.min(kafkaReplicas, 3)) @@ -323,6 +325,7 @@ private KafkaConnectBuilder defaultKafkaConnect(String name, int kafkaConnectRep return new KafkaConnectBuilder() .withMetadata(new ObjectMetaBuilder().withName(name).withNamespace(client().getNamespace()).build()) .withNewSpec() + .withVersion(KAFKA_VERSION) .withBootstrapServers(KafkaResources.plainBootstrapAddress(name)) .withReplicas(kafkaConnectReplicas) .withNewResources() @@ -369,6 +372,7 @@ private KafkaConnectS2IBuilder defaultKafkaConnectS2I(String name, int kafkaConn return new KafkaConnectS2IBuilder() .withMetadata(new ObjectMetaBuilder().withName(name).withNamespace(client().getNamespace()).build()) .withNewSpec() + .withVersion(KAFKA_VERSION) .withBootstrapServers(KafkaResources.plainBootstrapAddress(name)) .withReplicas(kafkaConnectS2IReplicas) .endSpec(); @@ -403,6 +407,7 @@ private KafkaMirrorMakerBuilder defaultMirrorMaker(String name, String sourceBoo return new KafkaMirrorMakerBuilder() .withMetadata(new ObjectMetaBuilder().withName(name).withNamespace(client().getNamespace()).build()) .withNewSpec() + .withVersion(KAFKA_VERSION) .withNewConsumer() .withBootstrapServers(tlsListener ? sourceBootstrapServer + "-kafka-bootstrap:9093" : sourceBootstrapServer + "-kafka-bootstrap:9092") .withGroupId(groupId) @@ -617,10 +622,10 @@ Deployment getDeploymentFromYaml(String yamlPath) { } DoneableDeployment clusterOperator(String namespace) { - return clusterOperator(defaultCLusterOperator(namespace).build()); + return clusterOperator(defaultClusterOperator(namespace).build()); } - DeploymentBuilder defaultCLusterOperator(String namespace) { + DeploymentBuilder defaultClusterOperator(String namespace) { Deployment clusterOperator = getDeploymentFromYaml(STRIMZI_PATH_TO_CO_CONFIG); diff --git a/systemtest/src/main/java/io/strimzi/systemtest/utils/StUtils.java b/systemtest/src/main/java/io/strimzi/systemtest/utils/StUtils.java index de72d7b1c07..a8554a8e620 100644 --- a/systemtest/src/main/java/io/strimzi/systemtest/utils/StUtils.java +++ b/systemtest/src/main/java/io/strimzi/systemtest/utils/StUtils.java @@ -147,7 +147,7 @@ public static Map waitTillDepHasRolled(KubernetesClient client, } public static File downloadAndUnzip(String url) throws IOException { - InputStream bais = (InputStream) URI.create(url).toURL().getContent(); + InputStream bais = (InputStream) URI.create(url).toURL().openConnection().getContent(); File dir = Files.createTempDirectory(StUtils.class.getName()).toFile(); dir.deleteOnExit(); ZipInputStream zin = new ZipInputStream(bais); diff --git a/systemtest/src/test/java/io/strimzi/systemtest/ConnectS2IST.java b/systemtest/src/test/java/io/strimzi/systemtest/ConnectS2IST.java index ed4c0726764..17c98db31a0 100644 --- a/systemtest/src/test/java/io/strimzi/systemtest/ConnectS2IST.java +++ b/systemtest/src/test/java/io/strimzi/systemtest/ConnectS2IST.java @@ -37,7 +37,7 @@ class ConnectS2IST extends AbstractST { @OpenShiftOnly @Tag(FLAKY) void testDeployS2IWithMongoDBPlugin() throws IOException { - resources().kafkaConnectS2I(CONNECT_CLUSTER_NAME, 1) + testClassResources.kafkaConnectS2I(CONNECT_CLUSTER_NAME, 1) .editMetadata() .addToLabels("type", "kafka-connect-s2i") .endMetadata() @@ -45,15 +45,12 @@ void testDeployS2IWithMongoDBPlugin() throws IOException { File dir = StUtils.downloadAndUnzip("https://repo1.maven.org/maven2/io/debezium/debezium-connector-mongodb/0.3.0/debezium-connector-mongodb-0.3.0-plugin.zip"); - String connectS2IPodName = KUBE_CLIENT.listResourcesByLabel("pod", "type=kafka-connect-s2i").get(0); - // Start a new image build using the plugins directory KUBE_CLIENT.exec("oc", "start-build", CONNECT_DEPLOYMENT_NAME, "--from-dir", dir.getAbsolutePath()); - KUBE_CLIENT.waitForResourceDeletion("pod", connectS2IPodName); KUBE_CLIENT.waitForDeploymentConfig(CONNECT_DEPLOYMENT_NAME); - connectS2IPodName = KUBE_CLIENT.listResourcesByLabel("pod", "type=kafka-connect-s2i").get(0); + String connectS2IPodName = KUBE_CLIENT.listResourcesByLabel("pod", "type=kafka-connect-s2i").get(0); String plugins = KUBE_CLIENT.execInPod(connectS2IPodName, "curl", "-X", "GET", "http://localhost:8083/connector-plugins").out(); assertThat(plugins, containsString("io.debezium.connector.mongodb.MongoDbConnector")); diff --git a/test/src/main/java/io/strimzi/test/TestUtils.java b/test/src/main/java/io/strimzi/test/TestUtils.java index ca93114aedb..380adda9b08 100644 --- a/test/src/main/java/io/strimzi/test/TestUtils.java +++ b/test/src/main/java/io/strimzi/test/TestUtils.java @@ -70,7 +70,7 @@ public final class TestUtils { public static final String CRD_KAFKA_MIRROR_MAKER = "../install/cluster-operator/045-Crd-kafkamirrormaker.yaml"; - private static final Pattern KAFKA_COMPONENT_PATTERN = Pattern.compile(":([^:]*?)-kafka-([0-9.]+)$"); + private static final Pattern KAFKA_COMPONENT_PATTERN = Pattern.compile(":([^:]*?)-kafka-(?[0-9.])"); private static final Pattern VERSION_IMAGE_PATTERN = Pattern.compile("(?[0-9.]+)=(?[^\\s]*)"); private TestUtils() { @@ -147,12 +147,12 @@ public static String getFileAsString(String filePath) { return ""; } - public static String changeOrgAndTag(String image, String newOrg, String newTag, String kafkaVersion) { + public static String changeOrgAndTag(String image, String newOrg, String newTag) { image = image.replaceFirst("^strimzi/", newOrg + "/"); Matcher m = KAFKA_COMPONENT_PATTERN.matcher(image); StringBuffer sb = new StringBuffer(); if (m.find()) { - m.appendReplacement(sb, ":" + newTag + "-kafka-" + kafkaVersion); + m.appendReplacement(sb, ":" + newTag + "-kafka-" + m.group("version")); m.appendTail(sb); image = sb.toString(); } else { @@ -164,11 +164,9 @@ public static String changeOrgAndTag(String image, String newOrg, String newTag, public static String changeOrgAndTag(String image) { String strimziOrg = "strimzi"; String strimziTag = "latest"; - String kafkaVersion = "2.1.0"; String dockerOrg = System.getenv().getOrDefault("DOCKER_ORG", strimziOrg); String dockerTag = System.getenv().getOrDefault("DOCKER_TAG", strimziTag); - kafkaVersion = System.getenv().getOrDefault("KAFKA_VERSION", kafkaVersion); - return changeOrgAndTag(image, dockerOrg, dockerTag, kafkaVersion); + return changeOrgAndTag(image, dockerOrg, dockerTag); } public static String changeOrgAndTagInImageMap(String imageMap) {