78
78
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_API_VERSION ;
79
79
import static oracle .weblogic .kubernetes .TestConstants .K8S_NODEPORT_HOST ;
80
80
import static oracle .weblogic .kubernetes .TestConstants .KIND_REPO ;
81
+ import static oracle .weblogic .kubernetes .TestConstants .OKD ;
81
82
import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_IMAGE_NAME ;
82
83
import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_IMAGE_TAG ;
83
84
import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_IMAGE_TO_USE_IN_SPEC ;
114
115
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createIngressForDomainAndVerify ;
115
116
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createPV ;
116
117
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createPVC ;
118
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createRouteForOKD ;
117
119
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createSecretForBaseImages ;
118
120
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createSecretWithUsernamePassword ;
119
121
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getExternalServicePodName ;
146
148
@ TestMethodOrder (MethodOrderer .OrderAnnotation .class )
147
149
@ DisplayName ("Verify the introspectVersion runs the introspector" )
148
150
@ IntegrationTest
151
+ @ Tag ("okdenv" )
149
152
public class ItIntrospectVersion {
150
153
151
154
private static String opNamespace = null ;
@@ -161,6 +164,9 @@ public class ItIntrospectVersion {
161
164
: WEBLOGIC_IMAGE_NAME + ":" + WLS_UPDATE_IMAGE_TAG ;
162
165
private final String wlSecretName = "weblogic-credentials" ;
163
166
167
+ private static String adminSvcExtHost = null ;
168
+ private static String clusterRouteHost = null ;
169
+
164
170
private Map <String , OffsetDateTime > podsWithTimeStamps = null ;
165
171
166
172
private static final String INTROSPECT_DOMAIN_SCRIPT = "introspectDomain.sh" ;
@@ -204,8 +210,9 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
204
210
nodeportshttp = getNextFreePort ();
205
211
int nodeportshttps = getNextFreePort ();
206
212
207
- // install and verify NGINX
208
- nginxHelmParams = installAndVerifyNginx (nginxNamespace , nodeportshttp , nodeportshttps );
213
+ if (!OKD ) {
214
+ nginxHelmParams = installAndVerifyNginx (nginxNamespace , nodeportshttp , nodeportshttps );
215
+ }
209
216
210
217
// create pull secrets for WebLogic image when running in non Kind Kubernetes cluster
211
218
// this secret is used only for non-kind cluster
@@ -240,6 +247,7 @@ public void testDomainIntrospectVersionNotRolling() {
240
247
241
248
final String adminServerName = "admin-server" ;
242
249
final String adminServerPodName = domainUid + "-" + adminServerName ;
250
+ final String clusterServiceName = domainUid + "-cluster-" + clusterName ;
243
251
244
252
final String managedServerNameBase = "managed-server" ;
245
253
String managedServerPodNamePrefix = domainUid + "-" + managedServerNameBase ;
@@ -374,6 +382,11 @@ public void testDomainIntrospectVersionNotRolling() {
374
382
checkPodReady (managedServerPodNamePrefix + i , domainUid , introDomainNamespace );
375
383
}
376
384
385
+ if (OKD ) {
386
+ adminSvcExtHost = createRouteForOKD (getExternalServicePodName (adminServerPodName ), introDomainNamespace );
387
+ logger .info ("admin svc host = {0}" , adminSvcExtHost );
388
+ }
389
+
377
390
// deploy application and verify all servers functions normally
378
391
logger .info ("Getting port for default channel" );
379
392
int defaultChannelPort = assertDoesNotThrow (()
@@ -391,15 +404,23 @@ public void testDomainIntrospectVersionNotRolling() {
391
404
//deploy clusterview application
392
405
logger .info ("Deploying clusterview app {0} to cluster {1}" ,
393
406
clusterViewAppPath , clusterName );
394
- ExecResult result = null ;
407
+ // ExecResult result = null;
395
408
String targets = "{identity:[clusters,'mycluster']},{identity:[servers,'admin-server']}" ;
396
- result = deployUsingRest (K8S_NODEPORT_HOST ,
397
- Integer .toString (serviceNodePort ),
398
- ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT ,
399
- targets , clusterViewAppPath , null , "clusterview" );
400
- assertNotNull (result , "Application deployment failed" );
401
- logger .info ("Application deployment returned {0}" , result .toString ());
402
- assertEquals ("202" , result .stdout (), "Application deploymen failed with wrong HTTP status code" );
409
+
410
+ String hostAndPort = (OKD ) ? adminSvcExtHost : K8S_NODEPORT_HOST + ":" + serviceNodePort ;
411
+ logger .info ("hostAndPort = {0} " , hostAndPort );
412
+
413
+ withStandardRetryPolicy .conditionEvaluationListener (
414
+ condition -> logger .info ("Deploying the application using Rest"
415
+ + "(elapsed time {0} ms, remaining time {1} ms)" ,
416
+ condition .getElapsedTimeInMS (),
417
+ condition .getRemainingTimeInMS ()))
418
+ .until ((Callable <Boolean >) () -> {
419
+ ExecResult result = assertDoesNotThrow (() -> deployUsingRest (hostAndPort ,
420
+ ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT ,
421
+ targets , clusterViewAppPath , null , "clusterview" ));
422
+ return result .stdout ().equals ("202" );
423
+ });
403
424
404
425
List <String > managedServerNames = new ArrayList <String >();
405
426
for (int i = 1 ; i <= replicaCount ; i ++) {
@@ -498,10 +519,14 @@ public void conditionEvaluated(EvaluatedCondition condition) {
498
519
}
499
520
500
521
//create ingress controller
501
- Map <String , Integer > clusterNameMsPortMap = new HashMap <>();
502
- clusterNameMsPortMap .put (clusterName , managedServerPort );
503
- logger .info ("Creating ingress for domain {0} in namespace {1}" , domainUid , introDomainNamespace );
504
- createIngressForDomainAndVerify (domainUid , introDomainNamespace , clusterNameMsPortMap );
522
+ if (!OKD ) {
523
+ Map <String , Integer > clusterNameMsPortMap = new HashMap <>();
524
+ clusterNameMsPortMap .put (clusterName , managedServerPort );
525
+ logger .info ("Creating ingress for domain {0} in namespace {1}" , domainUid , introDomainNamespace );
526
+ createIngressForDomainAndVerify (domainUid , introDomainNamespace , clusterNameMsPortMap );
527
+ } else {
528
+ clusterRouteHost = createRouteForOKD (clusterServiceName , introDomainNamespace );
529
+ }
505
530
506
531
managedServerNames = new ArrayList <String >();
507
532
for (int i = 1 ; i <= replicaCount + 1 ; i ++) {
@@ -511,13 +536,24 @@ public void conditionEvaluated(EvaluatedCondition condition) {
511
536
//verify admin server accessibility and the health of cluster members
512
537
verifyMemberHealth (adminServerPodName , managedServerNames , ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT );
513
538
514
- //access application in managed servers through NGINX load balancer
515
- logger .info ("Accessing the clusterview app through NGINX load balancer" );
516
- String curlRequest = String .format ("curl --silent --show-error --noproxy '*' "
517
- + "-H 'host: %s' http://%s:%s/clusterview/ClusterViewServlet"
539
+ String curlRequest = null ;
540
+
541
+ if (OKD ) {
542
+ logger .info ("cluster svc host = {0}" , clusterRouteHost );
543
+ logger .info ("Accessing the clusterview app through cluster route" );
544
+ curlRequest = String .format ("curl --silent --show-error --noproxy '*' "
545
+ + "http://%s/clusterview/ClusterViewServlet"
518
546
+ "\" ?user=" + ADMIN_USERNAME_DEFAULT
519
- + "&password=" + ADMIN_PASSWORD_DEFAULT + "\" " ,
520
- domainUid + "." + introDomainNamespace + "." + clusterName + ".test" , K8S_NODEPORT_HOST , nodeportshttp );
547
+ + "&password=" + ADMIN_PASSWORD_DEFAULT + "\" " , clusterRouteHost );
548
+ } else {
549
+ //access application in managed servers through NGINX load balancer
550
+ logger .info ("Accessing the clusterview app through NGINX load balancer" );
551
+ curlRequest = String .format ("curl --silent --show-error --noproxy '*' "
552
+ + "-H 'host: %s' http://%s:%s/clusterview/ClusterViewServlet"
553
+ + "\" ?user=" + ADMIN_USERNAME_DEFAULT
554
+ + "&password=" + ADMIN_PASSWORD_DEFAULT + "\" " ,
555
+ domainUid + "." + introDomainNamespace + "." + clusterName + ".test" , K8S_NODEPORT_HOST , nodeportshttp );
556
+ }
521
557
522
558
// verify each managed server can see other member in the cluster
523
559
verifyServerCommunication (curlRequest , managedServerNames );
@@ -662,13 +698,23 @@ public void testDomainIntrospectVersionRolling() {
662
698
//verify admin server accessibility and the health of cluster members
663
699
verifyMemberHealth (adminServerPodName , managedServerNames , ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT );
664
700
665
- //access application in managed servers through NGINX load balancer
666
- logger .info ("Accessing the clusterview app through NGINX load balancer" );
667
- String curlRequest = String .format ("curl --silent --show-error --noproxy '*' "
668
- + "-H 'host: %s' http://%s:%s/clusterview/ClusterViewServlet"
701
+ String curlRequest = null ;
702
+ if (OKD ) {
703
+ logger .info ("cluster svc host = {0}" , clusterRouteHost );
704
+ logger .info ("Accessing the clusterview app through cluster route" );
705
+ curlRequest = String .format ("curl --silent --show-error --noproxy '*' "
706
+ + "http://%s/clusterview/ClusterViewServlet"
669
707
+ "\" ?user=" + ADMIN_USERNAME_DEFAULT
670
- + "&password=" + ADMIN_PASSWORD_DEFAULT + "\" " ,
671
- domainUid + "." + introDomainNamespace + "." + clusterName + ".test" , K8S_NODEPORT_HOST , nodeportshttp );
708
+ + "&password=" + ADMIN_PASSWORD_DEFAULT + "\" " , clusterRouteHost );
709
+ } else {
710
+ //access application in managed servers through NGINX load balancer
711
+ logger .info ("Accessing the clusterview app through NGINX load balancer" );
712
+ curlRequest = String .format ("curl --silent --show-error --noproxy '*' "
713
+ + "-H 'host: %s' http://%s:%s/clusterview/ClusterViewServlet"
714
+ + "\" ?user=" + ADMIN_USERNAME_DEFAULT
715
+ + "&password=" + ADMIN_PASSWORD_DEFAULT + "\" " ,
716
+ domainUid + "." + introDomainNamespace + "." + clusterName + ".test" , K8S_NODEPORT_HOST , nodeportshttp );
717
+ }
672
718
673
719
// verify each managed server can see other member in the cluster
674
720
verifyServerCommunication (curlRequest , managedServerNames );
@@ -810,9 +856,9 @@ introDomainNamespace, getExternalServicePodName(adminServerPodName), "default"),
810
856
final boolean VALID = true ;
811
857
final boolean INVALID = false ;
812
858
logger .info ("Check that after patching current credentials are not valid and new credentials are" );
813
- verifyCredentials (adminServerPodName , introDomainNamespace ,
859
+ verifyCredentials (adminSvcExtHost , adminServerPodName , introDomainNamespace ,
814
860
ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT , INVALID );
815
- verifyCredentials (adminServerPodName , introDomainNamespace ,
861
+ verifyCredentials (adminSvcExtHost , adminServerPodName , introDomainNamespace ,
816
862
ADMIN_USERNAME_PATCH , ADMIN_PASSWORD_PATCH , VALID );
817
863
818
864
List <String > managedServerNames = new ArrayList <String >();
@@ -1150,8 +1196,11 @@ private static void verifyMemberHealth(String adminServerPodName, List<String> m
1150
1196
-> getServiceNodePort (introDomainNamespace , getExternalServicePodName (adminServerPodName ), "default" ),
1151
1197
"Getting admin server node port failed" );
1152
1198
1199
+ String hostAndPort = (OKD ) ? adminSvcExtHost : K8S_NODEPORT_HOST + ":" + serviceNodePort ;
1200
+ logger .info ("hostAndPort = {0} " , hostAndPort );
1201
+
1153
1202
logger .info ("Checking the health of servers in cluster" );
1154
- String url = "http://" + K8S_NODEPORT_HOST + ":" + serviceNodePort
1203
+ String url = "http://" + hostAndPort
1155
1204
+ "/clusterview/ClusterViewServlet?user=" + user + "&password=" + password ;
1156
1205
1157
1206
withStandardRetryPolicy .conditionEvaluationListener (
0 commit comments