Skip to content

Commit 8033078

Browse files
authored
backport pr3430 to release/3.4 (#3457)
1 parent 19c4b42 commit 8033078

File tree

1 file changed

+57
-6
lines changed

1 file changed

+57
-6
lines changed

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItFmwDiiSample.java

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import static oracle.weblogic.kubernetes.TestConstants.BASE_IMAGES_REPO_SECRET_NAME;
3333
import static oracle.weblogic.kubernetes.TestConstants.DB_IMAGE_TO_USE_IN_SPEC;
3434
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_VERSION;
35+
import static oracle.weblogic.kubernetes.TestConstants.FMWINFRA_IMAGE_NAME;
36+
import static oracle.weblogic.kubernetes.TestConstants.FMWINFRA_IMAGE_TAG;
3537
import static oracle.weblogic.kubernetes.TestConstants.FMWINFRA_IMAGE_TO_USE_IN_SPEC;
3638
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
3739
import static oracle.weblogic.kubernetes.TestConstants.KIND_REPO;
@@ -45,6 +47,7 @@
4547
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.callWebAppAndWaitTillReady;
4648
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
4749
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
50+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.testUntil;
4851
import static oracle.weblogic.kubernetes.utils.DbUtils.createRcuSecretWithUsernamePassword;
4952
import static oracle.weblogic.kubernetes.utils.FileUtils.replaceStringInFile;
5053
import static oracle.weblogic.kubernetes.utils.ImageUtils.createBaseRepoSecret;
@@ -184,9 +187,14 @@ void testFmwDomainInImageSample(String model) {
184187
}
185188

186189
private void createDomainAndVerify(String domainName, Path sampleBase) {
190+
testUntil(
191+
getInstanceAndContainerHostInfo(),
192+
logger,
193+
"Successfully got both instance and container hostname infor");
194+
187195
// run create-domain.sh to create domain.yaml file
188196
logger.info("Run create-domain.sh to create domain.yaml file");
189-
CommandParams params = new CommandParams().defaults();
197+
final CommandParams params = new CommandParams().defaults();
190198
params.command("sh "
191199
+ Paths.get(sampleBase.toString(), "create-domain.sh").toString()
192200
+ " -i " + Paths.get(sampleBase.toString(), "create-domain-inputs.yaml").toString()
@@ -197,8 +205,13 @@ private void createDomainAndVerify(String domainName, Path sampleBase) {
197205
+ " -o "
198206
+ Paths.get(sampleBase.toString()));
199207

200-
boolean result = Command.withParams(params).execute();
201-
assertTrue(result, "Failed to create domain.yaml");
208+
logger.info("Going to run sample create-domain.sh");
209+
testUntil(
210+
() -> {
211+
return Command.withParams(params).execute();
212+
},
213+
logger,
214+
"Running sample create-domain.sh to create domain.yaml");
202215

203216
//If the tests are running in kind cluster, push the image to kind registry
204217
if (KIND_REPO != null) {
@@ -220,11 +233,11 @@ private void createDomainAndVerify(String domainName, Path sampleBase) {
220233

221234
// run kubectl to create the domain
222235
logger.info("Run kubectl to create the domain");
223-
params = new CommandParams().defaults();
224-
params.command("kubectl apply -f "
236+
CommandParams params1 = new CommandParams().defaults();
237+
params1.command("kubectl apply -f "
225238
+ Paths.get(sampleBase.toString(), "weblogic-domains/" + domainName + "/domain.yaml").toString());
226239

227-
result = Command.withParams(params).execute();
240+
boolean result = Command.withParams(params1).execute();
228241
assertTrue(result, "Failed to create domain custom resource");
229242

230243
// wait for the domain to exist
@@ -412,4 +425,42 @@ private Callable<Boolean> tagAndPushToKind(String originalImage, String taggedIm
412425
});
413426
}
414427

428+
private Callable<Boolean> getInstanceAndContainerHostInfo() {
429+
return (() -> {
430+
return getHostnameInfo();
431+
});
432+
}
433+
434+
private Boolean getHostnameInfo() {
435+
436+
String fmwBaseImage = FMWINFRA_IMAGE_NAME + ":" + FMWINFRA_IMAGE_TAG;
437+
logger.info("Getting host infor of running instance and container by image: " + fmwBaseImage);
438+
String command1 = "cat /etc/resolv.conf && cat /etc/hosts";
439+
CommandParams params1 =
440+
defaultCommandParams()
441+
.command(command1)
442+
.saveResults(true);
443+
444+
String command2 = String.format(
445+
"docker run %s /bin/bash -c \"cat /etc/resolv.conf && cat /etc/hosts\"",
446+
fmwBaseImage);
447+
CommandParams params2 =
448+
defaultCommandParams()
449+
.command(command2)
450+
.saveResults(true)
451+
.redirect(true);
452+
453+
if (Command.withParams(params1).execute()
454+
&& params1.stdout() != null
455+
&& params1.stdout().length() != 0
456+
&& Command.withParams(params2).execute()
457+
&& params2.stdout() != null
458+
&& params2.stdout().length() != 0) {
459+
logger.info("Got both instance and container host infor");
460+
return true;
461+
}
462+
463+
return false;
464+
}
465+
415466
}

0 commit comments

Comments
 (0)