74
74
import static oracle .weblogic .kubernetes .actions .TestActions .createDomainCustomResource ;
75
75
import static oracle .weblogic .kubernetes .actions .TestActions .createSecret ;
76
76
import static oracle .weblogic .kubernetes .actions .TestActions .execCommand ;
77
+ import static oracle .weblogic .kubernetes .actions .TestActions .getDomainCustomResource ;
77
78
import static oracle .weblogic .kubernetes .actions .TestActions .getJob ;
78
79
import static oracle .weblogic .kubernetes .actions .TestActions .getPodLog ;
79
80
import static oracle .weblogic .kubernetes .actions .TestActions .getServiceNodePort ;
@@ -191,7 +192,7 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
191
192
logger .info ("Create database secret" );
192
193
final String dbSecretName = domainUid + "-db-secret" ;
193
194
assertDoesNotThrow (() -> createDatabaseSecret (dbSecretName , "scott" ,
194
- "tiger " , "jdbc:oracle:thin:localhost:/ORCLCDB" , domainNamespace ),
195
+ "##W%*}! \" ' \" `'] \\ \\ //1$$~x " , "jdbc:oracle:thin:localhost:/ORCLCDB" , domainNamespace ),
195
196
String .format ("createSecret failed for %s" , dbSecretName ));
196
197
String configMapName = "jdbc-jms-wldf-configmap" ;
197
198
@@ -248,15 +249,62 @@ public void beforeEach() {
248
249
}
249
250
}
250
251
252
+ /**
253
+ * Check the environment variable with special characters.
254
+ */
255
+ @ Test
256
+ @ Order (0 )
257
+ @ DisplayName ("Check environment variable with special characters" )
258
+ public void testMiiCustomEnv () {
259
+ Domain domain1 = assertDoesNotThrow (() -> getDomainCustomResource (domainUid , domainNamespace ),
260
+ String .format ("getDomainCustomResource failed with ApiException when tried to get domain %s in namespace %s" ,
261
+ domainUid , domainNamespace ));
262
+ List <V1EnvVar > envList = domain1 .getSpec ().getServerPod ().getEnv ();
263
+
264
+ boolean found = false ;
265
+ for (int i = 0 ; i < envList .size (); i ++) {
266
+ logger .info ("The name is: {0}, value is: {1}" , envList .get (i ).getName (), envList .get (i ).getValue ());
267
+ if (envList .get (i ).getName ().equalsIgnoreCase ("CUSTOM_ENV" )) {
268
+ assertTrue (
269
+ envList .get (i ).getValue ().equalsIgnoreCase ("${DOMAIN_UID}~##!'%*$(ls)" ),
270
+ "Expected value for CUSTOM_ENV variable does not mtach" );
271
+ found = true ;
272
+ }
273
+ }
274
+ assertTrue (found , "Couldn't find CUSTOM_ENV variable in domain resource" );
275
+
276
+ int adminServiceNodePort
277
+ = getServiceNodePort (domainNamespace , getExternalServicePodName (adminServerPodName ), "default" );
278
+ StringBuffer curlString = new StringBuffer ("curl --user weblogic:welcome1 " );
279
+ curlString .append ("\" http://" + K8S_NODEPORT_HOST + ":" + adminServiceNodePort )
280
+ .append ("/management/weblogic/latest/domainConfig" )
281
+ .append ("/JMSServers/TestClusterJmsServer" )
282
+ .append ("?fields=notes&links=none\" " )
283
+ .append (" --silent " );
284
+ logger .info ("checkJmsServerConfig: curl command {0}" , new String (curlString ));
285
+ ExecResult result = null ;
286
+ try {
287
+ result = exec (new String (curlString ), true );
288
+ getLogger ().info ("The command returned exit value: "
289
+ + result .exitValue () + " command output: "
290
+ + result .stderr () + "\n " + result .stdout ());
291
+ assertTrue ((result .exitValue () == 0 ),
292
+ "curl command returned non zero value" );
293
+ assertTrue ((result .stdout ().contains ("${DOMAIN_UID}~##!'%*$(ls)" )),
294
+ "Custom environment variable is not reflected in domin config" );
295
+ } catch (Exception e ) {
296
+ getLogger ().info ("Got exception, command failed with errors " + e .getMessage ());
297
+ }
298
+ }
299
+
251
300
/**
252
301
* Check server logs are written on PersistentVolume(PV).
253
- * The test looks for the string RUNNING in server log
302
+ * The test looks for the string RUNNING in the server log
254
303
*/
255
304
@ Test
256
305
@ Order (1 )
257
306
@ DisplayName ("Check the server logs are written to PersistentVolume" )
258
307
public void testMiiServerLogsAreOnPV () {
259
-
260
308
// check server logs are written on PV and look for string RUNNING in log
261
309
checkLogsOnPV ("grep RUNNING /shared/logs/" + adminServerName + ".log" , adminServerPodName );
262
310
}
@@ -296,12 +344,12 @@ public void testMiiHttpServerLogsAreOnPV() {
296
344
}
297
345
298
346
/**
299
- * Create a WebLogic domain with a defined configmap in configuration/model
300
- * section of the domain resource.
347
+ * Create a WebLogic domain with a defined configmap in the
348
+ * configuration/model section of the domain resource.
301
349
* The configmap has multiple sparse WDT model files that define
302
350
* a JDBCSystemResource, a JMSSystemResource and a WLDFSystemResource.
303
351
* Verify all the SystemResource configurations using the rest API call
304
- * using the public nodeport of the administration server.
352
+ * using the public node port of the administration server.
305
353
*/
306
354
@ Test
307
355
@ Order (3 )
@@ -475,15 +523,15 @@ public void testMiiAddSystemResources() {
475
523
* Update the restart version of the domain resource.
476
524
* Verify rolling restart of the domain by comparing PodCreationTimestamp
477
525
* before and after rolling restart.
478
- * Verify servers from new cluster are not in running state, because
526
+ * Verify servers from the new cluster are not in running state, because
479
527
* the spec level replica count to zero(default).
480
528
*/
481
529
@ Test
482
530
@ Order (6 )
483
531
@ DisplayName ("Add a dynamic cluster to the domain with default replica count" )
484
532
public void testMiiAddDynmicClusteriWithNoReplica () {
485
533
486
- // This test uses the WebLogic domain created in BeforeAll method
534
+ // This test uses the WebLogic domain created in the BeforeAll method
487
535
// BeforeEach method ensures that the server pods are running
488
536
489
537
String configMapName = "noreplicaconfigmap" ;
@@ -518,8 +566,8 @@ public void testMiiAddDynmicClusteriWithNoReplica() {
518
566
assertTrue (verifyRollingRestartOccurred (pods , 1 , domainNamespace ),
519
567
"Rolling restart failed" );
520
568
521
- // The ServerNamePrefix for the new configured cluster is config-server
522
- // Make sure the managed server from new cluster is not running
569
+ // The ServerNamePrefix for the newly configured cluster is config-server
570
+ // Make sure the managed server from the new cluster is not running
523
571
524
572
String newServerPodName = domainUid + "-config-server1" ;
525
573
checkPodNotCreated (newServerPodName , domainUid , domainNamespace );
@@ -536,14 +584,14 @@ public void testMiiAddDynmicClusteriWithNoReplica() {
536
584
* Update the restart version of the domain resource.
537
585
* Verify rolling restart of the domain by comparing PodCreationTimestamp
538
586
* before and after rolling restart.
539
- * Verify servers from new cluster are in running state .
587
+ * Verify servers from the new cluster are running.
540
588
*/
541
589
@ Test
542
590
@ Order (7 )
543
591
@ DisplayName ("Add a dynamic cluster to domain with non-zero replica count" )
544
592
public void testMiiAddDynamicCluster () {
545
593
546
- // This test uses the WebLogic domain created in BeforeAll method
594
+ // This test uses the WebLogic domain created in the BeforeAll method
547
595
// BeforeEach method ensures that the server pods are running
548
596
549
597
String configMapName = "dynamicclusterconfigmap" ;
@@ -613,14 +661,14 @@ public void testMiiAddDynamicCluster() {
613
661
* Update the restart version of the domain resource.
614
662
* Verify rolling restart of the domain by comparing PodCreationTimestamp
615
663
* before and after rolling restart.
616
- * Verify servers from new cluster are in running state .
664
+ * Verify servers from the new cluster are running.
617
665
*/
618
666
@ Test
619
667
@ Order (8 )
620
668
@ DisplayName ("Add a configured cluster to the domain" )
621
669
public void testMiiAddConfiguredCluster () {
622
670
623
- // This test uses the WebLogic domain created in BeforeAll method
671
+ // This test uses the WebLogic domain created in the BeforeAll method
624
672
// BeforeEach method ensures that the server pods are running
625
673
626
674
String configMapName = "configclusterconfigmap" ;
@@ -681,7 +729,7 @@ public void testMiiAddConfiguredCluster() {
681
729
}
682
730
683
731
/**
684
- * Start a WebLogic domain with model-in-imge .
732
+ * Start a WebLogic domain with model-in-image .
685
733
* Patch the domain CRD with a new credentials secret.
686
734
* Update domainRestartVersion to trigger a rolling restart of server pods.
687
735
* Make sure all the server pods are re-started in a rolling fashion.
@@ -749,10 +797,10 @@ public void testMiiUpdateWebLogicCredential() {
749
797
* Set allowReplicasBelowMinDynClusterSize to false.
750
798
* Make sure that the cluster can be scaled up to 5 servers and
751
799
* scaled down to 1 server.
752
- * Create a configmap with a sparse model file with following attributes for
800
+ * Create a configmap with a sparse model file with the following attributes
753
801
* Cluster/cluster-1/DynamicServers
754
802
* MaxDynamicClusterSize(4) and MinDynamicClusterSize(2)
755
- * Patch the domain resource with the configmap and update restartVersion.
803
+ * Patch the domain resource with the configmap and update the restartVersion.
756
804
* Make sure a rolling restart is triggered.
757
805
* Now with the modified value
758
806
* Make sure that the cluster can be scaled up to 4 servers.
@@ -970,6 +1018,8 @@ private static void createDomainSecret(String secretName, String username, Strin
970
1018
assertTrue (secretCreated , String .format ("create secret failed for %s in namespace %s" , secretName , domNamespace ));
971
1019
}
972
1020
1021
+ // Add an environmental variable with special character
1022
+ // Make sure the variable is available in domain resource with right value
973
1023
private static void createDomainResource (
974
1024
String domainUid , String domNamespace , String adminSecretName ,
975
1025
String repoSecretName , String encryptionSecretName ,
@@ -1004,6 +1054,9 @@ private static void createDomainResource(
1004
1054
.addEnvItem (new V1EnvVar ()
1005
1055
.name ("USER_MEM_ARGS" )
1006
1056
.value ("-Djava.security.egd=file:/dev/./urandom " ))
1057
+ .addEnvItem (new V1EnvVar ()
1058
+ .name ("CUSTOM_ENV" )
1059
+ .value ("${DOMAIN_UID}~##!'%*$(ls)" ))
1007
1060
.addVolumesItem (new V1Volume ()
1008
1061
.name (pvName )
1009
1062
.persistentVolumeClaim (new V1PersistentVolumeClaimVolumeSource ()
0 commit comments