Skip to content

Commit 54d42b2

Browse files
authored
Integration test for Japanese Locale (#3341)
* Integration test for Japanese Locale
1 parent 1bad77c commit 54d42b2

File tree

4 files changed

+97
-25
lines changed

4 files changed

+97
-25
lines changed

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItIstioDomainInPV.java

Lines changed: 60 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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

44
package oracle.weblogic.kubernetes;
@@ -30,6 +30,7 @@
3030
import oracle.weblogic.domain.DomainSpec;
3131
import oracle.weblogic.domain.Istio;
3232
import oracle.weblogic.domain.ServerPod;
33+
import oracle.weblogic.kubernetes.actions.impl.primitive.Kubernetes;
3334
import oracle.weblogic.kubernetes.annotations.IntegrationTest;
3435
import oracle.weblogic.kubernetes.annotations.Namespaces;
3536
import oracle.weblogic.kubernetes.logging.LoggingFacade;
@@ -46,16 +47,21 @@
4647
import static oracle.weblogic.kubernetes.TestConstants.BASE_IMAGES_REPO_SECRET_NAME;
4748
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_API_VERSION;
4849
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;
4953
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TO_USE_IN_SPEC;
5054
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_SLIM;
5155
import static oracle.weblogic.kubernetes.actions.ActionConstants.ITTESTS_DIR;
5256
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
5357
import static oracle.weblogic.kubernetes.actions.TestActions.addLabelsToNamespace;
5458
import static oracle.weblogic.kubernetes.actions.TestActions.scaleCluster;
5559
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.checkAppUsingHostHeader;
60+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
5661
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists;
5762
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
5863
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getUniqueName;
64+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withLongRetryPolicy;
5965
import static oracle.weblogic.kubernetes.utils.ConfigMapUtils.createConfigMapForDomainCreation;
6066
import static oracle.weblogic.kubernetes.utils.DeployUtil.deployToClusterUsingRest;
6167
import 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.

integration-tests/src/test/java/oracle/weblogic/kubernetes/TestConstants.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ public interface TestConstants {
116116
DB_IMAGE_NAME_DEFAULT);
117117
public static final String DB_IMAGE_TAG = getNonEmptySystemProperty("wko.it.db.image.tag", DB_IMAGE_TAG_DEFAULT);
118118

119+
// WebLogic Base Image with Japanease Locale
120+
public static final String LOCALE_IMAGE_NAME = "phx.ocir.io/weblogick8s/test-images/weblogic";
121+
public static final String LOCALE_IMAGE_TAG = "12.2.1.4-jp";
122+
119123
// For kind, replace repo name in image name with KIND_REPO, otherwise use the actual image name
120124
// For example, image container-registry.oracle.com/middleware/weblogic:12.2.1.4 will be pushed/used as
121125
// localhost:5000/middleware/weblogic:12.2.1.4 in kind and in non-kind cluster it will be used as is.

integration-tests/src/test/java/oracle/weblogic/kubernetes/extensions/ImageBuilders.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
import static oracle.weblogic.kubernetes.TestConstants.FMWINFRA_IMAGE_NAME;
4747
import static oracle.weblogic.kubernetes.TestConstants.FMWINFRA_IMAGE_TAG;
4848
import static oracle.weblogic.kubernetes.TestConstants.KIND_REPO;
49+
import static oracle.weblogic.kubernetes.TestConstants.LOCALE_IMAGE_NAME;
50+
import static oracle.weblogic.kubernetes.TestConstants.LOCALE_IMAGE_TAG;
4951
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_APP_NAME;
5052
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_DOMAINTYPE;
5153
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_NAME;
@@ -179,6 +181,7 @@ public void beforeAll(ExtensionContext context) {
179181
images.add(WEBLOGIC_IMAGE_NAME + ":" + WEBLOGIC_IMAGE_TAG);
180182
images.add(FMWINFRA_IMAGE_NAME + ":" + FMWINFRA_IMAGE_TAG);
181183
images.add(DB_IMAGE_NAME + ":" + DB_IMAGE_TAG);
184+
images.add(LOCALE_IMAGE_NAME + ":" + LOCALE_IMAGE_TAG);
182185

183186
for (String image : images) {
184187
withStandardRetryPolicy
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
# Copyright (c) 2022, Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
5+
# Description:
6+
# Update a base WebLogic ol8 image with Japanease Locale
7+
8+
set -o errexit
9+
10+
base_image=${1}
11+
http_proxy=${HTTP_PROXY:-""}
12+
https_proxy=${HTTPS_PROXY:-""}
13+
no_proxy=${NO_PROXY:-""}
14+
15+
# If the image name is phx.ocir.io/weblogick8s/test-images/weblogic:12.2.1.4
16+
# The new image name will be weblogic:12.2.1.4-jp
17+
18+
tagbase=`echo ${base_image} | awk -F '/' '{print $NF}'`
19+
tag="${tagbase}-jp"
20+
21+
cat << EOF > /tmp/Dockerfile
22+
from ${base_image}
23+
USER root
24+
RUN microdnf install glibc-langpack-ja
25+
USER oracle
26+
EOF
27+
28+
echo docker build -f /tmp/Dockerfile --tag=${tag} . --build-arg http_proxy=${http_proxy} --build-arg https_proxy=${https_proxy} -build-arg no_proxy=${no_proxy}
29+
30+
docker build -f /tmp/Dockerfile --tag=${tag} . --build-arg http_proxy=${http_proxy} --build-arg https_proxy=${https_proxy} --build-arg no_proxyr=${no_proxy}

0 commit comments

Comments
 (0)