54
54
import static oracle .weblogic .kubernetes .TestConstants .KUBERNETES_CLI ;
55
55
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_NAME ;
56
56
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
57
+ import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER ;
57
58
import static oracle .weblogic .kubernetes .TestConstants .TEST_IMAGES_REPO_SECRET_NAME ;
58
59
import static oracle .weblogic .kubernetes .actions .ActionConstants .MODEL_DIR ;
59
60
import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
71
72
import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .verifyUpdateWebLogicCredential ;
72
73
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodReadyAndServiceExists ;
73
74
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkServiceExists ;
75
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .exeAppInServerPod ;
74
76
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getHostAndPort ;
75
77
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getNextFreePort ;
76
78
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getUniqueName ;
100
102
import static org .junit .jupiter .api .Assertions .assertNotNull ;
101
103
import static org .junit .jupiter .api .Assertions .assertTrue ;
102
104
105
+
103
106
/**
104
107
* This test class verifies dynamic changes to domain resource and configuration
105
108
* by modifying the associated configmap with a model-in-image domain.
111
114
@ DisplayName ("Test logHome on PV, add SystemResources, Clusters to model in image domain" )
112
115
@ IntegrationTest
113
116
@ Tag ("olcne-mrg" )
114
- @ Tag ("oke-parallel" )
115
117
@ Tag ("kind-parallel" )
116
118
@ Tag ("toolkits-srg" )
117
119
@ Tag ("okd-wls-srg" )
120
+ @ Tag ("oke-gate" )
118
121
class ItMiiUpdateDomainConfig {
119
122
120
123
private static String opNamespace = null ;
@@ -124,7 +127,6 @@ class ItMiiUpdateDomainConfig {
124
127
private static final String pvName = getUniqueName (domainUid + "-pv-" );
125
128
private static final String pvcName = getUniqueName (domainUid + "-pvc-" );
126
129
private StringBuffer curlString = null ;
127
- private StringBuffer checkCluster = null ;
128
130
private V1Patch patch = null ;
129
131
private final String adminServerPodName = domainUid + "-admin-server" ;
130
132
private final String managedServerPrefix = domainUid + "-managed-server" ;
@@ -264,17 +266,25 @@ void testMiiCustomEnv() {
264
266
int adminServiceNodePort
265
267
= getServiceNodePort (domainNamespace , getExternalServicePodName (adminServerPodName ), "default" );
266
268
269
+ String hostAndPort =
270
+ OKE_CLUSTER ? adminServerPodName + ":7001" : getHostAndPort (adminSvcExtHost , adminServiceNodePort );
271
+
267
272
String curlString = new StringBuffer ()
268
273
.append ("curl --user " )
269
274
.append (ADMIN_USERNAME_DEFAULT )
270
275
.append (":" )
271
276
.append (ADMIN_PASSWORD_DEFAULT )
272
277
.append (" " )
273
- .append ("\" http://" + getHostAndPort ( adminSvcExtHost , adminServiceNodePort ) )
278
+ .append ("\" http://" + hostAndPort )
274
279
.append ("/management/weblogic/latest/domainConfig" )
275
280
.append ("/JMSServers/TestClusterJmsServer" )
276
281
.append ("?fields=notes&links=none\" " )
277
282
.append (" --silent " ).toString ();
283
+
284
+ if (OKE_CLUSTER ) {
285
+ curlString = KUBERNETES_CLI + " exec -n " + domainNamespace + " " + adminServerPodName + " -- " + curlString ;
286
+ }
287
+
278
288
logger .info ("checkJmsServerConfig: curl command {0}" , curlString );
279
289
verifyCommandResultContainsMsg (curlString , "${DOMAIN_UID}~##!'%*$(ls)" );
280
290
}
@@ -341,21 +351,51 @@ void testMiiCheckSystemResources() {
341
351
= getServiceNodePort (domainNamespace , getExternalServicePodName (adminServerPodName ), "default" );
342
352
assertNotEquals (-1 , adminServiceNodePort , "admin server default node port is not valid" );
343
353
344
- verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
345
- "JDBCSystemResources" , "TestDataSource" , "200" );
346
- logger .info ("Found the JDBCSystemResource configuration" );
347
-
348
- verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
349
- "JMSSystemResources" , "TestClusterJmsModule" , "200" );
350
- logger .info ("Found the JMSSystemResource configuration" );
351
-
352
- verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
353
- "WLDFSystemResources" , "TestWldfModule" , "200" );
354
- logger .info ("Found the WLDFSystemResource configuration" );
355
-
356
- verifyJdbcRuntime ("TestDataSource" , "jdbc:oracle:thin:localhost" );
357
- verifyJdbcRuntime ("TestDataSource" , "scott" );
358
- logger .info ("Found the JDBCSystemResource configuration" );
354
+ if (OKE_CLUSTER ) {
355
+ String resourcePath = "/management/weblogic/latest/domainConfig/JDBCSystemResources/TestDataSource" ;
356
+ ExecResult result = exeAppInServerPod (domainNamespace , adminServerPodName ,7001 , resourcePath );
357
+ assertEquals (0 , result .exitValue (), "Failed to find the JDBCSystemResource configuration" );
358
+ assertTrue (result .toString ().contains ("JDBCSystemResources" ),
359
+ "Failed to find the JDBCSystemResource configuration" );
360
+ logger .info ("Found the JDBCSystemResource configuration" );
361
+
362
+ resourcePath = "/management/weblogic/latest/domainConfig/JMSSystemResources/TestClusterJmsModule" ;
363
+ result = exeAppInServerPod (domainNamespace , adminServerPodName ,7001 , resourcePath );
364
+ assertEquals (0 , result .exitValue (), "Failed to find the JMSSystemResources configuration" );
365
+ assertTrue (result .toString ().contains ("JMSSystemResources" ),
366
+ "Failed to find the JMSSystemResources configuration" );
367
+ logger .info ("Found the JMSSystemResource configuration" );
368
+
369
+ resourcePath = "/management/weblogic/latest/domainConfig/WLDFSystemResources/TestWldfModule" ;
370
+ result = exeAppInServerPod (domainNamespace , adminServerPodName ,7001 , resourcePath );
371
+ assertEquals (0 , result .exitValue (), "Failed to find the WLDFSystemResources configuration" );
372
+ assertTrue (result .toString ().contains ("WLDFSystemResources" ),
373
+ "Failed to find the WLDFSystemResources configuration" );
374
+ logger .info ("Found the WLDFSystemResources configuration" );
375
+
376
+ resourcePath = "/management/wls/latest/datasources/id/TestDataSource" ;
377
+ result = exeAppInServerPod (domainNamespace , adminServerPodName ,7001 , resourcePath );
378
+ assertEquals (0 , result .exitValue (), "Failed to find the JDBCSystemResource configuration" );
379
+ assertTrue (result .toString ().contains ("scott" ),
380
+ "Failed to find the JDBCSystemResource configuration" );
381
+ logger .info ("Found the JDBCSystemResource configuration" );
382
+ } else {
383
+ verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
384
+ "JDBCSystemResources" , "TestDataSource" , "200" );
385
+ logger .info ("Found the JDBCSystemResource configuration" );
386
+
387
+ verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
388
+ "JMSSystemResources" , "TestClusterJmsModule" , "200" );
389
+ logger .info ("Found the JMSSystemResource configuration" );
390
+
391
+ verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
392
+ "WLDFSystemResources" , "TestWldfModule" , "200" );
393
+ logger .info ("Found the WLDFSystemResource configuration" );
394
+
395
+ verifyJdbcRuntime ("TestDataSource" , "jdbc:oracle:thin:localhost" );
396
+ verifyJdbcRuntime ("TestDataSource" , "scott" );
397
+ logger .info ("Found the JDBCSystemResource configuration" );
398
+ }
359
399
}
360
400
361
401
/**
@@ -416,13 +456,27 @@ void testMiiDeleteSystemResources() {
416
456
checkServiceExists (managedServerPrefix + i , domainNamespace );
417
457
}
418
458
419
- int adminServiceNodePort
420
- = getServiceNodePort (domainNamespace , getExternalServicePodName (adminServerPodName ), "default" );
421
- assertNotEquals (-1 , adminServiceNodePort , "admin server default node port is not valid" );
422
- verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
423
- "JDBCSystemResources" , "TestDataSource" , "404" );
424
- verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
425
- "JMSSystemResources" , "TestClusterJmsModule" , "404" );
459
+ if (OKE_CLUSTER ) {
460
+ String resourcePath = "/management/weblogic/latest/domainConfig/JDBCSystemResources/TestDataSource" ;
461
+ ExecResult result = exeAppInServerPod (domainNamespace , adminServerPodName , 7001 , resourcePath );
462
+ assertEquals (0 , result .exitValue (), "Failed to delete the JDBCSystemResource configuration" );
463
+ assertTrue (result .toString ().contains ("404" ), "Failed to delete the JDBCSystemResource configuration" );
464
+ logger .info ("The JDBCSystemResource configuration is deleted" );
465
+
466
+ resourcePath = "/management/weblogic/latest/domainConfig/JMSSystemResources/TestClusterJmsModule" ;
467
+ result = exeAppInServerPod (domainNamespace , adminServerPodName , 7001 , resourcePath );
468
+ assertEquals (0 , result .exitValue (), "Failed to delete the JMSSystemResources configuration" );
469
+ assertTrue (result .toString ().contains ("404" ), "Failed to delete the JMSSystemResources configuration" );
470
+ logger .info ("The JMSSystemResource configuration is deleted" );
471
+ } else {
472
+ int adminServiceNodePort
473
+ = getServiceNodePort (domainNamespace , getExternalServicePodName (adminServerPodName ), "default" );
474
+ assertNotEquals (-1 , adminServiceNodePort , "admin server default node port is not valid" );
475
+ verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
476
+ "JDBCSystemResources" , "TestDataSource" , "404" );
477
+ verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
478
+ "JMSSystemResources" , "TestClusterJmsModule" , "404" );
479
+ }
426
480
}
427
481
428
482
/**
@@ -482,17 +536,33 @@ void testMiiAddSystemResources() {
482
536
checkServiceExists (managedServerPrefix + i , domainNamespace );
483
537
}
484
538
485
- int adminServiceNodePort
486
- = getServiceNodePort (domainNamespace , getExternalServicePodName (adminServerPodName ), "default" );
487
- assertNotEquals (-1 , adminServiceNodePort , "admin server default node port is not valid" );
488
-
489
- verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
490
- "JDBCSystemResources" , "TestDataSource2" , "200" );
491
- logger .info ("Found the JDBCSystemResource configuration" );
492
-
493
- verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
494
- "JMSSystemResources" , "TestClusterJmsModule2" , "200" );
495
- logger .info ("Found the JMSSystemResource configuration" );
539
+ if (OKE_CLUSTER ) {
540
+ String resourcePath = "/management/weblogic/latest/domainConfig/JDBCSystemResources/TestDataSource2" ;
541
+ ExecResult result = exeAppInServerPod (domainNamespace , adminServerPodName , 7001 , resourcePath );
542
+ assertEquals (0 , result .exitValue (), "Failed to find the JDBCSystemResource configuration" );
543
+ assertTrue (result .toString ().contains ("JDBCSystemResources" ),
544
+ "Failed to find the JDBCSystemResource configuration" );
545
+ logger .info ("Found the JDBCSystemResource configuration" );
546
+
547
+ resourcePath = "/management/weblogic/latest/domainConfig/JMSSystemResources/TestClusterJmsModule2" ;
548
+ result = exeAppInServerPod (domainNamespace , adminServerPodName , 7001 , resourcePath );
549
+ assertEquals (0 , result .exitValue (), "Failed to find the JMSSystemResources configuration" );
550
+ assertTrue (result .toString ().contains ("JMSSystemResources" ),
551
+ "Failed to find the JMSSystemResources configuration" );
552
+ logger .info ("Found the JMSSystemResource configuration" );
553
+ } else {
554
+ int adminServiceNodePort
555
+ = getServiceNodePort (domainNamespace , getExternalServicePodName (adminServerPodName ), "default" );
556
+ assertNotEquals (-1 , adminServiceNodePort , "admin server default node port is not valid" );
557
+
558
+ verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
559
+ "JDBCSystemResources" , "TestDataSource2" , "200" );
560
+ logger .info ("Found the JDBCSystemResource configuration" );
561
+
562
+ verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
563
+ "JMSSystemResources" , "TestClusterJmsModule2" , "200" );
564
+ logger .info ("Found the JMSSystemResource configuration" );
565
+ }
496
566
497
567
// check JMS logs are written on PV
498
568
checkLogsOnPV ("ls -ltr /shared/" + domainNamespace + "/logs/*jms_messages.log" , managedServerPrefix + "1" );
@@ -559,13 +629,11 @@ void testMiiAddDynamicCluster() {
559
629
560
630
// Check if the admin server pod has been restarted
561
631
// by comparing the PodCreationTime before and after rolling restart
562
-
563
632
assertTrue (verifyRollingRestartOccurred (pods , 1 , domainNamespace ),
564
633
"Rolling restart failed" );
565
634
566
635
// The ServerNamePrefix for the new dynamic cluster is dynamic-server
567
636
// Make sure the managed server from the new cluster is running
568
-
569
637
String newServerPodName = domainUid + "-dynamic-server1" ;
570
638
checkPodReady (newServerPodName , domainUid , domainNamespace );
571
639
checkServiceExists (newServerPodName , domainNamespace );
@@ -803,13 +871,27 @@ void testMiiDeleteSystemResourcesByEmptyConfigMap() {
803
871
checkServiceExists (managedServerPrefix + i , domainNamespace );
804
872
}
805
873
806
- int adminServiceNodePort
807
- = getServiceNodePort (domainNamespace , getExternalServicePodName (adminServerPodName ), "default" );
808
- assertNotEquals (-1 , adminServiceNodePort , "admin server default node port is not valid" );
809
- verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
810
- "JDBCSystemResources" , "TestDataSource" , "404" );
811
- verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
812
- "JMSSystemResources" , "TestClusterJmsModule" , "404" );
874
+ if (OKE_CLUSTER ) {
875
+ String resourcePath = "/management/weblogic/latest/domainConfig/JDBCSystemResources/TestDataSource" ;
876
+ ExecResult result = exeAppInServerPod (domainNamespace , adminServerPodName , 7001 , resourcePath );
877
+ assertEquals (0 , result .exitValue (), "Failed to delete the JDBCSystemResource configuration" );
878
+ assertTrue (result .toString ().contains ("404" ), "Failed to delete the JDBCSystemResource configuration" );
879
+ logger .info ("The JDBCSystemResource configuration is deleted" );
880
+
881
+ resourcePath = "/management/weblogic/latest/domainConfig/JMSSystemResources/TestClusterJmsModule" ;
882
+ result = exeAppInServerPod (domainNamespace , adminServerPodName , 7001 , resourcePath );
883
+ assertEquals (0 , result .exitValue (), "Failed to delete the JMSSystemResources configuration" );
884
+ assertTrue (result .toString ().contains ("404" ), "Failed to delete the JMSSystemResources configuration" );
885
+ logger .info ("The JMSSystemResource configuration is deleted" );
886
+ } else {
887
+ int adminServiceNodePort
888
+ = getServiceNodePort (domainNamespace , getExternalServicePodName (adminServerPodName ), "default" );
889
+ assertNotEquals (-1 , adminServiceNodePort , "admin server default node port is not valid" );
890
+ verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
891
+ "JDBCSystemResources" , "TestDataSource" , "404" );
892
+ verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
893
+ "JMSSystemResources" , "TestClusterJmsModule" , "404" );
894
+ }
813
895
}
814
896
815
897
// Run standalone JMS Client in the pod using wlthint3client.jar in classpath.
@@ -918,26 +1000,41 @@ private static DomainResource createDomainResource(
918
1000
}
919
1001
920
1002
private void verifyManagedServerConfiguration (String managedServer ) {
921
-
922
1003
int adminServiceNodePort
923
1004
= getServiceNodePort (domainNamespace , getExternalServicePodName (adminServerPodName ), "default" );
924
-
925
- checkCluster = new StringBuffer ("status=$(curl --user " );
926
- checkCluster .append (ADMIN_USERNAME_DEFAULT )
927
- .append (":" )
928
- .append (ADMIN_PASSWORD_DEFAULT )
929
- .append (" " )
930
- .append ("http://" + getHostAndPort (adminSvcExtHost , adminServiceNodePort ))
931
- .append ("/management/tenant-monitoring/servers/" )
932
- .append (managedServer )
933
- .append (" --silent --show-error " )
934
- .append (" -o /dev/null" )
935
- .append (" -w %{http_code});" )
1005
+ String hostAndPort =
1006
+ OKE_CLUSTER ? adminServerPodName + ":7001" : getHostAndPort (adminSvcExtHost , adminServiceNodePort );
1007
+
1008
+ StringBuffer checkClusterBaseCmd = new StringBuffer ("curl --user " )
1009
+ .append (ADMIN_USERNAME_DEFAULT )
1010
+ .append (":" )
1011
+ .append (ADMIN_PASSWORD_DEFAULT )
1012
+ .append (" " )
1013
+ .append ("http://" + hostAndPort )
1014
+ .append ("/management/tenant-monitoring/servers/" )
1015
+ .append (managedServer )
1016
+ .append (" --silent --show-error -o /dev/null -w %{http_code}" );
1017
+
1018
+ StringBuffer checkCluster = new StringBuffer ();
1019
+
1020
+ if (OKE_CLUSTER ) {
1021
+ checkCluster = new StringBuffer (KUBERNETES_CLI )
1022
+ .append (" exec -n " )
1023
+ .append (domainNamespace )
1024
+ .append (" " )
1025
+ .append (adminServerPodName )
1026
+ .append (" -- " )
1027
+ .append (checkClusterBaseCmd );
1028
+ } else {
1029
+ checkCluster = new StringBuffer ("status=$(" );
1030
+ checkCluster .append (checkClusterBaseCmd )
1031
+ .append (");" )
936
1032
.append ("echo ${status}" );
937
- logger . info ( "checkManagedServerConfiguration: curl command {0}" , new String ( checkCluster ));
1033
+ }
938
1034
1035
+ logger .info ("checkManagedServerConfiguration: curl command {0}" , new String (checkCluster ));
939
1036
verifyCommandResultContainsMsg (new String (checkCluster ), "200" );
940
-
1037
+ logger . info ( "Command to check managedServer configuration: {0} succeeded" , new String ( checkCluster ));
941
1038
}
942
1039
943
1040
// Crate a ConfigMap with a model file to add a new WebLogic cluster
@@ -1005,7 +1102,5 @@ private void checkLogsOnPV(String commandToExecuteInsidePod, String podName) {
1005
1102
assertFalse (result .exitValue () != 0 && result .stderr () != null && !result .stderr ().isEmpty (),
1006
1103
String .format ("Command %s failed with exit value %s, stderr %s, stdout %s" ,
1007
1104
commandToExecuteInsidePod , result .exitValue (), result .stderr (), result .stdout ()));
1008
-
1009
1105
}
1010
-
1011
1106
}
0 commit comments