You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2026/07/22 13:32:57 UTC
(shardingsphere) branch master updated: Refactor DockerStorageContainer (#39213)
This is an automated email from the ASF dual-hosted git repository.
terrymanu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new f212965339d Refactor DockerStorageContainer (#39213)
f212965339d is described below
commit f212965339d97b88ca59277e7bf809868ba0ffc9
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Wed Jul 22 21:32:49 2026 +0800
Refactor DockerStorageContainer (#39213)
* Remove placeholder arguments from SQL E2E tests
Allow SQL E2E parameterized tests to run with zero invocations.
Remove synthetic null parameters and obsolete null guards.
* Refactor DockerStorageContainer
---
.../env/container/storage/type/DockerStorageContainer.java | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/storage/type/DockerStorageContainer.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/storage/type/DockerStorageContainer.java
index f4a104b205f..aee0791f51a 100644
--- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/storage/type/DockerStorageContainer.java
+++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/storage/type/DockerStorageContainer.java
@@ -18,6 +18,8 @@
package org.apache.shardingsphere.test.e2e.env.container.storage.type;
import com.github.dockerjava.api.command.InspectContainerResponse;
+import com.github.dockerjava.api.model.ExposedPort;
+import com.github.dockerjava.api.model.Ports;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import lombok.Getter;
@@ -129,8 +131,8 @@ public final class DockerStorageContainer extends DockerE2EContainer implements
private String getURL() {
return option.getCreateOption().getDefaultDatabaseName(majorVersion)
- .map(optional -> option.getConnectOption().getURL("localhost", getFirstMappedPort(), optional))
- .orElseGet(() -> option.getConnectOption().getURL("localhost", getFirstMappedPort()));
+ .map(optional -> option.getConnectOption().getURL("localhost", getMappedPort(), optional))
+ .orElseGet(() -> option.getConnectOption().getURL("localhost", getMappedPort()));
}
@SneakyThrows(SQLException.class)
@@ -140,7 +142,7 @@ public final class DockerStorageContainer extends DockerE2EContainer implements
return;
}
try (
- Connection connection = createConnection(option.getConnectOption(), option.getConnectOption().getURL("localhost", getFirstMappedPort()),
+ Connection connection = createConnection(option.getConnectOption(), option.getConnectOption().getURL("localhost", getMappedPort()),
option.getCreateOption().getDefaultUserWhenUnsupportedDockerEntrypoint().orElse(""),
option.getCreateOption().getDefaultPasswordWhenUnsupportedDockerEntrypoint().orElse(""))) {
for (String each : new MountSQLResourceGenerator(option.getType(), option.getCreateOption()).generate(majorVersion, scenario).keySet()) {
@@ -213,7 +215,10 @@ public final class DockerStorageContainer extends DockerE2EContainer implements
* @return mapped database container port
*/
public int getMappedPort() {
- return getMappedPort(getExposedPort());
+ int exposedPort = getExposedPort();
+ Ports.Binding[] bindings = getCurrentContainerInfo().getNetworkSettings().getPorts().getBindings().get(ExposedPort.tcp(exposedPort));
+ Preconditions.checkNotNull(bindings, "Database port (%s) is not mapped", exposedPort);
+ return Integer.parseInt(bindings[0].getHostPortSpec());
}
@Override