1- // Copyright (c) 2020, 2021 , Oracle and/or its affiliates.
1+ // Copyright (c) 2020, 2022 , Oracle and/or its affiliates.
22// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33
44package oracle .weblogic .kubernetes ;
3030import oracle .weblogic .domain .DomainSpec ;
3131import oracle .weblogic .domain .Istio ;
3232import oracle .weblogic .domain .ServerPod ;
33+ import oracle .weblogic .kubernetes .actions .impl .primitive .Kubernetes ;
3334import oracle .weblogic .kubernetes .annotations .IntegrationTest ;
3435import oracle .weblogic .kubernetes .annotations .Namespaces ;
3536import oracle .weblogic .kubernetes .logging .LoggingFacade ;
4647import static oracle .weblogic .kubernetes .TestConstants .BASE_IMAGES_REPO_SECRET_NAME ;
4748import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_API_VERSION ;
4849import static oracle .weblogic .kubernetes .TestConstants .K8S_NODEPORT_HOST ;
50+ import static oracle .weblogic .kubernetes .TestConstants .KIND_REPO ;
51+ import static oracle .weblogic .kubernetes .TestConstants .LOCALE_IMAGE_NAME ;
52+ import static oracle .weblogic .kubernetes .TestConstants .LOCALE_IMAGE_TAG ;
4953import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_IMAGE_TO_USE_IN_SPEC ;
5054import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_SLIM ;
5155import static oracle .weblogic .kubernetes .actions .ActionConstants .ITTESTS_DIR ;
5256import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
5357import static oracle .weblogic .kubernetes .actions .TestActions .addLabelsToNamespace ;
5458import static oracle .weblogic .kubernetes .actions .TestActions .scaleCluster ;
5559import static oracle .weblogic .kubernetes .utils .ApplicationUtils .checkAppUsingHostHeader ;
60+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodReadyAndServiceExists ;
5661import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkServiceExists ;
5762import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getNextFreePort ;
5863import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getUniqueName ;
64+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .withLongRetryPolicy ;
5965import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .createConfigMapForDomainCreation ;
6066import static oracle .weblogic .kubernetes .utils .DeployUtil .deployToClusterUsingRest ;
6167import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
@@ -92,9 +98,9 @@ class ItIstioDomainInPV {
9298 private static String domainNamespace = null ;
9399
94100 private final String wlSecretName = "weblogic-credentials" ;
95- private final String domainUid = "istio-div " ;
101+ private final String domainUid = "istio-dpv " ;
96102 private final String clusterName = "cluster-1" ;
97- private final String adminServerName = "admin-server " ;
103+ private final String adminServerName = "adminserver " ;
98104 private final String adminServerPodName = domainUid + "-" + adminServerName ;
99105 private static LoggingFacade logger = null ;
100106
@@ -137,9 +143,11 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
137143
138144 /**
139145 * Create a WebLogic domain using WLST in a persistent volume.
146+ * Use WebLogic (12.2.1.4) base image with Japanese Locale.
140147 * Add istio configuration.
141148 * Deploy istio gateways and virtual service.
142149 * Verify domain pods runs in ready state and services are created.
150+ * Check WebLogic Server log for few Japanese characters.
143151 * Verify login to WebLogic console is successful thru istio ingress Port.
144152 * Additionally, the test verifies that WebLogic cluster can be scaled down
145153 * and scaled up in the absence of Administration server.
@@ -148,8 +156,8 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
148156 @ DisplayName ("Create WebLogic domain in PV with Istio" )
149157 void testIstioDomainHomeInPv () {
150158
151- final String managedServerNameBase = "wlst-ms -" ;
152- String managedServerPodNamePrefix = domainUid + "-" + managedServerNameBase ;
159+ final String managedServerNameBase = "managed -" ;
160+ String managedServerPrefix = domainUid + "-" + managedServerNameBase ;
153161 final int replicaCount = 2 ;
154162 final int t3ChannelPort = getNextFreePort ();
155163
@@ -200,9 +208,18 @@ void testIstioDomainHomeInPv() {
200208 createDomainOnPVUsingWlst (wlstScript , domainPropertiesFile .toPath (),
201209 pvName , pvcName , domainNamespace );
202210
211+ // Use the WebLogic(12.2.1.4) Base Image with Japanese Locale
212+ String imageLocation = null ;
213+ if (KIND_REPO != null ) {
214+ imageLocation = KIND_REPO + "weblogick8s/test-images/weblogic:" + LOCALE_IMAGE_TAG ;
215+ } else {
216+ imageLocation = LOCALE_IMAGE_NAME + ":" + LOCALE_IMAGE_TAG ;
217+ }
218+
203219 // Enable istio in domain custom resource configuration object.
204220 // Add T3Channel Service with port assigned to Istio TCP ingress port.
205221 logger .info ("Creating domain custom resource" );
222+
206223 Domain domain = new Domain ()
207224 .apiVersion (DOMAIN_API_VERSION )
208225 .kind ("Domain" )
@@ -213,7 +230,7 @@ void testIstioDomainHomeInPv() {
213230 .domainUid (domainUid )
214231 .domainHome ("/shared/domains/" + domainUid )
215232 .domainHomeSourceType ("PersistentVolume" )
216- .image (WEBLOGIC_IMAGE_TO_USE_IN_SPEC )
233+ .image (imageLocation )
217234 .imagePullPolicy ("IfNotPresent" )
218235 .imagePullSecrets (Arrays .asList (
219236 new V1LocalObjectReference ()
@@ -227,6 +244,9 @@ void testIstioDomainHomeInPv() {
227244 .dataHome ("" )
228245 .serverStartPolicy ("IF_NEEDED" )
229246 .serverPod (new ServerPod () //serverpod
247+ .addEnvItem (new V1EnvVar ()
248+ .name ("LANG" )
249+ .value ("ja_JP.utf8" ))
230250 .addEnvItem (new V1EnvVar ()
231251 .name ("JAVA_OPTIONS" )
232252 .value ("-Dweblogic.StdoutDebugEnabled=false" ))
@@ -258,25 +278,19 @@ void testIstioDomainHomeInPv() {
258278 // verify the domain custom resource is created
259279 createDomainAndVerify (domain , domainNamespace );
260280
261- // verify the admin server service created
262- checkServiceExists (adminServerPodName , domainNamespace );
263-
264281 // verify admin server pod is ready
265- checkPodReady (adminServerPodName , domainUid , domainNamespace );
266-
282+ logger .info ("Wait for admin server pod {0} to be ready in namespace {1}" ,
283+ adminServerPodName , domainNamespace );
284+ checkPodReadyAndServiceExists (adminServerPodName , domainUid , domainNamespace );
267285 // verify managed server services created
268286 for (int i = 1 ; i <= replicaCount ; i ++) {
269- logger .info ("Checking managed service {0} is created in namespace {1}" ,
270- managedServerPodNamePrefix + i , domainNamespace );
271- checkServiceExists (managedServerPodNamePrefix + i , domainNamespace );
272- }
273-
274- // verify managed server pods are ready
275- for (int i = 1 ; i <= replicaCount ; i ++) {
276- logger .info ("Waiting for managed pod {0} to be ready in namespace {1}" ,
277- managedServerPodNamePrefix + i , domainNamespace );
278- checkPodReady (managedServerPodNamePrefix + i , domainUid , domainNamespace );
287+ logger .info ("Check managed service {0} is created in namespace {1}" ,
288+ managedServerPrefix + i , domainNamespace );
289+ checkPodReadyAndServiceExists (withLongRetryPolicy , managedServerPrefix + i , domainUid , domainNamespace );
279290 }
291+
292+ // Make sure Japanese character is found in server pod log
293+ assertTrue (matchPodLog (),"LANG is not set to ja_JP.utf8" );
280294
281295 String clusterService = domainUid + "-cluster-" + clusterName + "." + domainNamespace + ".svc.cluster.local" ;
282296
@@ -330,7 +344,6 @@ void testIstioDomainHomeInPv() {
330344 boolean checkApp = checkAppUsingHostHeader (url , domainNamespace + ".org" );
331345 assertTrue (checkApp , "Failed to access WebLogic application" );
332346
333- // Refer JIRA OWLS-86407
334347 // Stop and Start the managed server in absense of administration server
335348 assertTrue (patchServerStartPolicy (domainUid , domainNamespace ,
336349 "/spec/adminServer/serverStartPolicy" , "NEVER" ),
@@ -346,7 +359,7 @@ void testIstioDomainHomeInPv() {
346359 assertTrue (scalingSuccess ,
347360 String .format ("Cluster scaling failed for domain %s in namespace %s" , domainUid , domainNamespace ));
348361 logger .info ("Cluster is scaled down in absense of administration server" );
349- checkPodDeleted (managedServerPodNamePrefix + "2" , domainUid , domainNamespace );
362+ checkPodDeleted (managedServerPrefix + "2" , domainUid , domainNamespace );
350363 logger .info ("Managed Server stopped in absense of administration server" );
351364
352365 scalingSuccess = assertDoesNotThrow (() ->
@@ -356,11 +369,33 @@ void testIstioDomainHomeInPv() {
356369 assertTrue (scalingSuccess ,
357370 String .format ("Cluster scaling failed for domain %s in namespace %s" , domainUid , domainNamespace ));
358371 logger .info ("Cluster is scaled up in absense of administration server" );
359- checkServiceExists (managedServerPodNamePrefix + "2" , domainNamespace );
360- checkPodReady (managedServerPodNamePrefix + "2" , domainUid , domainNamespace );
372+ checkServiceExists (managedServerPrefix + "2" , domainNamespace );
373+ checkPodReady (managedServerPrefix + "2" , domainUid , domainNamespace );
361374 logger .info ("Managed Server started in absense of administration server" );
362375 }
363376
377+ // Looks for some Japanese Character in Server Pod Logs
378+ private boolean matchPodLog () {
379+ String toMatch = "起動しました" ;
380+ // toMatch = "起起起モードで起動しました"; test fails
381+ String podLog = null ;
382+ try {
383+ podLog = Kubernetes .getPodLog ("istio-dpv-managed-1" , domainNamespace , "weblogic-server" );
384+ logger .info ("{0}" , podLog );
385+ logger .info ("Looking for string [{0}] in Pod log" , toMatch );
386+ if (podLog .contains (toMatch )) {
387+ logger .info ("Found the string [{0}] in Pod log" , toMatch );
388+ return true ;
389+ } else {
390+ logger .info ("Matching string [{0}] Not found in Pod log" , toMatch );
391+ return false ;
392+ }
393+ } catch (Exception e ) {
394+ e .printStackTrace ();
395+ return false ;
396+ }
397+ }
398+
364399 /**
365400 * Create a WebLogic domain on a persistent volume by doing the following.
366401 * Create a configmap containing WLST script and property file.
0 commit comments