Skip to content

Commit 42a969e

Browse files
xiancaorjeberhard
authored andcommitted
[wls1412] fix ItFmwDomainOnPVSample test failure
1 parent 579231d commit 42a969e

File tree

1 file changed

+26
-9
lines changed
  • integration-tests/src/test/java/oracle/weblogic/kubernetes/utils

1 file changed

+26
-9
lines changed

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/SampleUtils.java

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,35 @@ public class SampleUtils {
2121
* @param envMap - envMap for running the docker command
2222
*/
2323
public static void createPVHostPathAndChangePermissionInKindCluster(String hostPath, Map<String, String> envMap) {
24-
String command = WLSIMG_BUILDER
25-
+ " exec kind-worker sh -c \"mkdir "
26-
+ hostPath
27-
+ " && chmod g+w "
28-
+ hostPath
29-
+ "\"";
30-
31-
Command.withParams(
24+
if (!pathExistsInKindCluster(hostPath, envMap)) {
25+
String command = WLSIMG_BUILDER
26+
+ " exec kind-worker sh -c \"mkdir "
27+
+ hostPath
28+
+ " && chmod g+w "
29+
+ hostPath
30+
+ "\"";
31+
32+
Command.withParams(
33+
new CommandParams()
34+
.command(command)
35+
.env(envMap)
36+
.redirect(true)
37+
).execute();
38+
}
39+
}
40+
41+
private static boolean pathExistsInKindCluster(String hostPath, Map<String, String> envMap) {
42+
String command = WLSIMG_BUILDER + " exec kind-worker sh -c \"ls / \" ";
43+
ExecResult result = Command.withParams(
3244
new CommandParams()
3345
.command(command)
3446
.env(envMap)
3547
.redirect(true)
36-
).execute();
48+
).executeAndReturnResult();
49+
50+
if (result.stdout().contains(hostPath.substring(1))) {
51+
return true;
52+
}
53+
return false;
3754
}
3855
}

0 commit comments

Comments
 (0)