Skip to content

Commit

Permalink
Upgrade TestContainers to 1.15.1 (apache#9120)
Browse files Browse the repository at this point in the history
* Upgrade TestContainers to 1.15.1

* Fixed testcontainers upgrade issues
  • Loading branch information
merlimat authored Jan 6, 2021
1 parent 2fd878a commit f817f3f
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 17 deletions.
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,12 @@ flexible messaging model and an intuitive client API.</description>
<nsq-client.version>1.0</nsq-client.version>
<cron-utils.version>9.1.3</cron-utils.version>
<spring-context.version>5.3.1</spring-context.version>
<docker-java.version>3.2.7</docker-java.version>

<!-- test dependencies -->
<cassandra.version>3.6.0</cassandra.version>
<disruptor.version>3.4.0</disruptor.version>
<testcontainers.version>1.14.3</testcontainers.version>
<testcontainers.version>1.15.1</testcontainers.version>
<kerby.version>1.1.1</kerby.version>
<testng.version>7.3.0</testng.version>
<mockito.version>3.0.0</mockito.version>
Expand Down Expand Up @@ -600,6 +601,12 @@ flexible messaging model and an intuitive client API.</description>
<artifactId>jna</artifactId>
<version>${jna.version}</version>
</dependency>

<dependency>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-core</artifactId>
<version>${docker-java.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson</groupId>
Expand Down
6 changes: 6 additions & 0 deletions tests/integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.pulsar</groupId>
<artifactId>pulsar-io-jdbc-postgres</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ protected ChaosContainer(String clusterName, String image) {
}

protected void beforeStop() {
if (null == containerId) {
if (null == getContainerId()) {
return;
}

// dump the container log
DockerUtils.dumpContainerLogToTarget(
getDockerClient(),
containerId
getContainerId()
);
}

Expand All @@ -66,15 +66,15 @@ public void stop() {

public void tailContainerLog() {
CompletableFuture.runAsync(() -> {
while (null == containerId) {
while (null == getContainerId()) {
try {
TimeUnit.MILLISECONDS.sleep(100);
} catch (InterruptedException e) {
return;
}
}

LogContainerCmd logContainerCmd = this.dockerClient.logContainerCmd(containerId);
LogContainerCmd logContainerCmd = this.dockerClient.logContainerCmd(getContainerId());
logContainerCmd.withStdOut(true).withStdErr(true).withFollowStream(true);
logContainerCmd.exec(new LogContainerResultCallback() {
@Override
Expand All @@ -88,7 +88,7 @@ public void onNext(Frame item) {
public String getContainerLog() {
StringBuilder sb = new StringBuilder();

LogContainerCmd logContainerCmd = this.dockerClient.logContainerCmd(containerId);
LogContainerCmd logContainerCmd = this.dockerClient.logContainerCmd(getContainerId());
logContainerCmd.withStdOut(true).withStdErr(true);
try {
logContainerCmd.exec(new LogContainerResultCallback() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public PrestoWorkerContainer(String clusterName, String hostname) {
@Override
protected void beforeStop() {
super.beforeStop();
if (null != containerId) {
if (null != getContainerId()) {
DockerUtils.dumpContainerDirToTargetCompressed(
getDockerClient(),
containerId,
getContainerId(),
"/pulsar/lib/presto/var/log"
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ public PulsarContainer(String clusterName,
@Override
protected void beforeStop() {
super.beforeStop();
if (null != containerId) {
if (null != getContainerId()) {
DockerUtils.dumpContainerDirToTargetCompressed(
getDockerClient(),
containerId,
getContainerId(),
"/var/log/pulsar"
);
}
Expand Down Expand Up @@ -149,7 +149,7 @@ public void start() {
beforeStart();
super.start();
afterStart();
log.info("Start pulsar service {} at container {}", serviceName, containerName);
log.info("Start pulsar service {} at container {}", serviceName, getContainerId());
}

@Override
Expand All @@ -159,13 +159,13 @@ public boolean equals(Object o) {
}

PulsarContainer another = (PulsarContainer) o;
return containerName.equals(another.containerName)
return getContainerId().equals(another.getContainerId())
&& super.equals(another);
}

@Override
public int hashCode() {
return 31 * super.hashCode() + Objects.hash(
containerName);
getContainerId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public WorkerContainer(String clusterName, String hostname) {
@Override
protected void beforeStop() {
super.beforeStop();
if (null != containerId) {
if (null != getContainerId()) {
DockerUtils.dumpContainerDirToTargetCompressed(
getDockerClient(),
containerId,
getContainerId(),
"/pulsar/logs/functions"
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public void enableDumpZkDataBeforeStop(boolean enabled) {
@Override
protected void beforeStop() {
super.beforeStop();
if (null != containerId && dumpZkDataBeforeStop) {
if (null != getContainerId() && dumpZkDataBeforeStop) {
DockerUtils.dumpContainerDirToTargetCompressed(
getDockerClient(),
containerId,
getContainerId(),
"/pulsar/data/zookeeper"
);
}
Expand Down

0 comments on commit f817f3f

Please sign in to comment.