1
- // Copyright (c) 2020, 2022 , Oracle and/or its affiliates.
1
+ // Copyright (c) 2020, 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 ;
61
61
import static oracle .weblogic .kubernetes .TestConstants .K8S_NODEPORT_HOST ;
62
62
import static oracle .weblogic .kubernetes .TestConstants .KIND_REPO ;
63
63
import static oracle .weblogic .kubernetes .TestConstants .KUBERNETES_CLI ;
64
- import static oracle .weblogic .kubernetes .TestConstants .OKD ;
65
64
import static oracle .weblogic .kubernetes .TestConstants .TEST_IMAGES_REPO ;
66
65
import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_IMAGE_NAME ;
67
66
import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_IMAGE_NAME_DEFAULT ;
109
108
import static oracle .weblogic .kubernetes .utils .K8sEvents .DOMAIN_ROLL_STARTING ;
110
109
import static oracle .weblogic .kubernetes .utils .K8sEvents .POD_CYCLE_STARTING ;
111
110
import static oracle .weblogic .kubernetes .utils .K8sEvents .checkEvent ;
112
- import static oracle .weblogic .kubernetes .utils .LoadBalancerUtils .createIngressForDomainAndVerify ;
113
111
import static oracle .weblogic .kubernetes .utils .OKDUtils .createRouteForOKD ;
114
112
import static oracle .weblogic .kubernetes .utils .OperatorUtils .installAndVerifyOperator ;
115
113
import static oracle .weblogic .kubernetes .utils .PatchDomainUtils .patchDomainResource ;
@@ -174,11 +172,8 @@ class ItIntrospectVersion {
174
172
private static String wlsPassword = ADMIN_PASSWORD_DEFAULT ;
175
173
176
174
private static String adminSvcExtHost = null ;
177
- private static String clusterRouteHost = null ;
178
- private static final String clusterServiceName = domainUid + "-cluster-" + cluster1Name ;
179
175
180
176
private Map <String , OffsetDateTime > cl2podsWithTimeStamps = null ;
181
- private Map <String , OffsetDateTime > cl1podsWithTimeStamps = null ;
182
177
183
178
private static final String INTROSPECT_DOMAIN_SCRIPT = "introspectDomain.sh" ;
184
179
private static final Path samplePath = Paths .get (ITTESTS_DIR , "../kubernetes/samples" );
@@ -329,21 +324,10 @@ void testDomainIntrospectVersionNotRolling() {
329
324
podStateNotChanged (adminServerPodName , domainUid , introDomainNamespace , adminPodCreationTime );
330
325
for (int i = 1 ; i <= cluster1ReplicaCount ; i ++) {
331
326
podStateNotChanged (cluster1ManagedServerPodNamePrefix + i ,
332
- domainUid , introDomainNamespace , pods .get (i ));
327
+ domainUid , introDomainNamespace , pods .get (cluster1ManagedServerPodNamePrefix + i ));
333
328
}
334
329
335
- //create ingress controller - OKD uses services exposed as routes
336
- if (!OKD ) {
337
- Map <String , Integer > clusterNameMsPortMap = new HashMap <>();
338
- clusterNameMsPortMap .put (cluster1Name , managedServerPort );
339
- logger .info ("Creating ingress for domain {0} in namespace {1}" , domainUid , introDomainNamespace );
340
- createIngressForDomainAndVerify (domainUid , introDomainNamespace , clusterNameMsPortMap );
341
- } else {
342
- clusterRouteHost = createRouteForOKD (clusterServiceName , introDomainNamespace );
343
- }
344
-
345
- List <String > managedServerNames = new ArrayList <String >();
346
- managedServerNames = new ArrayList <String >();
330
+ List <String > managedServerNames = new ArrayList <>();
347
331
for (int i = 1 ; i <= cluster1ReplicaCount + 1 ; i ++) {
348
332
managedServerNames .add (cluster1ManagedServerNameBase + i );
349
333
}
@@ -465,7 +449,7 @@ void testDomainIntrospectVersionRolling() {
465
449
"Getting admin server port failed" ),
466
450
"Updated admin server port is not equal to expected value" );
467
451
468
- List <String > managedServerNames = new ArrayList <String >();
452
+ List <String > managedServerNames = new ArrayList <>();
469
453
for (int i = 1 ; i <= cluster1ReplicaCount ; i ++) {
470
454
managedServerNames .add (cluster1ManagedServerNameBase + i );
471
455
}
@@ -586,7 +570,6 @@ void testCredentialChange() {
586
570
checkPodReadyAndServiceExists (cluster1ManagedServerPodNamePrefix + i , domainUid , introDomainNamespace );
587
571
}
588
572
589
- DomainResource cr = assertDoesNotThrow (() -> getDomainCustomResource (domainUid , introDomainNamespace ));
590
573
if (cluster2Created ) {
591
574
// verify new cluster managed server pods are ready
592
575
for (int i = 1 ; i <= cluster2ReplicaCount ; i ++) {
@@ -601,11 +584,11 @@ void testCredentialChange() {
601
584
final boolean VALID = true ;
602
585
logger .info ("Check that after patching current credentials are not valid and new credentials are" );
603
586
verifyCredentials (adminSvcExtHost , adminServerPodName , introDomainNamespace ,
604
- ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT , ! VALID );
587
+ ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT , false );
605
588
verifyCredentials (adminSvcExtHost , adminServerPodName , introDomainNamespace ,
606
589
ADMIN_USERNAME_PATCH , ADMIN_PASSWORD_PATCH , VALID );
607
590
608
- List <String > managedServerNames = new ArrayList <String >();
591
+ List <String > managedServerNames = new ArrayList <>();
609
592
for (int i = 1 ; i <= cluster1ReplicaCount ; i ++) {
610
593
managedServerNames .add (cluster1ManagedServerNameBase + i );
611
594
}
@@ -688,7 +671,7 @@ void testCreateNewCluster() {
688
671
checkPodReadyAndServiceExists (cluster2ManagedServerPodNamePrefix + i , domainUid , introDomainNamespace );
689
672
}
690
673
691
- List <String > managedServerNames = new ArrayList <String >();
674
+ List <String > managedServerNames = new ArrayList <>();
692
675
for (int i = 1 ; i <= cluster2ReplicaCount ; i ++) {
693
676
managedServerNames .add (cluster2ManagedServerNameBase + i );
694
677
}
@@ -725,7 +708,7 @@ void testUpdateImageName() {
725
708
cluster1ManagedServerNames .add (cluster1ManagedServerNameBase + i );
726
709
}
727
710
// get the map with server pods and their original creation timestamps
728
- cl1podsWithTimeStamps = getPodsWithTimeStamps (introDomainNamespace , adminServerPodName ,
711
+ Map < String , OffsetDateTime > cl1podsWithTimeStamps = getPodsWithTimeStamps (introDomainNamespace , adminServerPodName ,
729
712
cluster1ManagedServerPodNamePrefix , cluster1ReplicaCount );
730
713
731
714
List <String > cluster2ManagedServerNames = new ArrayList <>();
@@ -753,8 +736,7 @@ void testUpdateImageName() {
753
736
imageTag (imageName , imageUpdate );
754
737
imageRepoLoginAndPushImageToRegistry (imageUpdate );
755
738
756
- StringBuffer patchStr = null ;
757
- patchStr = new StringBuffer ("[{" );
739
+ StringBuffer patchStr = new StringBuffer ("[{" );
758
740
patchStr .append ("\" op\" : \" replace\" ," )
759
741
.append (" \" path\" : \" /spec/image\" ," )
760
742
.append ("\" value\" : \" " )
@@ -1159,7 +1141,7 @@ private static void createDomain() {
1159
1141
},
1160
1142
logger ,
1161
1143
"Deploying the application using Rest" );
1162
- List <String > managedServerNames = new ArrayList <String >();
1144
+ List <String > managedServerNames = new ArrayList <>();
1163
1145
for (int i = 1 ; i <= cluster1ReplicaCount ; i ++) {
1164
1146
managedServerNames .add (cluster1ManagedServerNameBase + i );
1165
1147
}
@@ -1282,7 +1264,6 @@ private void verifyIntrospectVersionLabelInPod() {
1282
1264
verifyIntrospectVersionLabelValue (cluster1ManagedServerPodNamePrefix + i , introspectVersion );
1283
1265
}
1284
1266
1285
- DomainResource cr = assertDoesNotThrow (() -> getDomainCustomResource (domainUid , introDomainNamespace ));
1286
1267
if (cluster2Created ) {
1287
1268
// verify new cluster managed server pods are ready
1288
1269
for (int i = 1 ; i <= cluster2ReplicaCount ; i ++) {
@@ -1299,16 +1280,23 @@ private void verifyIntrospectVersionLabelValue(String podName, String introspect
1299
1280
getPod (introDomainNamespace , "" , podName ),
1300
1281
"Get pod " + podName );
1301
1282
1302
- Map <String , String > myLabels = myPod .getMetadata ().getLabels ();
1283
+ Map <String , String > myLabels = new HashMap <>();
1284
+ if (myPod != null && myPod .getMetadata () != null ) {
1285
+ myLabels = myPod .getMetadata ().getLabels ();
1286
+ }
1303
1287
1304
- for (Map .Entry <String , String > entry : myLabels .entrySet ()) {
1305
- if (entry .getKey ().equals (wlsIntroVersion )) {
1306
- logger .info ("Get Spec Key:value = {0}:{1}" , entry .getKey (), entry .getValue ());
1307
- logger .info ("Verifying weblogic.introspectVersion is set to {0}" , introspectVersion );
1288
+ if (myLabels != null ) {
1289
+ for (Map .Entry <String , String > entry : myLabels .entrySet ()) {
1290
+ if (entry .getKey ().equals (wlsIntroVersion )) {
1291
+ logger .info ("Get Spec Key:value = {0}:{1}" , entry .getKey (), entry .getValue ());
1292
+ logger .info ("Verifying weblogic.introspectVersion is set to {0}" , introspectVersion );
1308
1293
1309
- assertEquals (introspectVersion , entry .getValue (),
1310
- "Failed to set " + wlsIntroVersion + " to " + introspectVersion );
1294
+ assertEquals (introspectVersion , entry .getValue (),
1295
+ "Failed to set " + wlsIntroVersion + " to " + introspectVersion );
1296
+ }
1311
1297
}
1298
+ } else {
1299
+ logger .info ("myLabels for pod {0} in namespace {1} is null" , podName , introDomainNamespace );
1312
1300
}
1313
1301
}
1314
1302
0 commit comments