1
- // Copyright (c) 2020, 2021 , Oracle and/or its affiliates.
1
+ // Copyright (c) 2020, 2022 , 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 ;
30
30
import oracle .weblogic .domain .DomainSpec ;
31
31
import oracle .weblogic .domain .Istio ;
32
32
import oracle .weblogic .domain .ServerPod ;
33
+ import oracle .weblogic .kubernetes .actions .impl .primitive .Kubernetes ;
33
34
import oracle .weblogic .kubernetes .annotations .IntegrationTest ;
34
35
import oracle .weblogic .kubernetes .annotations .Namespaces ;
35
36
import oracle .weblogic .kubernetes .logging .LoggingFacade ;
46
47
import static oracle .weblogic .kubernetes .TestConstants .BASE_IMAGES_REPO_SECRET_NAME ;
47
48
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_API_VERSION ;
48
49
import 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 ;
49
53
import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_IMAGE_TO_USE_IN_SPEC ;
50
54
import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_SLIM ;
51
55
import static oracle .weblogic .kubernetes .actions .ActionConstants .ITTESTS_DIR ;
52
56
import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
53
57
import static oracle .weblogic .kubernetes .actions .TestActions .addLabelsToNamespace ;
54
58
import static oracle .weblogic .kubernetes .actions .TestActions .scaleCluster ;
55
59
import static oracle .weblogic .kubernetes .utils .ApplicationUtils .checkAppUsingHostHeader ;
60
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodReadyAndServiceExists ;
56
61
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkServiceExists ;
57
62
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getNextFreePort ;
58
63
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getUniqueName ;
64
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .withLongRetryPolicy ;
59
65
import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .createConfigMapForDomainCreation ;
60
66
import static oracle .weblogic .kubernetes .utils .DeployUtil .deployToClusterUsingRest ;
61
67
import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
@@ -92,9 +98,9 @@ class ItIstioDomainInPV {
92
98
private static String domainNamespace = null ;
93
99
94
100
private final String wlSecretName = "weblogic-credentials" ;
95
- private final String domainUid = "istio-div " ;
101
+ private final String domainUid = "istio-dpv " ;
96
102
private final String clusterName = "cluster-1" ;
97
- private final String adminServerName = "admin-server " ;
103
+ private final String adminServerName = "adminserver " ;
98
104
private final String adminServerPodName = domainUid + "-" + adminServerName ;
99
105
private static LoggingFacade logger = null ;
100
106
@@ -137,9 +143,11 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
137
143
138
144
/**
139
145
* Create a WebLogic domain using WLST in a persistent volume.
146
+ * Use WebLogic (12.2.1.4) base image with Japanese Locale.
140
147
* Add istio configuration.
141
148
* Deploy istio gateways and virtual service.
142
149
* Verify domain pods runs in ready state and services are created.
150
+ * Check WebLogic Server log for few Japanese characters.
143
151
* Verify login to WebLogic console is successful thru istio ingress Port.
144
152
* Additionally, the test verifies that WebLogic cluster can be scaled down
145
153
* and scaled up in the absence of Administration server.
@@ -148,8 +156,8 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
148
156
@ DisplayName ("Create WebLogic domain in PV with Istio" )
149
157
void testIstioDomainHomeInPv () {
150
158
151
- final String managedServerNameBase = "wlst-ms -" ;
152
- String managedServerPodNamePrefix = domainUid + "-" + managedServerNameBase ;
159
+ final String managedServerNameBase = "managed -" ;
160
+ String managedServerPrefix = domainUid + "-" + managedServerNameBase ;
153
161
final int replicaCount = 2 ;
154
162
final int t3ChannelPort = getNextFreePort ();
155
163
@@ -200,9 +208,18 @@ void testIstioDomainHomeInPv() {
200
208
createDomainOnPVUsingWlst (wlstScript , domainPropertiesFile .toPath (),
201
209
pvName , pvcName , domainNamespace );
202
210
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
+
203
219
// Enable istio in domain custom resource configuration object.
204
220
// Add T3Channel Service with port assigned to Istio TCP ingress port.
205
221
logger .info ("Creating domain custom resource" );
222
+
206
223
Domain domain = new Domain ()
207
224
.apiVersion (DOMAIN_API_VERSION )
208
225
.kind ("Domain" )
@@ -213,7 +230,7 @@ void testIstioDomainHomeInPv() {
213
230
.domainUid (domainUid )
214
231
.domainHome ("/shared/domains/" + domainUid )
215
232
.domainHomeSourceType ("PersistentVolume" )
216
- .image (WEBLOGIC_IMAGE_TO_USE_IN_SPEC )
233
+ .image (imageLocation )
217
234
.imagePullPolicy ("IfNotPresent" )
218
235
.imagePullSecrets (Arrays .asList (
219
236
new V1LocalObjectReference ()
@@ -227,6 +244,9 @@ void testIstioDomainHomeInPv() {
227
244
.dataHome ("" )
228
245
.serverStartPolicy ("IF_NEEDED" )
229
246
.serverPod (new ServerPod () //serverpod
247
+ .addEnvItem (new V1EnvVar ()
248
+ .name ("LANG" )
249
+ .value ("ja_JP.utf8" ))
230
250
.addEnvItem (new V1EnvVar ()
231
251
.name ("JAVA_OPTIONS" )
232
252
.value ("-Dweblogic.StdoutDebugEnabled=false" ))
@@ -258,25 +278,19 @@ void testIstioDomainHomeInPv() {
258
278
// verify the domain custom resource is created
259
279
createDomainAndVerify (domain , domainNamespace );
260
280
261
- // verify the admin server service created
262
- checkServiceExists (adminServerPodName , domainNamespace );
263
-
264
281
// 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 );
267
285
// verify managed server services created
268
286
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 );
279
290
}
291
+
292
+ // Make sure Japanese character is found in server pod log
293
+ assertTrue (matchPodLog (),"LANG is not set to ja_JP.utf8" );
280
294
281
295
String clusterService = domainUid + "-cluster-" + clusterName + "." + domainNamespace + ".svc.cluster.local" ;
282
296
@@ -330,7 +344,6 @@ void testIstioDomainHomeInPv() {
330
344
boolean checkApp = checkAppUsingHostHeader (url , domainNamespace + ".org" );
331
345
assertTrue (checkApp , "Failed to access WebLogic application" );
332
346
333
- // Refer JIRA OWLS-86407
334
347
// Stop and Start the managed server in absense of administration server
335
348
assertTrue (patchServerStartPolicy (domainUid , domainNamespace ,
336
349
"/spec/adminServer/serverStartPolicy" , "NEVER" ),
@@ -346,7 +359,7 @@ void testIstioDomainHomeInPv() {
346
359
assertTrue (scalingSuccess ,
347
360
String .format ("Cluster scaling failed for domain %s in namespace %s" , domainUid , domainNamespace ));
348
361
logger .info ("Cluster is scaled down in absense of administration server" );
349
- checkPodDeleted (managedServerPodNamePrefix + "2" , domainUid , domainNamespace );
362
+ checkPodDeleted (managedServerPrefix + "2" , domainUid , domainNamespace );
350
363
logger .info ("Managed Server stopped in absense of administration server" );
351
364
352
365
scalingSuccess = assertDoesNotThrow (() ->
@@ -356,11 +369,33 @@ void testIstioDomainHomeInPv() {
356
369
assertTrue (scalingSuccess ,
357
370
String .format ("Cluster scaling failed for domain %s in namespace %s" , domainUid , domainNamespace ));
358
371
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 );
361
374
logger .info ("Managed Server started in absense of administration server" );
362
375
}
363
376
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
+
364
399
/**
365
400
* Create a WebLogic domain on a persistent volume by doing the following.
366
401
* Create a configmap containing WLST script and property file.
0 commit comments