Skip to content

Commit

Permalink
[improve][test] Upgrade testcontainers to 1.17.2 (apache#16161)
Browse files Browse the repository at this point in the history
* [improve][test] Upgrade testcontainers to 1.17.2

* migrate getContainerIpAddress to getHost

* fix compile

* remove usage of shaded lib from testcontainers

(cherry picked from commit c8f03e8)
  • Loading branch information
nicoloboschi committed Nov 23, 2022
1 parent a54e074 commit 6b65c9d
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@ flexible messaging model and an intuitive client API.</description>
<!-- test dependencies -->
<cassandra.version>3.6.0</cassandra.version>
<disruptor.version>3.4.0</disruptor.version>
<testcontainers.version>1.15.3</testcontainers.version>
<testcontainers.version>1.17.2</testcontainers.version>
<hamcrest.version>2.2</hamcrest.version>

<!-- Set docker-java.version to the version of docker-java used in Testcontainers -->
<docker-java.version>3.2.8</docker-java.version>
<docker-java.version>3.2.13</docker-java.version>
<kerby.version>1.1.1</kerby.version>
<testng.version>7.3.0</testng.version>
<junit4.version>4.13.1</junit4.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public PulsarContainer(final String pulsarVersion) {
}

public String getPlainTextPulsarBrokerUrl() {
return String.format("pulsar://%s:%s", this.getContainerIpAddress(), this.getMappedPort(PULSAR_PORT));
return String.format("pulsar://%s:%s", this.getHost(), this.getMappedPort(PULSAR_PORT));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public PulsarContainer(final String pulsarVersion) {
}

public String getPlainTextPulsarBrokerUrl() {
return String.format("pulsar://%s:%s", this.getContainerIpAddress(), this.getMappedPort(PULSAR_PORT));
return String.format("pulsar://%s:%s", this.getHost(), this.getMappedPort(PULSAR_PORT));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public PulsarContainer(final String pulsarVersion) {
}

public String getPlainTextPulsarBrokerUrl() {
return String.format("pulsar://%s:%s", this.getContainerIpAddress(), this.getMappedPort(PULSAR_PORT));
return String.format("pulsar://%s:%s", this.getHost(), this.getMappedPort(PULSAR_PORT));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/
package org.apache.pulsar.tests.integration.cli;

import org.apache.commons.lang3.RandomStringUtils;
import org.apache.pulsar.tests.TestRetrySupport;
import org.apache.pulsar.tests.integration.containers.BrokerContainer;
import org.apache.pulsar.tests.integration.docker.ContainerExecResult;
import org.apache.pulsar.tests.integration.topologies.PulsarCluster;
import org.apache.pulsar.tests.integration.topologies.PulsarClusterSpec;
import org.testcontainers.shaded.org.apache.commons.lang.RandomStringUtils;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/
package org.apache.pulsar.tests.integration.cli;

import org.apache.commons.lang3.RandomStringUtils;
import org.apache.pulsar.tests.TestRetrySupport;
import org.apache.pulsar.tests.integration.containers.BrokerContainer;
import org.apache.pulsar.tests.integration.docker.ContainerExecResult;
import org.apache.pulsar.tests.integration.topologies.PulsarCluster;
import org.apache.pulsar.tests.integration.topologies.PulsarClusterSpec;
import org.testcontainers.shaded.org.apache.commons.lang.RandomStringUtils;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
*/
package org.apache.pulsar.tests.integration.cli;

import org.apache.commons.lang3.RandomStringUtils;
import org.apache.pulsar.tests.TestRetrySupport;
import org.apache.pulsar.tests.integration.docker.ContainerExecResult;
import org.apache.pulsar.tests.integration.topologies.PulsarCluster;
import org.apache.pulsar.tests.integration.topologies.PulsarClusterSpec;
import org.testcontainers.shaded.org.apache.commons.lang.RandomStringUtils;

import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ protected void beforeStop() {
}

public String getUrl() {
return String.format("%s:%s", getContainerIpAddress(), getMappedPort(PrestoWorkerContainer.PRESTO_HTTP_PORT));
return String.format("%s:%s", getHost(), getMappedPort(PrestoWorkerContainer.PRESTO_HTTP_PORT));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public ProxyContainer(String clusterName, String hostName) {
}

public String getPlainTextServiceUrl() {
return "pulsar://" + getContainerIpAddress() + ":" + getMappedPort(BROKER_PORT);
return "pulsar://" + getHost() + ":" + getMappedPort(BROKER_PORT);
}

public String getHttpServiceUrl() {
return "http://" + getContainerIpAddress() + ":" + getMappedPort(BROKER_HTTP_PORT);
return "http://" + getHost() + ":" + getMappedPort(BROKER_HTTP_PORT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ protected void beforeStart() {
}

public String getPlainTextServiceUrl() {
return "pulsar://" + getContainerIpAddress() + ":" + getMappedPort(BROKER_PORT);
return "pulsar://" + getHost() + ":" + getMappedPort(BROKER_PORT);
}

public String getHttpServiceUrl() {
return "http://" + getContainerIpAddress() + ":" + getMappedPort(BROKER_HTTP_PORT);
return "http://" + getHost() + ":" + getMappedPort(BROKER_HTTP_PORT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void prepareSink() throws Exception {

static ConnectionFactory createConnectionFactory(RabbitMQContainer container) {
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHost(container.getContainerIpAddress());
connectionFactory.setHost(container.getHost());
connectionFactory.setPort(container.getMappedPort(RabbitMQContainer.PORTS[0]));

return connectionFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.bookkeeper.client.BookKeeper;
import org.apache.bookkeeper.conf.ClientConfiguration;
import org.apache.commons.lang3.StringUtils;
import org.apache.pulsar.client.admin.PulsarAdmin;
import org.apache.pulsar.client.api.CompressionType;
import org.apache.pulsar.client.api.Consumer;
Expand All @@ -37,7 +38,6 @@
import org.apache.pulsar.common.naming.TopicDomain;
import org.apache.pulsar.common.naming.TopicName;
import org.apache.pulsar.tests.integration.containers.S3Container;
import org.testcontainers.shaded.org.apache.commons.lang.StringUtils;
import org.testng.Assert;
import org.testng.annotations.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
import java.util.List;
import java.util.concurrent.TimeUnit;
import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.pulsar.client.api.CompressionType;
import org.apache.pulsar.client.api.Schema;
import org.apache.pulsar.common.naming.TopicName;
Expand All @@ -39,9 +42,6 @@
import org.apache.pulsar.tests.integration.suites.PulsarSQLTestSuite;
import org.apache.pulsar.tests.integration.topologies.PulsarCluster;
import org.awaitility.Awaitility;
import org.testcontainers.shaded.okhttp3.OkHttpClient;
import org.testcontainers.shaded.okhttp3.Request;
import org.testcontainers.shaded.okhttp3.Response;
import org.testng.Assert;
import org.testng.annotations.DataProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public String getAllBrokersHttpServiceUrl() {
Iterator<BrokerContainer> brokers = getBrokers().iterator();
while (brokers.hasNext()) {
BrokerContainer broker = brokers.next();
multiUrl += broker.getContainerIpAddress() + ":" + broker.getMappedPort(BROKER_HTTP_PORT);
multiUrl += broker.getHost() + ":" + broker.getMappedPort(BROKER_HTTP_PORT);
if (brokers.hasNext()) {
multiUrl += ",";
}
Expand All @@ -225,11 +225,11 @@ public String getAllBrokersHttpServiceUrl() {
}

public String getZKConnString() {
return zkContainer.getContainerIpAddress() + ":" + zkContainer.getMappedPort(ZK_PORT);
return zkContainer.getHost() + ":" + zkContainer.getMappedPort(ZK_PORT);
}

public String getCSConnString() {
return csContainer.getContainerIpAddress() + ":" + csContainer.getMappedPort(CS_PORT);
return csContainer.getHost() + ":" + csContainer.getMappedPort(CS_PORT);
}

public Network getNetwork() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public PulsarContainer(final String pulsarVersion) {
}

public String getPlainTextPulsarBrokerUrl() {
return String.format("pulsar://%s:%s", this.getContainerIpAddress(), this.getMappedPort(PULSAR_PORT));
return String.format("pulsar://%s:%s", this.getHost(), this.getMappedPort(PULSAR_PORT));
}

public String getPulsarAdminUrl() {
return String.format("http://%s:%s", this.getContainerIpAddress(), this.getMappedPort(BROKER_HTTP_PORT));
return String.format("http://%s:%s", this.getHost(), this.getMappedPort(BROKER_HTTP_PORT));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public PulsarContainer(final String pulsarVersion) {
}

public String getPlainTextPulsarBrokerUrl() {
return String.format("pulsar://%s:%s", this.getContainerIpAddress(), this.getMappedPort(PULSAR_PORT));
return String.format("pulsar://%s:%s", this.getHost(), this.getMappedPort(PULSAR_PORT));
}

public String getPulsarAdminUrl() {
return String.format("http://%s:%s", this.getContainerIpAddress(), this.getMappedPort(BROKER_HTTP_PORT));
return String.format("http://%s:%s", this.getHost(), this.getMappedPort(BROKER_HTTP_PORT));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public PulsarContainer(final String pulsarVersion) {
}

public String getPlainTextPulsarBrokerUrl() {
return String.format("pulsar://%s:%s", this.getContainerIpAddress(), this.getMappedPort(PULSAR_PORT));
return String.format("pulsar://%s:%s", this.getHost(), this.getMappedPort(PULSAR_PORT));
}

public String getPulsarAdminUrl() {
return String.format("http://%s:%s", this.getContainerIpAddress(), this.getMappedPort(BROKER_HTTP_PORT));
return String.format("http://%s:%s", this.getHost(), this.getMappedPort(BROKER_HTTP_PORT));
}

}

0 comments on commit 6b65c9d

Please sign in to comment.