1
- // Copyright (c) 2022, Oracle and/or its affiliates.
1
+ // Copyright (c) 2022, 2023, Oracle and/or its affiliates.
2
2
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3
3
4
4
package oracle .weblogic .kubernetes ;
5
5
6
+ import java .time .OffsetDateTime ;
6
7
import java .util .Collections ;
7
8
import java .util .List ;
8
9
29
30
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_NAME ;
30
31
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
31
32
import static oracle .weblogic .kubernetes .actions .TestActions .deletePod ;
33
+ import static oracle .weblogic .kubernetes .actions .TestActions .getPodCreationTimestamp ;
32
34
import static oracle .weblogic .kubernetes .actions .TestActions .patchClusterCustomResource ;
33
35
import static oracle .weblogic .kubernetes .assertions .TestAssertions .domainStatusClustersConditionTypeHasExpectedStatus ;
34
36
import static oracle .weblogic .kubernetes .assertions .TestAssertions .domainStatusConditionTypeHasExpectedStatus ;
41
43
import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodDeleted ;
42
44
import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodDoesNotExist ;
43
45
import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodReady ;
46
+ import static oracle .weblogic .kubernetes .utils .PodUtils .checkPodRestarted ;
44
47
import static oracle .weblogic .kubernetes .utils .ThreadSafeLogger .getLogger ;
45
48
import static org .awaitility .Awaitility .with ;
46
49
import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
55
58
class ItRetryImprovementMisc {
56
59
57
60
private static String domainNamespace = null ;
58
- private static String domainUid = "domain1 " ;
61
+ private static String domainUid = "rimiscdomain1 " ;
59
62
60
63
private static String adminServerPodName = String .format ("%s-%s" , domainUid , ADMIN_SERVER_NAME_BASE );
61
64
private static String managedServerPrefix = String .format ("%s-%s" , domainUid , MANAGED_SERVER_NAME_BASE );
@@ -293,8 +296,13 @@ void testSetClusterToIfNeeded() {
293
296
@ DisplayName ("Test domain and cluster status conditions after deleting a server pod of the cluster with "
294
297
+ "cluster replicas set to 1." )
295
298
void testDeleteServerPodWithReplicasSetTo1 () {
296
- // delete a cluster server pod
299
+
297
300
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
298
306
assertDoesNotThrow (() -> deletePod (podName , domainNamespace ),
299
307
String .format ("delete pod %s in namespace %s failed" , podName , domainNamespace ));
300
308
@@ -309,6 +317,7 @@ void testDeleteServerPodWithReplicasSetTo1() {
309
317
DOMAIN_STATUS_CONDITION_AVAILABLE_TYPE , "False" );
310
318
311
319
// wait the pod is restarted and back to ready
320
+ checkPodRestarted (domainUid , domainNamespace , podName , ms1PodCreationTime );
312
321
checkPodReady (podName , domainUid , domainNamespace );
313
322
314
323
// verify domain and cluster status conditions Available and Complete become true
@@ -445,8 +454,13 @@ void testClusterReplicasTo2() {
445
454
@ DisplayName ("Test domain and cluster status conditions when deleting one of the cluster server pods with cluster "
446
455
+ "replicas set to 2." )
447
456
void testDeleteOneClusterPodWithReplicasSetTo2 () {
448
- // delete one server pod
449
457
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
450
464
assertDoesNotThrow (() -> deletePod (podName , domainNamespace ),
451
465
String .format ("delete pod %s in namespace %s failed" , podName , domainNamespace ));
452
466
@@ -463,6 +477,7 @@ void testDeleteOneClusterPodWithReplicasSetTo2() {
463
477
DOMAIN_STATUS_CONDITION_AVAILABLE_TYPE , "TRUE" , DOMAIN_VERSION );
464
478
465
479
// Wait for the pod restarted
480
+ checkPodRestarted (domainUid , domainNamespace , podName , ms1PodCreationTime );
466
481
checkPodReady (podName , domainUid , domainNamespace );
467
482
468
483
// check the cluster and domain Complete should become true
@@ -483,6 +498,10 @@ void testDeleteOneClusterPodWithReplicasSetTo2() {
483
498
@ Test
484
499
@ DisplayName ("Test domain and cluster status condition when deleting the admin server pod." )
485
500
void testDeleteAdminServer () {
501
+ OffsetDateTime adminPodCreationTime =
502
+ assertDoesNotThrow (() -> getPodCreationTimestamp (domainNamespace , "" , adminServerPodName ),
503
+ String .format ("Failed to get creationTimestamp for pod %s" , adminServerPodName ));
504
+
486
505
// delete admin server pod
487
506
assertDoesNotThrow (() -> deletePod (adminServerPodName , domainNamespace ),
488
507
String .format ("delete pod %s in namespace %s failed" , adminServerPodName , domainNamespace ));
@@ -500,6 +519,7 @@ void testDeleteAdminServer() {
500
519
clusterName , DOMAIN_STATUS_CONDITION_AVAILABLE_TYPE , "True" , DOMAIN_VERSION );
501
520
502
521
// wait for admin server restart
522
+ checkPodRestarted (domainUid , domainNamespace , adminServerPodName , adminPodCreationTime );
503
523
checkPodReady (adminServerPodName , domainUid , domainNamespace );
504
524
505
525
// check the domain status condition Available and Complete become true
0 commit comments