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
44package oracle .weblogic .kubernetes ;
55
6+ import java .time .OffsetDateTime ;
67import java .util .Collections ;
78import java .util .List ;
89
2930import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_NAME ;
3031import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
3132import static oracle .weblogic .kubernetes .actions .TestActions .deletePod ;
33+ import static oracle .weblogic .kubernetes .actions .TestActions .getPodCreationTimestamp ;
3234import static oracle .weblogic .kubernetes .actions .TestActions .patchClusterCustomResource ;
3335import static oracle .weblogic .kubernetes .assertions .TestAssertions .domainStatusClustersConditionTypeHasExpectedStatus ;
3436import static oracle .weblogic .kubernetes .assertions .TestAssertions .domainStatusConditionTypeHasExpectedStatus ;
4143import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodDeleted ;
4244import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodDoesNotExist ;
4345import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodReady ;
46+ import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodRestarted ;
4447import static oracle .weblogic .kubernetes .utils .ThreadSafeLogger .getLogger ;
4548import static org .awaitility .Awaitility .with ;
4649import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
5558class 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
0 commit comments