46
46
import static oracle .weblogic .kubernetes .TestConstants .ADMIN_USERNAME_DEFAULT ;
47
47
import static oracle .weblogic .kubernetes .TestConstants .BASE_IMAGES_REPO ;
48
48
import static oracle .weblogic .kubernetes .TestConstants .BASE_IMAGES_REPO_SECRET_NAME ;
49
+ import static oracle .weblogic .kubernetes .TestConstants .CLUSTER_VERSION ;
49
50
import static oracle .weblogic .kubernetes .TestConstants .DB_IMAGE_TO_USE_IN_SPEC ;
50
51
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_API_VERSION ;
51
52
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_STATUS_CONDITION_AVAILABLE_TYPE ;
52
53
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_STATUS_CONDITION_COMPLETED_TYPE ;
53
54
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_STATUS_CONDITION_FAILED_TYPE ;
55
+ import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_VERSION ;
54
56
import static oracle .weblogic .kubernetes .TestConstants .FMWINFRA_IMAGE_NAME ;
55
57
import static oracle .weblogic .kubernetes .TestConstants .FMWINFRA_IMAGE_TAG ;
56
58
import static oracle .weblogic .kubernetes .TestConstants .FMWINFRA_IMAGE_TO_USE_IN_SPEC ;
64
66
import static oracle .weblogic .kubernetes .actions .TestActions .deleteConfigMap ;
65
67
import static oracle .weblogic .kubernetes .actions .TestActions .patchClusterCustomResource ;
66
68
import static oracle .weblogic .kubernetes .actions .impl .Domain .patchDomainCustomResource ;
69
+ import static oracle .weblogic .kubernetes .assertions .TestAssertions .clusterExists ;
70
+ import static oracle .weblogic .kubernetes .assertions .TestAssertions .domainExists ;
67
71
import static oracle .weblogic .kubernetes .assertions .TestAssertions .domainStatusReasonMatches ;
68
72
import static oracle .weblogic .kubernetes .utils .ClusterUtils .createClusterAndVerify ;
69
73
import static oracle .weblogic .kubernetes .utils .ClusterUtils .createClusterResource ;
72
76
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getNextFreePort ;
73
77
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getUniqueName ;
74
78
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
79
+ import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .configMapExist ;
75
80
import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .createConfigMapFromFiles ;
76
81
import static oracle .weblogic .kubernetes .utils .DbUtils .createRcuAccessSecret ;
77
82
import static oracle .weblogic .kubernetes .utils .DbUtils .setupDBandRCUschema ;
@@ -108,16 +113,13 @@ class ItDiagnosticsFailedCondition {
108
113
109
114
private static String domainNamespace = null ;
110
115
int replicaCount = 2 ;
111
- String wlClusterName = "cluster-1" ;
116
+ private String wlClusterName = "cluster-1" ;
112
117
113
118
114
119
private static String adminSecretName ;
115
120
private static String encryptionSecretName ;
116
121
private static final String domainUid = "diagnosticsdomain" ;
117
122
118
- private static String opServiceAccount = null ;
119
- private static String opNamespace = null ;
120
-
121
123
private static LoggingFacade logger = null ;
122
124
private static List <String > ns ;
123
125
@@ -134,14 +136,14 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
134
136
logger = getLogger ();
135
137
logger .info ("Assign a unique namespace for operator" );
136
138
assertNotNull (namespaces .get (0 ), "Namespace is null" );
137
- opNamespace = namespaces .get (0 );
139
+ String opNamespace = namespaces .get (0 );
138
140
139
141
logger .info ("Assign a unique namespace for WebLogic domain" );
140
142
assertNotNull (namespaces .get (1 ), "Namespace is null" );
141
143
domainNamespace = namespaces .get (1 );
142
144
143
145
// set the service account name for the operator
144
- opServiceAccount = opNamespace + "-sa" ;
146
+ String opServiceAccount = opNamespace + "-sa" ;
145
147
146
148
// install and verify operator with REST API
147
149
installAndVerifyOperator (opNamespace , opServiceAccount , true , 0 , domainNamespace );
@@ -206,9 +208,15 @@ void testBadModelFileStatus() {
206
208
if (!testPassed ) {
207
209
LoggingUtil .generateLog (this , ns );
208
210
}
209
- deleteDomainResource (domainNamespace , domainName );
210
- deleteConfigMap (badModelFileCm , domainNamespace );
211
- deleteClusterCustomResource (clusterResName , domainNamespace );
211
+ if (assertDoesNotThrow (() -> domainExists (domainName , DOMAIN_VERSION , domainNamespace ).call ())) {
212
+ deleteDomainResource (domainNamespace , domainName );
213
+ }
214
+ if (assertDoesNotThrow (() -> configMapExist (domainNamespace , badModelFileCm ).call ())) {
215
+ deleteConfigMap (badModelFileCm , domainNamespace );
216
+ }
217
+ if (assertDoesNotThrow (() -> clusterExists (clusterResName , CLUSTER_VERSION , domainNamespace ).call ())) {
218
+ deleteClusterCustomResource (clusterResName , domainNamespace );
219
+ }
212
220
}
213
221
}
214
222
@@ -244,17 +252,19 @@ void testReplicasTooHigh() {
244
252
"waiting for domain status condition reason ReplicasTooHigh exists"
245
253
);
246
254
247
- // remove after debug
255
+ // Need to patch the cluster first, otherwise the domain can not be patched
256
+ // You will get this error:
257
+ // the replica count of cluster 'cluster-1' would exceed the cluster size '5' when patching the domain
248
258
String patchStr
249
259
= "["
250
260
+ "{\" op\" : \" replace\" , \" path\" : \" /spec/replicas\" , \" value\" : 2}"
251
261
+ "]" ;
252
262
V1Patch patch = new V1Patch (patchStr );
253
263
logger .info ("Patching cluster resource using patch string {0} " , patchStr );
264
+
254
265
assertTrue (patchClusterCustomResource (clusterResName , domainNamespace ,
255
266
patch , V1Patch .PATCH_FORMAT_JSON_PATCH ), "Failed to patch cluster" );
256
- //end of debug
257
-
267
+
258
268
patchStr = "[{\" op\" : \" replace\" , "
259
269
+ "\" path\" : \" /spec/webLogicCredentialsSecret/name\" , \" value\" : \" weblogic-credentials-foo\" }]" ;
260
270
logger .info ("PatchStr for domainHome: {0}" , patchStr );
@@ -286,8 +296,12 @@ void testReplicasTooHigh() {
286
296
if (!testPassed ) {
287
297
LoggingUtil .generateLog (this , ns );
288
298
}
289
- deleteDomainResource (domainNamespace , domainName );
290
- deleteClusterCustomResource (clusterResName , domainNamespace );
299
+ if (assertDoesNotThrow (() -> domainExists (domainName , DOMAIN_VERSION , domainNamespace ).call ())) {
300
+ deleteDomainResource (domainNamespace , domainName );
301
+ }
302
+ if (assertDoesNotThrow (() -> clusterExists (clusterResName , CLUSTER_VERSION , domainNamespace ).call ())) {
303
+ deleteClusterCustomResource (clusterResName , domainNamespace );
304
+ }
291
305
}
292
306
}
293
307
@@ -334,8 +348,12 @@ void testReplicasTooHighNegative() {
334
348
if (!testPassed ) {
335
349
LoggingUtil .generateLog (this , ns );
336
350
}
337
- deleteDomainResource (domainNamespace , domainName );
338
- deleteClusterCustomResource (clusterResName , domainNamespace );
351
+ if (assertDoesNotThrow (() -> domainExists (domainName , DOMAIN_VERSION , domainNamespace ).call ())) {
352
+ deleteDomainResource (domainNamespace , domainName );
353
+ }
354
+ if (assertDoesNotThrow (() -> clusterExists (clusterResName , CLUSTER_VERSION , domainNamespace ).call ())) {
355
+ deleteClusterCustomResource (clusterResName , domainNamespace );
356
+ }
339
357
}
340
358
}
341
359
@@ -371,8 +389,12 @@ void testImageDoesnotExist() {
371
389
if (!testPassed ) {
372
390
LoggingUtil .generateLog (this , ns );
373
391
}
374
- deleteDomainResource (domainNamespace , domainName );
375
- deleteClusterCustomResource (clusterResName , domainNamespace );
392
+ if (assertDoesNotThrow (() -> domainExists (domainName , DOMAIN_VERSION , domainNamespace ).call ())) {
393
+ deleteDomainResource (domainNamespace , domainName );
394
+ }
395
+ if (assertDoesNotThrow (() -> clusterExists (clusterResName , CLUSTER_VERSION , domainNamespace ).call ())) {
396
+ deleteClusterCustomResource (clusterResName , domainNamespace );
397
+ }
376
398
}
377
399
}
378
400
@@ -408,8 +430,12 @@ void testImagePullSecretDoesnotExist() {
408
430
if (!testPassed ) {
409
431
LoggingUtil .generateLog (this , ns );
410
432
}
411
- deleteDomainResource (domainNamespace , domainName );
412
- deleteClusterCustomResource (clusterResName , domainNamespace );
433
+ if (assertDoesNotThrow (() -> domainExists (domainName , DOMAIN_VERSION , domainNamespace ).call ())) {
434
+ deleteDomainResource (domainNamespace , domainName );
435
+ }
436
+ if (assertDoesNotThrow (() -> clusterExists (clusterResName , CLUSTER_VERSION , domainNamespace ).call ())) {
437
+ deleteClusterCustomResource (clusterResName , domainNamespace );
438
+ }
413
439
}
414
440
}
415
441
@@ -448,8 +474,12 @@ void testIncorrectImagePullSecret() {
448
474
if (!testPassed ) {
449
475
LoggingUtil .generateLog (this , ns );
450
476
}
451
- deleteDomainResource (domainNamespace , domainName );
452
- deleteClusterCustomResource (clusterResName , domainNamespace );
477
+ if (assertDoesNotThrow (() -> domainExists (domainName , DOMAIN_VERSION , domainNamespace ).call ())) {
478
+ deleteDomainResource (domainNamespace , domainName );
479
+ }
480
+ if (assertDoesNotThrow (() -> clusterExists (clusterResName , CLUSTER_VERSION , domainNamespace ).call ())) {
481
+ deleteClusterCustomResource (clusterResName , domainNamespace );
482
+ }
453
483
}
454
484
}
455
485
@@ -531,8 +561,12 @@ void testNonexistentPVC() {
531
561
if (!testPassed ) {
532
562
LoggingUtil .generateLog (this , ns );
533
563
}
534
- deleteClusterCustomResource (clusterResName , domainNamespace );
535
- deleteDomainResource (domainNamespace , domainName );
564
+ if (assertDoesNotThrow (() -> clusterExists (clusterResName , CLUSTER_VERSION , domainNamespace ).call ())) {
565
+ deleteClusterCustomResource (clusterResName , domainNamespace );
566
+ }
567
+ if (assertDoesNotThrow (() -> domainExists (domainName , DOMAIN_VERSION , domainNamespace ).call ())) {
568
+ deleteDomainResource (domainNamespace , domainName );
569
+ }
536
570
}
537
571
}
538
572
@@ -567,8 +601,12 @@ void testNonexistentAdminSecret() {
567
601
if (!testPassed ) {
568
602
LoggingUtil .generateLog (this , ns );
569
603
}
570
- deleteDomainResource (domainNamespace , domainName );
571
- deleteClusterCustomResource (clusterResName , domainNamespace );
604
+ if (assertDoesNotThrow (() -> domainExists (domainName , DOMAIN_VERSION , domainNamespace ).call ())) {
605
+ deleteDomainResource (domainNamespace , domainName );
606
+ }
607
+ if (assertDoesNotThrow (() -> clusterExists (clusterResName , CLUSTER_VERSION , domainNamespace ).call ())) {
608
+ deleteClusterCustomResource (clusterResName , domainNamespace );
609
+ }
572
610
}
573
611
}
574
612
@@ -611,8 +649,12 @@ void testInvalidNodePort() {
611
649
if (!testPassed ) {
612
650
LoggingUtil .generateLog (this , ns );
613
651
}
614
- deleteDomainResource (domainNamespace , domainName );
615
- deleteClusterCustomResource (clusterResName , domainNamespace );
652
+ if (assertDoesNotThrow (() -> domainExists (domainName , DOMAIN_VERSION , domainNamespace ).call ())) {
653
+ deleteDomainResource (domainNamespace , domainName );
654
+ }
655
+ if (assertDoesNotThrow (() -> clusterExists (clusterResName , CLUSTER_VERSION , domainNamespace ).call ())) {
656
+ deleteClusterCustomResource (clusterResName , domainNamespace );
657
+ }
616
658
}
617
659
}
618
660
@@ -650,8 +692,12 @@ void testIntrospectorTimeoutFailure() {
650
692
if (!testPassed ) {
651
693
LoggingUtil .generateLog (this , ns );
652
694
}
653
- deleteDomainResource (domainNamespace , domainName );
654
- deleteClusterCustomResource (clusterResName , domainNamespace );
695
+ if (assertDoesNotThrow (() -> domainExists (domainName , DOMAIN_VERSION , domainNamespace ).call ())) {
696
+ deleteDomainResource (domainNamespace , domainName );
697
+ }
698
+ if (assertDoesNotThrow (() -> clusterExists (clusterResName , CLUSTER_VERSION , domainNamespace ).call ())) {
699
+ deleteClusterCustomResource (clusterResName , domainNamespace );
700
+ }
655
701
}
656
702
}
657
703
@@ -671,15 +717,13 @@ void testMSBootFailureStatus() {
671
717
String domainName = getDomainName ();
672
718
String clusterResName = getClusterResName (domainName );
673
719
try {
674
- String fmwMiiImage = null ;
675
720
String rcuSchemaPrefix = "FMWDOMAINMII" ;
676
721
String oracleDbUrlPrefix = "oracledb." ;
677
- String oracleDbSuffix = null ;
678
722
String rcuSchemaPassword = "Oradoc_db1" ;
679
723
String modelFile = "model-singleclusterdomain-sampleapp-jrf.yaml" ;
680
724
681
725
final int dbListenerPort = getNextFreePort ();
682
- oracleDbSuffix = ".svc.cluster.local:" + dbListenerPort + "/devpdb.k8s" ;
726
+ String oracleDbSuffix = ".svc.cluster.local:" + dbListenerPort + "/devpdb.k8s" ;
683
727
String dbUrl = oracleDbUrlPrefix + domainNamespace + oracleDbSuffix ;
684
728
685
729
String rcuaccessSecretName = domainName + "-rcu-access" ;
@@ -712,7 +756,7 @@ rcuSchemaPrefix, domainNamespace, getNextFreePort(), dbUrl, dbListenerPort),
712
756
713
757
logger .info ("Create an image with jrf model file" );
714
758
final List <String > modelList = Collections .singletonList (MODEL_DIR + "/" + modelFile );
715
- fmwMiiImage = createMiiImageAndVerify (
759
+ String fmwMiiImage = createMiiImageAndVerify (
716
760
"jrf-mii-image-status" ,
717
761
modelList ,
718
762
Collections .singletonList (MII_BASIC_APP_NAME ),
@@ -800,8 +844,12 @@ rcuSchemaPrefix, domainNamespace, getNextFreePort(), dbUrl, dbListenerPort),
800
844
if (!testPassed ) {
801
845
LoggingUtil .generateLog (this , ns );
802
846
}
803
- deleteClusterCustomResource (clusterResName , domainNamespace );
804
- deleteDomainResource (domainNamespace , domainName );
847
+ if (assertDoesNotThrow (() -> clusterExists (clusterResName , CLUSTER_VERSION , domainNamespace ).call ())) {
848
+ deleteClusterCustomResource (clusterResName , domainNamespace );
849
+ }
850
+ if (assertDoesNotThrow (() -> domainExists (domainName , DOMAIN_VERSION , domainNamespace ).call ())) {
851
+ deleteDomainResource (domainNamespace , domainName );
852
+ }
805
853
}
806
854
}
807
855
0 commit comments