Skip to content

Commit 4a7e39f

Browse files
fix: avoid issuing invalid wait-for-it command (#1149)
Signed-off-by: Marko Strukelj <[email protected]> Co-authored-by: Bartosz Majsak <[email protected]>
1 parent 5706177 commit 4a7e39f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

docker/docker/src/main/java/org/arquillian/cube/docker/impl/await/PollingAwaitStrategy.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public boolean await() {
111111
} catch (UnsupportedOperationException e) {
112112
// In case of not having ss command installed on container, it automatically fall back to waitforit approach
113113
try {
114-
if (!executeWaitForIt(portBindings.getInternalIP(), port)) {
114+
if (!executeWaitForIt(getReadyCheckIp(portBindings), port)) {
115115
return false;
116116
}
117117
} catch (UnsupportedOperationException ex) {
@@ -132,7 +132,7 @@ public boolean await() {
132132
}
133133
break;
134134
case "waitforit": {
135-
if (!executeWaitForIt(portBindings.getInternalIP(), port)) {
135+
if (!executeWaitForIt(getReadyCheckIp(portBindings), port)) {
136136
return false;
137137
}
138138
}
@@ -142,6 +142,17 @@ public boolean await() {
142142
return true;
143143
}
144144

145+
private String getReadyCheckIp(HasPortBindings portBindings) {
146+
String ip = portBindings.getInternalIP();
147+
if (ip == null || "".equals(ip)) {
148+
ip = portBindings.getContainerIP();
149+
}
150+
if (ip == null || "".equals(ip)) {
151+
ip = "localhost";
152+
}
153+
return ip;
154+
}
155+
145156
private boolean executeWaitForIt(String containerIp, int port) {
146157

147158
// We copy our wait-for-it-sh.sh file form classpath

0 commit comments

Comments
 (0)