1
- // Copyright (c) 2020, 2024 , Oracle and/or its affiliates.
1
+ // Copyright (c) 2020, 2025 , 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 ;
116
116
@ TestMethodOrder (MethodOrderer .OrderAnnotation .class )
117
117
@ DisplayName ("Test logHome on PV, add SystemResources, Clusters to model in image domain" )
118
118
@ IntegrationTest
119
- @ Tag ("olcne-mrg " )
119
+ @ Tag ("olcne-sequential " )
120
120
@ Tag ("kind-parallel" )
121
121
@ Tag ("toolkits-srg" )
122
122
@ Tag ("okd-wls-srg" )
@@ -192,7 +192,6 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
192
192
configMapName , domainUid , domainNamespace ,
193
193
Arrays .asList (MODEL_DIR + "/model.sysresources.yaml" ));
194
194
195
-
196
195
// create pull secrets for WebLogic image when running in non Kind Kubernetes cluster
197
196
// this secret is used only for non-kind cluster
198
197
createBaseRepoSecret (domainNamespace );
@@ -257,7 +256,7 @@ public void beforeEach() {
257
256
* Check the environment variable with special characters.
258
257
*/
259
258
@ Test
260
- @ Order (0 )
259
+ @ Order (1 )
261
260
@ DisplayName ("Check environment variable with special characters" )
262
261
void testMiiCustomEnv () {
263
262
DomainResource domain1 = assertDoesNotThrow (() -> getDomainCustomResource (domainUid , domainNamespace ),
@@ -271,7 +270,7 @@ void testMiiCustomEnv() {
271
270
if (envList .get (i ).getName ().equalsIgnoreCase ("CUSTOM_ENV" )) {
272
271
assertTrue (envList .get (i ).getValue () != null
273
272
&& envList .get (i ).getValue ().equalsIgnoreCase ("${DOMAIN_UID}~##!'%*$(ls)" ),
274
- "Expected value for CUSTOM_ENV variable does not mtach " );
273
+ "Expected value for CUSTOM_ENV variable does not match " );
275
274
found = true ;
276
275
}
277
276
}
@@ -320,7 +319,7 @@ void testMiiCustomEnv() {
320
319
* The test looks for the string RUNNING in the server log
321
320
*/
322
321
@ Test
323
- @ Order (1 )
322
+ @ Order (2 )
324
323
@ DisplayName ("Check the server logs are written to PersistentVolume" )
325
324
void testMiiServerLogsAreOnPV () {
326
325
// check server logs are written on PV and look for string RUNNING in log
@@ -334,7 +333,7 @@ void testMiiServerLogsAreOnPV() {
334
333
* logs
335
334
*/
336
335
@ Test
337
- @ Order (2 )
336
+ @ Order (3 )
338
337
@ DisplayName ("Check the HTTP server logs are written to PersistentVolume" )
339
338
void testMiiHttpServerLogsAreOnPV () {
340
339
String [] podNames = {managedServerPrefix + "1" , managedServerPrefix + "2" };
@@ -369,7 +368,7 @@ void testMiiHttpServerLogsAreOnPV() {
369
368
* using the public node port of the administration server.
370
369
*/
371
370
@ Test
372
- @ Order (3 )
371
+ @ Order (4 )
373
372
@ DisplayName ("Verify the pre-configured SystemResources in the domain" )
374
373
void testMiiCheckSystemResources () {
375
374
@@ -424,6 +423,84 @@ void testMiiCheckSystemResources() {
424
423
}
425
424
}
426
425
426
+ /**
427
+ * Start a WebLogic domain using model-in-image with JMS/JDBC SystemResources.
428
+ * Create a empty configmap to delete JMS/JDBC SystemResources
429
+ * Patch the domain resource with the configmap.
430
+ * Update the restart version of the domain resource.
431
+ * Verify rolling restart of the domain by comparing PodCreationTimestamp
432
+ * for all the server pods before and after rolling restart.
433
+ * Verify SystemResources are deleted from the domain.
434
+ */
435
+ @ Test
436
+ @ Order (5 )
437
+ @ DisplayName ("Delete SystemResources from the domain" )
438
+ void testMiiDeleteSystemResourcesByEmptyConfigMap () {
439
+
440
+ String configMapName = "deletesysrescm" ;
441
+ createConfigMapAndVerify (
442
+ configMapName , domainUid , domainNamespace ,
443
+ Arrays .asList (MODEL_DIR + "/model.delete.sysresourcesbyconfigmap.yaml" ));
444
+
445
+ LinkedHashMap <String , OffsetDateTime > pods = new LinkedHashMap <>();
446
+ // get the creation time of the admin server pod before patching
447
+ OffsetDateTime adminPodCreationTime = getPodCreationTime (domainNamespace ,adminServerPodName );
448
+ pods .put (adminServerPodName , adminPodCreationTime );
449
+ // get the creation time of the managed server pods before patching
450
+ for (int i = 1 ; i <= replicaCount ; i ++) {
451
+ pods .put (managedServerPrefix + i , getPodCreationTime (domainNamespace , managedServerPrefix + i ));
452
+ }
453
+
454
+ StringBuffer patchStr = null ;
455
+ patchStr = new StringBuffer ("[{" );
456
+ patchStr .append ("\" op\" : \" replace\" ," )
457
+ .append (" \" path\" : \" /spec/configuration/model/configMap\" ," )
458
+ .append (" \" value\" : \" " + configMapName + "\" " )
459
+ .append (" }]" );
460
+ logger .log (Level .INFO , "Configmap patch string: {0}" , patchStr );
461
+
462
+ patch = new V1Patch (new String (patchStr ));
463
+ boolean cmPatched = assertDoesNotThrow (() ->
464
+ patchDomainCustomResource (domainUid , domainNamespace , patch , "application/json-patch+json" ),
465
+ "patchDomainCustomResource(configMap) failed " );
466
+ assertTrue (cmPatched , "patchDomainCustomResource(configMap) failed" );
467
+
468
+ String newRestartVersion = patchDomainResourceWithNewRestartVersion (domainUid , domainNamespace );
469
+ logger .log (Level .INFO , "New restart version is {0}" , newRestartVersion );
470
+
471
+ assertTrue (verifyRollingRestartOccurred (pods , 1 , domainNamespace ),
472
+ "Rolling restart failed" );
473
+
474
+ // Even if pods are created, need the service to created
475
+ for (int i = 1 ; i <= replicaCount ; i ++) {
476
+ logger .info ("Check managed server service {0} created in namespace {1}" ,
477
+ managedServerPrefix + i , domainNamespace );
478
+ checkServiceExists (managedServerPrefix + i , domainNamespace );
479
+ }
480
+
481
+ if (OKE_CLUSTER || OCNE ) {
482
+ String resourcePath = "/management/weblogic/latest/domainConfig/JDBCSystemResources/TestDataSource" ;
483
+ ExecResult result = exeAppInServerPod (domainNamespace , adminServerPodName , 7001 , resourcePath );
484
+ assertEquals (0 , result .exitValue (), "Failed to delete the JDBCSystemResource configuration" );
485
+ assertTrue (result .toString ().contains ("404" ), "Failed to delete the JDBCSystemResource configuration" );
486
+ logger .info ("The JDBCSystemResource configuration is deleted" );
487
+
488
+ resourcePath = "/management/weblogic/latest/domainConfig/JMSSystemResources/TestClusterJmsModule" ;
489
+ result = exeAppInServerPod (domainNamespace , adminServerPodName , 7001 , resourcePath );
490
+ assertEquals (0 , result .exitValue (), "Failed to delete the JMSSystemResources configuration" );
491
+ assertTrue (result .toString ().contains ("404" ), "Failed to delete the JMSSystemResources configuration" );
492
+ logger .info ("The JMSSystemResource configuration is deleted" );
493
+ } else {
494
+ int adminServiceNodePort
495
+ = getServiceNodePort (domainNamespace , getExternalServicePodName (adminServerPodName ), "default" );
496
+ assertNotEquals (-1 , adminServiceNodePort , "admin server default node port is not valid" );
497
+ verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
498
+ "JDBCSystemResources" , "TestDataSource" , "404" , hostHeader );
499
+ verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
500
+ "JMSSystemResources" , "TestClusterJmsModule" , "404" , hostHeader );
501
+ }
502
+ }
503
+
427
504
/**
428
505
* Start a WebLogic domain using model-in-image.
429
506
* Create 1 configmap with 2 models files, one of them to add JMS/JDBC SystemResources
@@ -435,7 +512,7 @@ void testMiiCheckSystemResources() {
435
512
* Verify SystemResources are deleted from the domain.
436
513
*/
437
514
@ Test
438
- @ Order (5 )
515
+ @ Order (6 )
439
516
@ DisplayName ("Delete SystemResources from the domain" )
440
517
void testMiiDeleteSystemResources () {
441
518
@@ -516,7 +593,7 @@ void testMiiDeleteSystemResources() {
516
593
* Verify JMS Server logs are written on PV.
517
594
*/
518
595
@ Test
519
- @ Order (6 )
596
+ @ Order (7 )
520
597
@ DisplayName ("Add new JDBC/JMS SystemResources to the domain" )
521
598
void testMiiAddSystemResources () {
522
599
@@ -604,7 +681,7 @@ void testMiiAddSystemResources() {
604
681
* Verify servers from the new cluster are running.
605
682
*/
606
683
@ Test
607
- @ Order (7 )
684
+ @ Order (8 )
608
685
@ DisplayName ("Add a dynamic cluster to domain with non-zero replica count" )
609
686
void testMiiAddDynamicCluster () {
610
687
@@ -676,7 +753,7 @@ void testMiiAddDynamicCluster() {
676
753
* Check the validity of new credentials by accessing WebLogic RESTful Service
677
754
*/
678
755
@ Test
679
- @ Order (8 )
756
+ @ Order (9 )
680
757
@ DisplayName ("Change the WebLogic Admin credential of the domain" )
681
758
void testMiiUpdateWebLogicCredential () {
682
759
verifyUpdateWebLogicCredential (7001 , domainNamespace , domainUid , adminServerPodName ,
@@ -698,7 +775,7 @@ void testMiiUpdateWebLogicCredential() {
698
775
* Make sure JMS Connections and messages are distributed across 4 servers.
699
776
*/
700
777
@ Test
701
- @ Order (9 )
778
+ @ Order (10 )
702
779
@ DisplayName ("Test modification to Dynamic cluster size parameters" )
703
780
void testMiiUpdateDynamicClusterSize () {
704
781
@@ -714,7 +791,7 @@ void testMiiUpdateDynamicClusterSize() {
714
791
checkPodReadyAndServiceExists (managedServerPrefix + "4" , domainUid , domainNamespace );
715
792
checkPodReadyAndServiceExists (managedServerPrefix + "5" , domainUid , domainNamespace );
716
793
717
- // Make sure that we can scale down upto replica count 1
794
+ // Make sure that we can scale down replica count to 1
718
795
// since the MinDynamicClusterSize is set to 1
719
796
logger .info ("[Before Patching] updating the replica count to 1" );
720
797
boolean p11Success = scaleCluster (domainUid + "-cluster-1" , domainNamespace , 1 );
@@ -814,112 +891,6 @@ void testMiiUpdateDynamicClusterSize() {
814
891
logger .info ("New Dynamic Cluster Size attribute verified" );
815
892
}
816
893
817
- // Build JMS Client inside the Admin Server Pod
818
- private void buildClientOnPod () {
819
-
820
- String destLocation = "/u01/JmsTestClient.java" ;
821
- assertDoesNotThrow (() -> copyFileToPod (domainNamespace ,
822
- adminServerPodName , "" ,
823
- Paths .get (RESOURCE_DIR , "tunneling" , "JmsTestClient.java" ),
824
- Paths .get (destLocation )));
825
-
826
- String jarLocation = "/u01/oracle/wlserver/server/lib/weblogic.jar" ;
827
-
828
- StringBuffer javacCmd = new StringBuffer (KUBERNETES_CLI + " exec -n " );
829
- javacCmd .append (domainNamespace );
830
- javacCmd .append (" -it " );
831
- javacCmd .append (adminServerPodName );
832
- javacCmd .append (" -- /bin/bash -c \" " );
833
- javacCmd .append ("javac -cp " );
834
- javacCmd .append (jarLocation );
835
- javacCmd .append (" /u01/JmsTestClient.java " );
836
- javacCmd .append (" \" " );
837
- logger .info ("javac command {0}" , javacCmd .toString ());
838
- ExecResult result = assertDoesNotThrow (
839
- () -> exec (new String (javacCmd ), true ));
840
- logger .info ("javac returned {0}" , result .toString ());
841
- logger .info ("javac returned EXIT value {0}" , result .exitValue ());
842
- assertEquals (0 , result .exitValue (), "Client compilation fails" );
843
- }
844
-
845
- /**
846
- * Start a WebLogic domain using model-in-image with JMS/JDBC SystemResources.
847
- * Create a empty configmap to delete JMS/JDBC SystemResources
848
- * Patch the domain resource with the configmap.
849
- * Update the restart version of the domain resource.
850
- * Verify rolling restart of the domain by comparing PodCreationTimestamp
851
- * for all the server pods before and after rolling restart.
852
- * Verify SystemResources are deleted from the domain.
853
- */
854
- @ Test
855
- @ Order (4 )
856
- @ DisplayName ("Delete SystemResources from the domain" )
857
- void testMiiDeleteSystemResourcesByEmptyConfigMap () {
858
-
859
- String configMapName = "deletesysrescm" ;
860
- createConfigMapAndVerify (
861
- configMapName , domainUid , domainNamespace ,
862
- Arrays .asList (MODEL_DIR + "/model.delete.sysresourcesbyconfigmap.yaml" ));
863
-
864
- LinkedHashMap <String , OffsetDateTime > pods = new LinkedHashMap <>();
865
- // get the creation time of the admin server pod before patching
866
- OffsetDateTime adminPodCreationTime = getPodCreationTime (domainNamespace ,adminServerPodName );
867
- pods .put (adminServerPodName , adminPodCreationTime );
868
- // get the creation time of the managed server pods before patching
869
- for (int i = 1 ; i <= replicaCount ; i ++) {
870
- pods .put (managedServerPrefix + i , getPodCreationTime (domainNamespace , managedServerPrefix + i ));
871
- }
872
-
873
- StringBuffer patchStr = null ;
874
- patchStr = new StringBuffer ("[{" );
875
- patchStr .append ("\" op\" : \" replace\" ," )
876
- .append (" \" path\" : \" /spec/configuration/model/configMap\" ," )
877
- .append (" \" value\" : \" " + configMapName + "\" " )
878
- .append (" }]" );
879
- logger .log (Level .INFO , "Configmap patch string: {0}" , patchStr );
880
-
881
- patch = new V1Patch (new String (patchStr ));
882
- boolean cmPatched = assertDoesNotThrow (() ->
883
- patchDomainCustomResource (domainUid , domainNamespace , patch , "application/json-patch+json" ),
884
- "patchDomainCustomResource(configMap) failed " );
885
- assertTrue (cmPatched , "patchDomainCustomResource(configMap) failed" );
886
-
887
- String newRestartVersion = patchDomainResourceWithNewRestartVersion (domainUid , domainNamespace );
888
- logger .log (Level .INFO , "New restart version is {0}" , newRestartVersion );
889
-
890
- assertTrue (verifyRollingRestartOccurred (pods , 1 , domainNamespace ),
891
- "Rolling restart failed" );
892
-
893
- // Even if pods are created, need the service to created
894
- for (int i = 1 ; i <= replicaCount ; i ++) {
895
- logger .info ("Check managed server service {0} created in namespace {1}" ,
896
- managedServerPrefix + i , domainNamespace );
897
- checkServiceExists (managedServerPrefix + i , domainNamespace );
898
- }
899
-
900
- if (OKE_CLUSTER || OCNE ) {
901
- String resourcePath = "/management/weblogic/latest/domainConfig/JDBCSystemResources/TestDataSource" ;
902
- ExecResult result = exeAppInServerPod (domainNamespace , adminServerPodName , 7001 , resourcePath );
903
- assertEquals (0 , result .exitValue (), "Failed to delete the JDBCSystemResource configuration" );
904
- assertTrue (result .toString ().contains ("404" ), "Failed to delete the JDBCSystemResource configuration" );
905
- logger .info ("The JDBCSystemResource configuration is deleted" );
906
-
907
- resourcePath = "/management/weblogic/latest/domainConfig/JMSSystemResources/TestClusterJmsModule" ;
908
- result = exeAppInServerPod (domainNamespace , adminServerPodName , 7001 , resourcePath );
909
- assertEquals (0 , result .exitValue (), "Failed to delete the JMSSystemResources configuration" );
910
- assertTrue (result .toString ().contains ("404" ), "Failed to delete the JMSSystemResources configuration" );
911
- logger .info ("The JMSSystemResource configuration is deleted" );
912
- } else {
913
- int adminServiceNodePort
914
- = getServiceNodePort (domainNamespace , getExternalServicePodName (adminServerPodName ), "default" );
915
- assertNotEquals (-1 , adminServiceNodePort , "admin server default node port is not valid" );
916
- verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
917
- "JDBCSystemResources" , "TestDataSource" , "404" , hostHeader );
918
- verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
919
- "JMSSystemResources" , "TestClusterJmsModule" , "404" , hostHeader );
920
- }
921
- }
922
-
923
894
// Run standalone JMS Client in the pod using wlthint3client.jar in classpath.
924
895
// The client sends 300 messsage to a Uniform Distributed Queue.
925
896
// Make sure that each destination get excatly 150 messages each.
@@ -933,7 +904,6 @@ private static Callable<Boolean> runJmsClient(String javaCmd) {
933
904
});
934
905
}
935
906
936
-
937
907
private static void createDatabaseSecret (
938
908
String secretName , String username , String password ,
939
909
String dburl , String domNamespace ) {
@@ -1112,7 +1082,6 @@ private void verifyJdbcRuntime(String resourcesName, String expectedOutput) {
1112
1082
headers = " -H 'host: " + hostHeader + "' " ;
1113
1083
}
1114
1084
1115
- ExecResult result = null ;
1116
1085
curlString = new StringBuffer ("curl -g --user " )
1117
1086
.append (ADMIN_USERNAME_DEFAULT )
1118
1087
.append (":" )
@@ -1150,4 +1119,32 @@ private void checkLogsOnPV(String commandToExecuteInsidePod, String podName) {
1150
1119
String .format ("Command %s failed with exit value %s, stderr %s, stdout %s" ,
1151
1120
commandToExecuteInsidePod , result .exitValue (), result .stderr (), result .stdout ()));
1152
1121
}
1122
+
1123
+ // Build JMS Client inside the Admin Server Pod
1124
+ private void buildClientOnPod () {
1125
+
1126
+ String destLocation = "/u01/JmsTestClient.java" ;
1127
+ assertDoesNotThrow (() -> copyFileToPod (domainNamespace ,
1128
+ adminServerPodName , "" ,
1129
+ Paths .get (RESOURCE_DIR , "tunneling" , "JmsTestClient.java" ),
1130
+ Paths .get (destLocation )));
1131
+
1132
+ String jarLocation = "/u01/oracle/wlserver/server/lib/weblogic.jar" ;
1133
+
1134
+ StringBuffer javacCmd = new StringBuffer (KUBERNETES_CLI + " exec -n " );
1135
+ javacCmd .append (domainNamespace );
1136
+ javacCmd .append (" -it " );
1137
+ javacCmd .append (adminServerPodName );
1138
+ javacCmd .append (" -- /bin/bash -c \" " );
1139
+ javacCmd .append ("javac -cp " );
1140
+ javacCmd .append (jarLocation );
1141
+ javacCmd .append (" /u01/JmsTestClient.java " );
1142
+ javacCmd .append (" \" " );
1143
+ logger .info ("javac command {0}" , javacCmd .toString ());
1144
+ ExecResult result = assertDoesNotThrow (
1145
+ () -> exec (new String (javacCmd ), true ));
1146
+ logger .info ("javac returned {0}" , result .toString ());
1147
+ logger .info ("javac returned EXIT value {0}" , result .exitValue ());
1148
+ assertEquals (0 , result .exitValue (), "Client compilation fails" );
1149
+ }
1153
1150
}
0 commit comments