Skip to content

Commit 481bb43

Browse files
committed
fix
1 parent 65cea20 commit 481bb43

File tree

2 files changed

+46
-29
lines changed

2 files changed

+46
-29
lines changed

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import oracle.kubernetes.operator.utils.K8sTestUtils;
1818
import oracle.kubernetes.operator.utils.Operator;
1919
import oracle.kubernetes.operator.utils.TestUtils;
20-
import org.junit.AfterClass;
2120
import org.junit.Assert;
2221
import org.junit.Assume;
2322
import org.junit.BeforeClass;
@@ -75,7 +74,7 @@ public static void staticPrepare() throws Exception {
7574
*
7675
* @throws Exception
7776
*/
78-
@AfterClass
77+
// @AfterClass
7978
public static void staticUnPrepare() throws Exception {
8079
if (!QUICKTEST) {
8180
logger.info("+++++++++++++++++++++++++++++++++---------------------------------+");
@@ -326,6 +325,11 @@ public void testAdminServerRestartVersion() throws Exception {
326325
Assume.assumeFalse(QUICKTEST);
327326
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
328327
logTestBegin(testMethodName);
328+
K8sTestUtils testUtil = new K8sTestUtils();
329+
final String domainUid = domain.getDomainUid();
330+
final String domain1LabelSelector = String.format("weblogic.domainUID in (%s)", domainUid);
331+
final String podName = domain.getDomainUid() + "-" + domain.getAdminServerName();
332+
329333
try {
330334
// Modify the original domain yaml to include restartVersion in admin server node
331335
DomainCRD crd = new DomainCRD(originalYaml);
@@ -346,19 +350,21 @@ public void testAdminServerRestartVersion() throws Exception {
346350
ExecResult exec = TestUtils.exec("kubectl apply -f " + path.toString());
347351
logger.info(exec.stdout());
348352
logger.info("Verifying if the admin server is restarted");
349-
K8sTestUtils testUtil = new K8sTestUtils();
350-
for (int i = 0; i < 60000; i++) {
353+
for (int i = 0; i < 120000; i = i + 10000) {
351354
String podStatus =
352-
testUtil.getPodStatus(domain.getDomainNS(), domain.getDomainUid(), "mypod");
355+
testUtil.getPodStatus(domain.getDomainNS(), domain1LabelSelector, podName);
353356
Thread.sleep(10000);
354357
}
355-
// domain.verifyAdminServerRestarted();
356358
} finally {
357359
logger.log(
358360
Level.INFO, "Reverting back the domain to old crd\n kubectl apply -f {0}", originalYaml);
359361
TestUtils.exec("kubectl apply -f " + originalYaml);
360362
logger.info("Verifying if the admin server is restarted");
361-
domain.verifyAdminServerRestarted();
363+
for (int i = 0; i < 120000; i = i + 10000) {
364+
String podStatus =
365+
testUtil.getPodStatus(domain.getDomainNS(), domain1LabelSelector, podName);
366+
Thread.sleep(10000);
367+
}
362368
}
363369
logger.log(Level.INFO, "SUCCESS - {0}", testMethodName);
364370
}

integration-tests/src/test/java/oracle/kubernetes/operator/utils/K8sTestUtils.java

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import io.kubernetes.client.models.V1PersistentVolumeList;
2727
import io.kubernetes.client.models.V1Pod;
2828
import io.kubernetes.client.models.V1PodList;
29-
import io.kubernetes.client.models.V1PodStatus;
3029
import io.kubernetes.client.models.V1ReplicaSetList;
3130
import io.kubernetes.client.models.V1RoleBindingList;
3231
import io.kubernetes.client.models.V1RoleList;
@@ -38,6 +37,8 @@
3837
import io.kubernetes.client.util.ClientBuilder;
3938
import java.io.IOException;
4039
import java.util.List;
40+
import java.util.logging.Level;
41+
import java.util.logging.Logger;
4142

4243
public class K8sTestUtils {
4344
static {
@@ -55,6 +56,7 @@ public class K8sTestUtils {
5556
private ExtensionsV1beta1Api extensionsV1beta1Api = new ExtensionsV1beta1Api();
5657
private RbacAuthorizationV1Api rbacAuthorizationV1Api = new RbacAuthorizationV1Api();
5758
private ApiextensionsV1beta1Api apiextensionsV1beta1Api = new ApiextensionsV1beta1Api();
59+
public static final Logger logger = Logger.getLogger("OperatorIT", "OperatorIT");
5860

5961
public void verifyDomainCrd() throws Exception {
6062
try {
@@ -344,33 +346,42 @@ public void verifyNoClusterRoleBindings(String labelSelectors) throws Exception
344346
assertEquals("Number of cluster role bindings", v1ClusterRoleBindingList.getItems().size(), 0);
345347
}
346348

347-
public V1PodList getPods(String namespace, String labelSelectors) throws ApiException {
348-
V1PodList v1PodList =
349-
coreV1Api.listNamespacedPod(
350-
namespace,
351-
Boolean.FALSE,
352-
Boolean.FALSE.toString(),
353-
null,
354-
null,
355-
labelSelectors,
356-
null,
357-
null,
358-
null,
359-
Boolean.FALSE);
349+
public V1PodList getPods(String namespace, String labelSelectors) {
350+
V1PodList v1PodList = null;
351+
try {
352+
v1PodList =
353+
coreV1Api.listNamespacedPod(
354+
namespace,
355+
Boolean.FALSE,
356+
Boolean.FALSE.toString(),
357+
null,
358+
null,
359+
labelSelectors,
360+
null,
361+
null,
362+
null,
363+
Boolean.FALSE);
364+
365+
} catch (ApiException ex) {
366+
Logger.getLogger(K8sTestUtils.class.getName()).log(Level.SEVERE, null, ex);
367+
}
368+
logger.log(
369+
Level.INFO,
370+
"Pods in namespace :{0} and label :{1} :{2}",
371+
new Object[] {namespace, labelSelectors, v1PodList.getItems().size()});
360372
return v1PodList;
361373
}
362374

363-
public String getPodStatus(String namespace, String labelSelectors, String podName)
364-
throws ApiException {
375+
public String getPodStatus(String namespace, String labelSelectors, String podName) {
365376
String status = null;
366377
List<V1Pod> pods = getPods(namespace, labelSelectors).getItems();
367378
for (V1Pod pod : pods) {
368-
V1PodStatus podStatus = pod.getStatus();
369-
System.out.println(pod.toString() + ":" + podStatus.getMessage());
370-
System.out.println(pod.toString() + ":" + podStatus.getPhase());
371-
System.out.println(pod.toString() + ":" + podStatus.toString());
372-
if (pod.toString().equals(podName)) {
373-
status = pod.getStatus().toString();
379+
logger.log(
380+
Level.INFO,
381+
"POD NAME:{0} POD STATUS :{1}",
382+
new Object[] {pod.getMetadata().getName(), pod.getStatus().getPhase()});
383+
if (pod.getMetadata().getName().equals(podName)) {
384+
status = pod.getStatus().getPhase();
374385
}
375386
}
376387
return status;

0 commit comments

Comments
 (0)