Skip to content

Commit 0d3ee9a

Browse files
committed
Fix intermittent ItRetryImprovementsMisc fails to receive expected Cluster Status in 4.0 (#3951)
* fix intermittent test failure * check pod restarted
1 parent a8df9e5 commit 0d3ee9a

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright (c) 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2022, 2023, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes;
55

6+
import java.time.OffsetDateTime;
67
import java.util.Collections;
78
import java.util.List;
89

@@ -29,6 +30,7 @@
2930
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_NAME;
3031
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG;
3132
import static oracle.weblogic.kubernetes.actions.TestActions.deletePod;
33+
import static oracle.weblogic.kubernetes.actions.TestActions.getPodCreationTimestamp;
3234
import static oracle.weblogic.kubernetes.actions.TestActions.patchClusterCustomResource;
3335
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainStatusClustersConditionTypeHasExpectedStatus;
3436
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainStatusConditionTypeHasExpectedStatus;
@@ -41,6 +43,7 @@
4143
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodDeleted;
4244
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodDoesNotExist;
4345
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodReady;
46+
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodRestarted;
4447
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
4548
import static org.awaitility.Awaitility.with;
4649
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
@@ -55,7 +58,7 @@
5558
class ItRetryImprovementMisc {
5659

5760
private static String domainNamespace = null;
58-
private static String domainUid = "domain1";
61+
private static String domainUid = "rimiscdomain1";
5962

6063
private static String adminServerPodName = String.format("%s-%s", domainUid, ADMIN_SERVER_NAME_BASE);
6164
private static String managedServerPrefix = String.format("%s-%s", domainUid, MANAGED_SERVER_NAME_BASE);
@@ -293,8 +296,13 @@ void testSetClusterToIfNeeded() {
293296
@DisplayName("Test domain and cluster status conditions after deleting a server pod of the cluster with "
294297
+ "cluster replicas set to 1.")
295298
void testDeleteServerPodWithReplicasSetTo1() {
296-
// delete a cluster server pod
299+
297300
String podName = managedServerPrefix + 1;
301+
OffsetDateTime ms1PodCreationTime =
302+
assertDoesNotThrow(() -> getPodCreationTimestamp(domainNamespace, "", podName),
303+
String.format("Failed to get creationTimestamp for pod %s", podName));
304+
305+
// delete a cluster server pod
298306
assertDoesNotThrow(() -> deletePod(podName, domainNamespace),
299307
String.format("delete pod %s in namespace %s failed", podName, domainNamespace));
300308

@@ -309,6 +317,7 @@ void testDeleteServerPodWithReplicasSetTo1() {
309317
DOMAIN_STATUS_CONDITION_AVAILABLE_TYPE, "False");
310318

311319
// wait the pod is restarted and back to ready
320+
checkPodRestarted(domainUid, domainNamespace, podName, ms1PodCreationTime);
312321
checkPodReady(podName, domainUid, domainNamespace);
313322

314323
// verify domain and cluster status conditions Available and Complete become true
@@ -445,8 +454,13 @@ void testClusterReplicasTo2() {
445454
@DisplayName("Test domain and cluster status conditions when deleting one of the cluster server pods with cluster "
446455
+ "replicas set to 2.")
447456
void testDeleteOneClusterPodWithReplicasSetTo2() {
448-
// delete one server pod
449457
String podName = managedServerPrefix + 1;
458+
459+
OffsetDateTime ms1PodCreationTime =
460+
assertDoesNotThrow(() -> getPodCreationTimestamp(domainNamespace, "", podName),
461+
String.format("Failed to get creationTimestamp for pod %s", podName));
462+
463+
// delete one server pod
450464
assertDoesNotThrow(() -> deletePod(podName, domainNamespace),
451465
String.format("delete pod %s in namespace %s failed", podName, domainNamespace));
452466

@@ -463,6 +477,7 @@ void testDeleteOneClusterPodWithReplicasSetTo2() {
463477
DOMAIN_STATUS_CONDITION_AVAILABLE_TYPE, "TRUE", DOMAIN_VERSION);
464478

465479
// Wait for the pod restarted
480+
checkPodRestarted(domainUid, domainNamespace, podName, ms1PodCreationTime);
466481
checkPodReady(podName, domainUid, domainNamespace);
467482

468483
// check the cluster and domain Complete should become true
@@ -483,6 +498,10 @@ void testDeleteOneClusterPodWithReplicasSetTo2() {
483498
@Test
484499
@DisplayName("Test domain and cluster status condition when deleting the admin server pod.")
485500
void testDeleteAdminServer() {
501+
OffsetDateTime adminPodCreationTime =
502+
assertDoesNotThrow(() -> getPodCreationTimestamp(domainNamespace, "", adminServerPodName),
503+
String.format("Failed to get creationTimestamp for pod %s", adminServerPodName));
504+
486505
// delete admin server pod
487506
assertDoesNotThrow(() -> deletePod(adminServerPodName, domainNamespace),
488507
String.format("delete pod %s in namespace %s failed", adminServerPodName, domainNamespace));
@@ -500,6 +519,7 @@ void testDeleteAdminServer() {
500519
clusterName, DOMAIN_STATUS_CONDITION_AVAILABLE_TYPE, "True", DOMAIN_VERSION);
501520

502521
// wait for admin server restart
522+
checkPodRestarted(domainUid, domainNamespace, adminServerPodName, adminPodCreationTime);
503523
checkPodReady(adminServerPodName, domainUid, domainNamespace);
504524

505525
// check the domain status condition Available and Complete become true

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2022, 2023, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes;
@@ -101,8 +101,8 @@ class ItValidateWebhookReplicas {
101101
private static String opNamespace = null;
102102
private static String domainNamespace = null;
103103
private static String domainNamespace2 = null;
104-
private static String domainUid = "domain1";
105-
private static String domainUid2 = "domain2";
104+
private static String domainUid = "valwebrepdomain1";
105+
private static String domainUid2 = "valwebrepdomain2";
106106

107107
private static String adminServerPodName = String.format("%s-%s", domainUid, ADMIN_SERVER_NAME_BASE);
108108
private static String managedServerPrefix = String.format("%s-%s", domainUid, MANAGED_SERVER_NAME_BASE);

0 commit comments

Comments
 (0)