Skip to content

Commit 3116370

Browse files
committed
corrected some test logic1
1 parent a740e79 commit 3116370

File tree

1 file changed

+5
-63
lines changed

1 file changed

+5
-63
lines changed

integration-tests/src/test/java/oracle/kubernetes/operator/ITPodsShutdown.java

Lines changed: 5 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -481,13 +481,6 @@ private void updateCRDYamlVerifyShutdown(DomainCRD crd, long delayTime) throws E
481481
Files.write(path, modYaml.getBytes(charset));
482482
modifiedYaml = path.toString();
483483
// Apply the new yaml to update the domain crd
484-
/*
485-
logger.log(Level.INFO, "kubectl delete -f {0}", originalYaml);
486-
ExecResult exec = TestUtils.exec("kubectl delete -f " + originalYaml);
487-
logger.info(exec.stdout());
488-
TestUtils.checkPodDeleted(domainUid + "-managed-server1", domainNS);
489-
TestUtils.checkPodDeleted(domainUid + "-admin-server", domainNS);
490-
*/
491484
this.domain.shutdown();
492485
logger.log(Level.INFO, "kubectl apply -f {0}", path.toString());
493486
ExecResult exec = TestUtils.exec("kubectl apply -f " + path.toString());
@@ -496,8 +489,6 @@ private void updateCRDYamlVerifyShutdown(DomainCRD crd, long delayTime) throws E
496489
logger.info("Verifying if the domain is restarted");
497490
TestUtils.checkPodReady(domainUid + "-admin-server", domainNS);
498491
TestUtils.checkPodReady(domainUid + "-managed-server1", domainNS);
499-
// this.domain.verifyAdminServerRestarted();
500-
// this.domain.verifyManagedServersRestarted();
501492

502493
// invoke servlet to keep sessions opened, terminate pod and check shutdown time
503494
if (delayTime > 0) {
@@ -509,15 +500,13 @@ private void updateCRDYamlVerifyShutdown(DomainCRD crd, long delayTime) throws E
509500
Thread.sleep(5 * 1000);
510501
}
511502
terminationTime = shutdownServer("managed-server1");
512-
513-
// logger.info("Checking termination time");
514-
// terminationTime = checkShutdownTime(domainUid + "-managed-server1");
515503
logger.info(" termination time: " + terminationTime);
504+
TestUtils.checkPodCreated(domainUid + "-admin-server", domainNS);
505+
TestUtils.checkPodCreated(domainUid + "-managed-server1", domainNS);
516506
}
517507

518508
private static void getDefaultShutdownTime() throws Exception {
519509
terminationDefaultOptionsTime = shutdownServer("managed-server1");
520-
// terminationDefaultOptionsTime = checkShutdownTime(domainUid + "-managed-server1");
521510
logger.info(
522511
" termination pod's time with default shutdown options is: "
523512
+ terminationDefaultOptionsTime);
@@ -620,10 +609,6 @@ private static long shutdownServer(String serverName) throws Exception {
620609
long endTime = System.currentTimeMillis();
621610
terminationTime = endTime - startTime;
622611
return terminationTime;
623-
// String output = result.stdout().trim();
624-
// logger.info("output from shutting down server:\n" + output);
625-
// TestUtils.checkPodTerminating(domainUid + "-" + serverName, domainNS);
626-
// logger.info(" Pod " + domainUid + "-" + serverName + " is Terminating status :\n" + output);
627612
}
628613

629614
private static boolean checkShutdownUpdatedProp(String podName, String... props)
@@ -649,53 +634,10 @@ private static boolean checkShutdownUpdatedProp(String podName, String... props)
649634
propFound.put(prop, new Boolean(true));
650635
}
651636
}
652-
if (props.length == propFound.size()) found = true;
653-
return found;
654-
}
655-
656-
private static long checkShutdownTime(String podName) throws Exception {
657-
long startTime = System.currentTimeMillis();
658-
long endTime = 0;
659-
int maxIterations = 50;
660-
int waitPodTime = 5;
661-
String matchStr = "Terminating";
662-
StringBuffer cmd = new StringBuffer();
663-
cmd.append("kubectl get pod ").append(podName).append(" -n ").append(domainNS);
664-
int i = 0;
665-
while (i < maxIterations) {
666-
ExecResult result = ExecCommand.exec(cmd.toString());
667-
668-
// pod might not have been created or if created loop till condition
669-
if ((result.exitValue() == 0 && result.stdout().contains(matchStr))) {
670-
logger.info("Output for " + cmd + "\n" + result.stdout() + "\n " + result.stderr());
671-
672-
// check for last iteration
673-
if (i == (maxIterations - 1)) {
674-
throw new RuntimeException(
675-
"FAILURE: pod " + podName + " is still in " + matchStr + " status, exiting!");
676-
}
677-
logger.info(
678-
"Pod "
679-
+ podName
680-
+ " is "
681-
+ matchStr
682-
+ " Ite ["
683-
+ i
684-
+ "/"
685-
+ maxIterations
686-
+ "], sleeping "
687-
+ waitPodTime
688-
+ " seconds more");
689-
690-
Thread.sleep(maxIterations * 1000);
691-
i++;
692-
} else {
693-
endTime = System.currentTimeMillis();
694-
logger.info("Pod " + podName + " is not in the " + matchStr + " status or does not exists");
695-
break;
696-
}
637+
if (props.length == propFound.size()) {
638+
found = true;
697639
}
698-
return (endTime - startTime);
640+
return found;
699641
}
700642
}
701643

0 commit comments

Comments
 (0)