30
30
import oracle .weblogic .kubernetes .annotations .Namespaces ;
31
31
import oracle .weblogic .kubernetes .logging .LoggingFacade ;
32
32
import oracle .weblogic .kubernetes .utils .DomainUtils ;
33
+ import oracle .weblogic .kubernetes .utils .ExecResult ;
33
34
import org .junit .jupiter .api .BeforeAll ;
34
35
import org .junit .jupiter .api .DisplayName ;
35
36
import org .junit .jupiter .api .Tag ;
48
49
import static oracle .weblogic .kubernetes .TestConstants .MANAGED_SERVER_NAME_BASE ;
49
50
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_APP_NAME ;
50
51
import static oracle .weblogic .kubernetes .TestConstants .OKD ;
52
+ import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER ;
51
53
import static oracle .weblogic .kubernetes .TestConstants .OPERATOR_EXTERNAL_REST_HTTPSPORT ;
54
+ import static oracle .weblogic .kubernetes .TestConstants .OPERATOR_RELEASE_NAME ;
52
55
import static oracle .weblogic .kubernetes .TestConstants .TEST_IMAGES_REPO_SECRET_NAME ;
53
56
import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_INGRESS_HTTP_HOSTPORT ;
54
57
import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_IMAGE_NAME ;
61
64
import static oracle .weblogic .kubernetes .actions .TestActions .buildAppArchive ;
62
65
import static oracle .weblogic .kubernetes .actions .TestActions .defaultAppParams ;
63
66
import static oracle .weblogic .kubernetes .actions .TestActions .getDomainCustomResource ;
67
+ import static oracle .weblogic .kubernetes .actions .TestActions .getOperatorPodName ;
64
68
import static oracle .weblogic .kubernetes .actions .TestActions .getServiceNodePort ;
65
69
import static oracle .weblogic .kubernetes .actions .TestActions .getServicePort ;
66
70
import static oracle .weblogic .kubernetes .actions .TestActions .listIngresses ;
73
77
import static oracle .weblogic .kubernetes .utils .ClusterUtils .createClusterResourceAndAddReferenceToDomain ;
74
78
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodReadyAndServiceExists ;
75
79
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createIngressHostRouting ;
80
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .exeAppInServerPod ;
76
81
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getHostAndPort ;
77
82
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getNextFreePort ;
83
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getServiceExtIPAddrtOke ;
78
84
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .scaleAndVerifyCluster ;
79
85
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .startPortForwardProcess ;
80
86
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .stopPortForwardProcess ;
97
103
import static oracle .weblogic .kubernetes .utils .SecretUtils .createSecretWithUsernamePassword ;
98
104
import static oracle .weblogic .kubernetes .utils .ThreadSafeLogger .getLogger ;
99
105
import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
106
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
100
107
import static org .junit .jupiter .api .Assertions .assertNotEquals ;
101
108
import static org .junit .jupiter .api .Assertions .assertNotNull ;
102
109
import static org .junit .jupiter .api .Assertions .assertTrue ;
114
121
+ "rolling restart behavior in a multi-cluster MII domain and "
115
122
+ "the sample application can be accessed via NGINX ingress controller" )
116
123
@ Tag ("kind-sequential" )
117
- @ Tag ("oke-sequential " )
124
+ @ Tag ("oke-gate " )
118
125
@ IntegrationTest
119
126
class ItMultiDomainModelsScale {
120
127
@@ -140,6 +147,7 @@ class ItMultiDomainModelsScale {
140
147
private static String opNamespace = null ;
141
148
private static String opServiceAccount = null ;
142
149
private static NginxParams nginxHelmParams = null ;
150
+ private static String nginxNamespace = null ;
143
151
private static int nodeportshttp = 0 ;
144
152
private static LoggingFacade logger = null ;
145
153
private static String miiDomainNamespace = null ;
@@ -170,7 +178,7 @@ public static void initAll(@Namespaces(5) List<String> namespaces) {
170
178
// get a unique NGINX namespace
171
179
logger .info ("Get a unique namespace for NGINX" );
172
180
assertNotNull (namespaces .get (1 ), "Namespace list is null" );
173
- String nginxNamespace = namespaces .get (1 );
181
+ nginxNamespace = namespaces .get (1 );
174
182
175
183
// get unique namespaces for three different type of domains
176
184
logger .info ("Getting unique namespaces for three different type of domains" );
@@ -245,23 +253,45 @@ void testScaleClustersByPatchingClusterResource(String domainType) {
245
253
numberOfServers = 3 ;
246
254
}
247
255
248
- logger .info ("Scaling cluster {0} of domain {1} in namespace {2} to {3} servers." ,
249
- clusterName , domainUid , domainNamespace , numberOfServers );
250
- curlCmd = generateCurlCmd (domainUid , domainNamespace , clusterName , SAMPLE_APP_CONTEXT_ROOT );
251
- List <String > managedServersBeforeScale = listManagedServersBeforeScale (numClusters , clusterName , replicaCount );
252
- scaleAndVerifyCluster (clusterName , domainUid , domainNamespace , managedServerPodNamePrefix ,
253
- replicaCount , numberOfServers , curlCmd , managedServersBeforeScale );
254
-
255
- // then scale cluster back to 1 servers
256
- logger .info ("Scaling cluster {0} of domain {1} in namespace {2} from {3} servers to {4} servers." ,
257
- clusterName , domainUid , domainNamespace , numberOfServers , replicaCount );
258
- managedServersBeforeScale = listManagedServersBeforeScale (numClusters , clusterName , numberOfServers );
259
- scaleAndVerifyCluster (clusterName , domainUid , domainNamespace , managedServerPodNamePrefix ,
260
- numberOfServers , replicaCount , curlCmd , managedServersBeforeScale );
256
+ if (OKE_CLUSTER ) {
257
+ logger .info ("Scaling cluster {0} of domain {1} in namespace {2} to {3} servers." ,
258
+ clusterName , domainUid , domainNamespace , numberOfServers );
259
+ scaleAndVerifyCluster (clusterName , domainUid , domainNamespace , managedServerPodNamePrefix ,
260
+ replicaCount , numberOfServers , null , null );
261
+
262
+ // then scale cluster back to 1 servers
263
+ logger .info ("Scaling cluster {0} of domain {1} in namespace {2} from {3} servers to {4} servers." ,
264
+ clusterName , domainUid , domainNamespace , numberOfServers , replicaCount );
265
+ scaleAndVerifyCluster (clusterName , domainUid , domainNamespace , managedServerPodNamePrefix ,
266
+ numberOfServers , replicaCount , null , null );
267
+ } else {
268
+ logger .info ("Scaling cluster {0} of domain {1} in namespace {2} to {3} servers." ,
269
+ clusterName , domainUid , domainNamespace , numberOfServers );
270
+ curlCmd = generateCurlCmd (domainUid , domainNamespace , clusterName , SAMPLE_APP_CONTEXT_ROOT );
271
+ List <String > managedServersBeforeScale = listManagedServersBeforeScale (numClusters , clusterName , replicaCount );
272
+ scaleAndVerifyCluster (clusterName , domainUid , domainNamespace , managedServerPodNamePrefix ,
273
+ replicaCount , numberOfServers , curlCmd , managedServersBeforeScale );
274
+
275
+ // then scale cluster back to 1 servers
276
+ logger .info ("Scaling cluster {0} of domain {1} in namespace {2} from {3} servers to {4} servers." ,
277
+ clusterName , domainUid , domainNamespace , numberOfServers , replicaCount );
278
+ managedServersBeforeScale = listManagedServersBeforeScale (numClusters , clusterName , numberOfServers );
279
+ scaleAndVerifyCluster (clusterName , domainUid , domainNamespace , managedServerPodNamePrefix ,
280
+ numberOfServers , replicaCount , curlCmd , managedServersBeforeScale );
281
+ }
261
282
}
262
283
263
284
// verify admin console login
264
- if (!WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT )) {
285
+ if (OKE_CLUSTER ) {
286
+ String resourcePath = "/console/login/LoginForm.jsp" ;
287
+ final String adminServerPodName = domainUid + "-admin-server" ;
288
+ ExecResult result = exeAppInServerPod (domainNamespace , adminServerPodName , ADMIN_SERVER_PORT , resourcePath );
289
+ logger .info ("result in OKE_CLUSTER is {0}" , result .toString ());
290
+ assertEquals (0 , result .exitValue (), "Failed to access WebLogic console" );
291
+
292
+ // verify admin console login using ingress controller
293
+ verifyReadyAppUsingIngressController (domainUid , domainNamespace );
294
+ } else if (!WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT )) {
265
295
hostHeader = createIngressHostRoutingIfNotExists (domainNamespace , domainUid );
266
296
assertDoesNotThrow (()
267
297
-> verifyAdminServerRESTAccess ("localhost" , TRAEFIK_INGRESS_HTTP_HOSTPORT , false , hostHeader ));
@@ -305,25 +335,47 @@ void testScaleClustersWithRestApi(String domainType) {
305
335
String clusterName = domain .getSpec ().getClusters ().get (0 ).getName ();
306
336
String managedServerPodNamePrefix = generateMsPodNamePrefix (numClusters , domainUid , clusterName );
307
337
int numberOfServers = 3 ;
338
+ String operatorPodName = null ;
339
+ curlCmd = generateCurlCmd (domainUid , domainNamespace , clusterName , SAMPLE_APP_CONTEXT_ROOT );
340
+
341
+ if (OKE_CLUSTER ) {
342
+ // get operator pod name
343
+ operatorPodName = assertDoesNotThrow (() -> getOperatorPodName (OPERATOR_RELEASE_NAME , opNamespace ));
344
+ assertNotNull (operatorPodName , "Operator pod name returned is null" );
345
+ logger .info ("Operator pod name {0}" , operatorPodName );
346
+ curlCmd = domainType .contains ("modelInImage" )
347
+ ? generateCurlCmd (domainUid , domainNamespace , clusterName , SAMPLE_APP_CONTEXT_ROOT ) : null ;
348
+ }
308
349
309
350
logger .info ("Scaling cluster {0} of domain {1} in namespace {2} from {3} servers to {4} servers." ,
310
351
clusterName , domainUid , domainNamespace , replicaCount , numberOfServers );
311
- curlCmd = generateCurlCmd (domainUid , domainNamespace , clusterName , SAMPLE_APP_CONTEXT_ROOT );
352
+ // curlCmd = generateCurlCmd(domainUid, domainNamespace, clusterName, SAMPLE_APP_CONTEXT_ROOT);
312
353
List <String > managedServersBeforeScale = listManagedServersBeforeScale (numClusters , clusterName , replicaCount );
313
354
scaleAndVerifyCluster (clusterName , domainUid , domainNamespace , managedServerPodNamePrefix ,
314
355
replicaCount , numberOfServers , true , OPERATOR_EXTERNAL_REST_HTTPSPORT , opNamespace , opServiceAccount ,
315
- false , "" , "" , 0 , "" , "" , curlCmd , managedServersBeforeScale );
356
+ false , "" , "" , 0 , "" , "" ,
357
+ curlCmd , managedServersBeforeScale , operatorPodName );
316
358
317
359
// then scale cluster back to 2 servers
318
360
logger .info ("Scaling cluster {0} of domain {1} in namespace {2} from {3} servers to {4} servers." ,
319
361
clusterName , domainUid , domainNamespace , numberOfServers , replicaCount );
320
362
managedServersBeforeScale = listManagedServersBeforeScale (numClusters , clusterName , numberOfServers );
321
363
scaleAndVerifyCluster (clusterName , domainUid , domainNamespace , managedServerPodNamePrefix ,
322
364
numberOfServers , replicaCount , true , OPERATOR_EXTERNAL_REST_HTTPSPORT , opNamespace , opServiceAccount ,
323
- false , "" , "" , 0 , "" , "" , curlCmd , managedServersBeforeScale );
365
+ false , "" , "" , 0 , "" , "" ,
366
+ curlCmd , managedServersBeforeScale , operatorPodName );
324
367
325
368
// verify admin console login
326
- if (!WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT )) {
369
+ if (OKE_CLUSTER ) {
370
+ String resourcePath = "/console/login/LoginForm.jsp" ;
371
+ final String adminServerPodName = domainUid + "-admin-server" ;
372
+ ExecResult result = exeAppInServerPod (domainNamespace , adminServerPodName ,ADMIN_SERVER_PORT , resourcePath );
373
+ logger .info ("result in OKE_CLUSTER is {0}" , result .toString ());
374
+ assertEquals (0 , result .exitValue (), "Failed to access WebLogic console" );
375
+
376
+ // verify admin console login using ingress controller
377
+ verifyReadyAppUsingIngressController (domainUid , domainNamespace );
378
+ } else if (!WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT )) {
327
379
hostHeader = createIngressHostRoutingIfNotExists (domainNamespace , domainUid );
328
380
assertDoesNotThrow (()
329
381
-> verifyAdminServerRESTAccess ("localhost" , TRAEFIK_INGRESS_HTTP_HOSTPORT , false , hostHeader ));
@@ -341,6 +393,10 @@ void testScaleClustersWithRestApi(String domainType) {
341
393
* Scale cluster using WLDF policy for three different type of domains.
342
394
* i.e. domain-on-pv, domain-in-image and model-in-image
343
395
*
396
+ * In internal OKE env, we only test scaling cluster using WLDF policy for domain type, model-in-image.
397
+ * domain type, domain-in-image is excluded and domain type, domain-on-pv is tested in
398
+ * ItMultiDomainModelsScaleWithWLDFDomainOnPV.java
399
+ *
344
400
* @param domainType domain type, possible value: modelInImage, domainInImage, domainOnPV
345
401
*/
346
402
@ ParameterizedTest
@@ -361,15 +417,21 @@ void testScaleClustersWithWLDF(String domainType) {
361
417
String managedServerPodNamePrefix = generateMsPodNamePrefix (numClusters , domainUid , clusterName );
362
418
363
419
curlCmd = generateCurlCmd (domainUid , domainNamespace , clusterName , SAMPLE_APP_CONTEXT_ROOT );
364
- logger .info ("BR: curlCmd = {0}" , curlCmd );
420
+ logger .info ("Generated curlCmd = {0}" , curlCmd );
421
+
422
+ // domain type, domain-in-image is excluded and domain type, domain-on-pv is tested in
423
+ // ItMultiDomainModelsScaleWithWLDFDomainOnPV.java
424
+ if (OKE_CLUSTER && (domainType .contains ("domainInImage" ) || domainType .contains ("domainOnPV" ))) {
425
+ return ;
426
+ }
365
427
366
428
// scale up the cluster by 1 server
367
429
logger .info ("Scaling cluster {0} of domain {1} in namespace {2} from {3} servers to {4} servers." ,
368
430
clusterName , domainUid , domainNamespace , replicaCount , replicaCount + 1 );
369
431
List <String > managedServersBeforeScale = listManagedServersBeforeScale (numClusters , clusterName , replicaCount );
370
432
String curlCmdForWLDFScript =
371
433
generateCurlCmd (domainUid , domainNamespace , clusterName , WLDF_OPENSESSION_APP_CONTEXT_ROOT );
372
- logger .info ("BR: curlCmdForWLDFScript = {0}" , curlCmdForWLDFScript );
434
+ logger .info ("Generated curlCmdForWLDFScript = {0}" , curlCmdForWLDFScript );
373
435
374
436
scaleAndVerifyCluster (clusterName , domainUid , domainNamespace , managedServerPodNamePrefix ,
375
437
replicaCount , replicaCount + 1 , false , OPERATOR_EXTERNAL_REST_HTTPSPORT , opNamespace , opServiceAccount ,
@@ -387,7 +449,16 @@ void testScaleClustersWithWLDF(String domainType) {
387
449
WLDF_OPENSESSION_APP , curlCmdForWLDFScript , curlCmd , managedServersBeforeScale );
388
450
389
451
// verify admin console login
390
- if (!WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT )) {
452
+ if (OKE_CLUSTER ) {
453
+ String resourcePath = "/console/login/LoginForm.jsp" ;
454
+ final String adminServerPodName = domainUid + "-admin-server" ;
455
+ ExecResult result = exeAppInServerPod (domainNamespace , adminServerPodName ,ADMIN_SERVER_PORT , resourcePath );
456
+ logger .info ("result in OKE_CLUSTER is {0}" , result .toString ());
457
+ assertEquals (0 , result .exitValue (), "Failed to access WebLogic console" );
458
+
459
+ // verify admin console login using ingress controller
460
+ verifyReadyAppUsingIngressController (domainUid , domainNamespace );
461
+ } else if (!WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT )) {
391
462
hostHeader = createIngressHostRoutingIfNotExists (domainNamespace , domainUid );
392
463
assertDoesNotThrow (()
393
464
-> verifyAdminServerRESTAccess ("localhost" , TRAEFIK_INGRESS_HTTP_HOSTPORT , false , hostHeader ));
@@ -575,22 +646,30 @@ private static DomainResource createDomainOnPvUsingWdt(String domainUid, String
575
646
* @param appContextRoot the context root of the application
576
647
* @return curl command string
577
648
*/
578
- private static String generateCurlCmd (String domainUid , String domainNamespace , String clusterName ,
649
+ private static String generateCurlCmd (String domainUid ,
650
+ String domainNamespace ,
651
+ String clusterName ,
579
652
String appContextRoot ) {
580
653
if (OKD ) {
581
654
String routeHost = getRouteHost (domainNamespace , domainUid + "-cluster-" + clusterName );
582
655
logger .info ("routeHost = {0}" , routeHost );
583
- return String .format ("curl -g -v --show-error --noproxy '*' http://%s/%s/index.jsp" ,
584
- routeHost , appContextRoot );
585
-
656
+ return String .format ("curl -g -v --show-error --noproxy '*' http://%s/%s/index.jsp" , routeHost , appContextRoot );
586
657
} else {
587
658
String host = K8S_NODEPORT_HOST ;
588
659
if (host .contains (":" )) {
589
660
host = "[" + host + "]" ;
590
661
}
591
- return String .format ("curl -g -v --show-error --noproxy '*' -H 'host: %s' http://%s/%s/index.jsp" ,
592
- domainUid + "." + domainNamespace + "." + clusterName + ".test" ,
593
- getHostAndPort (host , nodeportshttp ), appContextRoot );
662
+ if (OKE_CLUSTER ) {
663
+ String nginxServiceName = nginxHelmParams .getHelmParams ().getReleaseName () + "-ingress-nginx-controller" ;
664
+
665
+ return String .format ("curl -g -v --show-error --noproxy '*' -H 'host: %s' http://%s/%s/index.jsp" ,
666
+ domainUid + "." + domainNamespace + "." + clusterName + ".test" ,
667
+ getServiceExtIPAddrtOke (nginxServiceName , nginxNamespace ), appContextRoot );
668
+ } else {
669
+ return String .format ("curl -g -v --show-error --noproxy '*' -H 'host: %s' http://%s/%s/index.jsp" ,
670
+ domainUid + "." + domainNamespace + "." + clusterName + ".test" ,
671
+ getHostAndPort (host , nodeportshttp ), appContextRoot );
672
+ }
594
673
}
595
674
}
596
675
@@ -740,7 +819,10 @@ private static void createRouteForOKDOrIngressForDomain(DomainResource domain) {
740
819
741
820
if (!OKD ) {
742
821
logger .info ("Creating ingress for domain {0} in namespace {1}" , domainUid , domainNamespace );
743
- if (WLSIMG_BUILDER .equals (WLSIMG_BUILDER_DEFAULT )) {
822
+ if (OKE_CLUSTER ) {
823
+ createIngressForDomainAndVerify (domainUid , domainNamespace , 0 , clusterNameMsPortMap ,
824
+ false , nginxHelmParams .getIngressClassName (), false , 0 );
825
+ } else if (WLSIMG_BUILDER .equals (WLSIMG_BUILDER_DEFAULT )) {
744
826
createIngressForDomainAndVerify (domainUid , domainNamespace , nodeportshttp , clusterNameMsPortMap ,
745
827
true , nginxHelmParams .getIngressClassName (), true , ADMIN_SERVER_PORT );
746
828
} else {
@@ -820,22 +902,30 @@ private void verifyReadyAppUsingAdminNodePort(String domainUid, String domainNam
820
902
private void verifyReadyAppUsingIngressController (String domainUid , String domainNamespace ) {
821
903
822
904
if (!OKD ) {
905
+ if (OKE_CLUSTER ) {
906
+ final String adminServerPodName = domainUid + "-admin-server" ;
907
+ String resourcePath = "/weblogic/ready" ;
908
+ ExecResult result = exeAppInServerPod (domainNamespace , adminServerPodName , 7002 , resourcePath );
909
+ logger .info ("result in OKE_CLUSTER is {0}" , result .toString ());
910
+ assertEquals (0 , result .exitValue (), "Failed to access WebLogic ready app" );
911
+ } else {
912
+ String host = K8S_NODEPORT_HOST ;
913
+ if (host .contains (":" )) {
914
+ host = "[" + host + "]" ;
915
+ }
823
916
824
- String host = K8S_NODEPORT_HOST ;
825
- if (host .contains (":" )) {
826
- host = "[" + host + "]" ;
917
+ String curlCmd = "curl -g --silent --show-error --noproxy '*' -H 'host: "
918
+ + domainUid + "." + domainNamespace + ".adminserver.test"
919
+ + "' http://" + host + ":" + nodeportshttp
920
+ + "/weblogic/ready --write-out %{http_code} -o /dev/null" ;
921
+
922
+ logger .info ("Executing curl command {0}" , curlCmd );
923
+ testUntil (() -> callWebAppAndWaitTillReady (curlCmd , 5 ),
924
+ logger ,
925
+ "Ready app on domain {0} in namespace {1} is accessible" ,
926
+ domainUid ,
927
+ domainNamespace );
827
928
}
828
- String curlCmd = "curl -g --silent --show-error --noproxy '*' -H 'host: "
829
- + domainUid + "." + domainNamespace + ".adminserver.test"
830
- + "' http://" + host + ":" + nodeportshttp
831
- + "/weblogic/ready --write-out %{http_code} -o /dev/null" ;
832
-
833
- logger .info ("Executing curl command {0}" , curlCmd );
834
- testUntil (() -> callWebAppAndWaitTillReady (curlCmd , 5 ),
835
- logger ,
836
- "Ready app on domain {0} in namespace {1} is accessible" ,
837
- domainUid ,
838
- domainNamespace );
839
929
840
930
logger .info ("Ready app on domain1 is accessible" );
841
931
} else {
0 commit comments