Skip to content

Commit 52bfdb0

Browse files
committed
Merge branch 'xc-126555' into 'release/4.2'
Fix for FMW sample DB creation failure in nightly runs See merge request weblogic-cloud/weblogic-kubernetes-operator!4964
2 parents 8a81c87 + 2e270a9 commit 52bfdb0

File tree

10 files changed

+177
-32
lines changed

10 files changed

+177
-32
lines changed

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

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2023, 2025, 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;
@@ -31,6 +31,7 @@
3131
import static oracle.weblogic.kubernetes.TestConstants.BUSYBOX_TAG;
3232
import static oracle.weblogic.kubernetes.TestConstants.DB_IMAGE_NAME;
3333
import static oracle.weblogic.kubernetes.TestConstants.DB_IMAGE_TAG;
34+
import static oracle.weblogic.kubernetes.TestConstants.DB_PDB_ID_DEFAULT_19C;
3435
import static oracle.weblogic.kubernetes.TestConstants.FMWINFRA_IMAGE_TAG;
3536
import static oracle.weblogic.kubernetes.TestConstants.FMWINFRA_IMAGE_TO_USE_IN_SPEC;
3637
import static oracle.weblogic.kubernetes.TestConstants.IMAGE_NAME_OPERATOR;
@@ -63,6 +64,7 @@
6364
import static oracle.weblogic.kubernetes.utils.SampleUtils.createPVHostPathAndChangePermissionInKindCluster;
6465
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
6566
import static org.junit.jupiter.api.Assertions.assertNotNull;
67+
import static org.junit.jupiter.api.Assertions.assertTrue;
6668

6769
/**
6870
* Test and verify Domain on PV FMW domain sample.
@@ -141,6 +143,7 @@ public static void initAll(@Namespaces(4) List<String> namespaces) {
141143
envMap.put("OPER_IMAGE_NAME", TEST_IMAGES_PREFIX + IMAGE_NAME_OPERATOR);
142144
envMap.put("DOMAIN_CREATION_IMAGE_NAME", TEST_IMAGES_PREFIX + DOMAIN_CREATION_IMAGE_NAME);
143145
envMap.put("DB_IMAGE_PULL_SECRET", BASE_IMAGES_REPO_SECRET_NAME);
146+
envMap.put("DB_PDB_ID", DB_PDB_ID_DEFAULT_19C);
144147

145148
// kind cluster uses openjdk which is not supported by image tool
146149
if (WIT_JAVA_HOME != null) {
@@ -181,7 +184,7 @@ public static void initAll(@Namespaces(4) List<String> namespaces) {
181184
@Order(1)
182185
public void testInstallOperator() {
183186
String backupReports = backupReports(UniqueName.uniqueName(this.getClass().getSimpleName()));
184-
execTestScriptAndAssertSuccess("-oper", "Failed to run -oper");
187+
assertTrue(execTestScriptAndAssertSuccess("-oper", "Failed to run -oper"));
185188
restoreReports(backupReports);
186189
}
187190

@@ -191,7 +194,8 @@ public void testInstallOperator() {
191194
@Test
192195
@Order(2)
193196
public void testInstallTraefik() {
194-
execTestScriptAndAssertSuccess("-traefik", "Failed to run -traefik");
197+
Assumptions.assumeTrue(previousTestSuccessful);
198+
assertTrue(execTestScriptAndAssertSuccess("-traefik", "Failed to run -traefik"));
195199
}
196200

197201
/**
@@ -200,7 +204,8 @@ public void testInstallTraefik() {
200204
@Test
201205
@Order(3)
202206
public void testPrecleandb() {
203-
execTestScriptAndAssertSuccess("-precleandb", "Failed to run -precleandb");
207+
Assumptions.assumeTrue(previousTestSuccessful);
208+
assertTrue(execTestScriptAndAssertSuccess("-precleandb", "Failed to run -precleandb"));
204209
}
205210

206211
/**
@@ -209,25 +214,38 @@ public void testPrecleandb() {
209214
@Test
210215
@Order(4)
211216
public void testCreatedb() {
217+
Assumptions.assumeTrue(previousTestSuccessful);
212218
logger.info("test case for creating a db");
213219
if (KIND_REPO != null) {
214220
String dbimage = DB_IMAGE_NAME + ":" + DB_IMAGE_TAG;
215221
logger.info("loading image {0} to kind", dbimage);
216222
imagePush(dbimage);
217223
}
218-
execTestScriptAndAssertSuccess("-db", "Failed to run -db");
224+
assertTrue(execTestScriptAndAssertSuccess("-db", "Failed to run -db"));
219225
}
220226

221227
/**
222-
* Test Domain on PV sample building image for FMW domain use case.
228+
* Test Domain on PV sample - Initialize schemas in the DB.
223229
*/
224230
@Test
225231
@Order(5)
232+
public void testCreateRCU() {
233+
Assumptions.assumeTrue(previousTestSuccessful);
234+
logger.info("test case for initializing schemas in the DB");
235+
assertTrue(execTestScriptAndAssertSuccess("-rcu", "Failed to run -rcu"));
236+
}
237+
238+
/**
239+
* Test Domain on PV sample building image for FMW domain use case.
240+
*/
241+
@Test
242+
@Order(6)
226243
public void testInitialImage() {
244+
Assumptions.assumeTrue(previousTestSuccessful);
227245
logger.info("test case for building image");
228246
imagePull(BUSYBOX_IMAGE + ":" + BUSYBOX_TAG);
229247
imageTag(BUSYBOX_IMAGE + ":" + BUSYBOX_TAG, "busybox");
230-
execTestScriptAndAssertSuccess("-initial-image", "Failed to run -initial-image");
248+
assertTrue(execTestScriptAndAssertSuccess("-initial-image", "Failed to run -initial-image"));
231249
ExecResult result = Command.withParams(
232250
new CommandParams()
233251
.command(WLSIMG_BUILDER + " images")
@@ -247,8 +265,9 @@ public void testInitialImage() {
247265
* Test Domain on PV sample create FMW domain use case.
248266
*/
249267
@Test
250-
@Order(6)
268+
@Order(7)
251269
public void testInitialMain() {
270+
Assumptions.assumeTrue(previousTestSuccessful);
252271
logger.info("test case for creating a FMW domain");
253272

254273
// load the base image to kind if using kind cluster
@@ -262,7 +281,7 @@ public void testInitialMain() {
262281
withLongRetryPolicy,
263282
checkTestScriptAndAssertSuccess("-initial-main", "Failed to run -initial-main"),
264283
logger,
265-
"create PV HostPath and change Permission in Kind Cluster");
284+
"creating FMW domain");
266285
}
267286

268287
/**
@@ -273,7 +292,6 @@ public void testInitialMain() {
273292
private boolean execTestScriptAndAssertSuccess(String arg,
274293
String errString) {
275294

276-
Assumptions.assumeTrue(previousTestSuccessful);
277295
previousTestSuccessful = false;
278296

279297
String command = domainOnPvSampleScript
@@ -293,14 +311,14 @@ private boolean execTestScriptAndAssertSuccess(String arg,
293311
&& result.stdout() != null
294312
&& result.stdout().contains("Finished without errors");
295313

296-
String outStr = errString;
297-
outStr += ", command=\n{\n" + command + "\n}\n";
314+
String outStr = success ? "Running test script succeeds: " : errString + ":";
315+
outStr += " command=\n{\n" + command + "\n}\n";
298316
outStr += ", stderr=\n{\n" + (result != null ? result.stderr() : "") + "\n}\n";
299317
outStr += ", stdout=\n{\n" + (result != null ? result.stdout() : "") + "\n}\n";
300318

301319
logger.info("output String is: {0}", outStr);
302320

303-
previousTestSuccessful = true;
321+
previousTestSuccessful = success;
304322

305323
return success;
306324
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ public interface TestConstants {
114114
public static final String DB_IMAGE_NAME_DEFAULT = "test-images/database/enterprise";
115115
public static final String DB_PREBUILT_IMAGE_NAME_DEFAULT = "test-images/database/express";
116116
public static final String DB_IMAGE_TAG_DEFAULT = "19.3.0.0";
117+
public static final String DB_IMAGE_TAG_DEFAULT_12C = "12.2.0.1-slim";
118+
public static final String DB_PDB_ID_DEFAULT_19C = "orclpdb1";
119+
public static final String DB_PDB_ID_DEFAULT_12C = "devpdb.k8s";
117120

118121
// repository to push the domain images created during test execution
119122
// (a) for kind cluster push to kind repo
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Copyright (c) 2025, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
apiVersion: v1
5+
kind: Service
6+
metadata:
7+
name: oracle-db
8+
namespace: default
9+
spec:
10+
ports:
11+
- name: tns
12+
port: 1521
13+
protocol: TCP
14+
targetPort: 1521
15+
nodePort: 30011
16+
selector:
17+
app.kubernetes.io/instance: dev
18+
app.kubernetes.io/name: oracle-db
19+
sessionAffinity: None
20+
type: LoadBalancer
21+
---
22+
apiVersion: apps/v1
23+
kind: Deployment
24+
metadata:
25+
name: oracle-db
26+
namespace: default
27+
spec:
28+
replicas: 1
29+
selector:
30+
matchLabels:
31+
app.kubernetes.io/instance: dev
32+
app.kubernetes.io/name: oracle-db
33+
strategy:
34+
rollingUpdate:
35+
maxSurge: 1
36+
maxUnavailable: 1
37+
type: RollingUpdate
38+
template:
39+
metadata:
40+
labels:
41+
app.kubernetes.io/instance: dev
42+
app.kubernetes.io/name: oracle-db
43+
spec:
44+
containers:
45+
- env:
46+
- name: ORACLE_SID
47+
value: ORCLCDB
48+
- name: ORACLE_PDB
49+
value: ORCLPDB1
50+
- name: DB_DOMAIN
51+
value: k8s
52+
- name: DB_BUNDLE
53+
value: basic
54+
- name: ORACLE_PWD
55+
valueFrom:
56+
secretKeyRef:
57+
name: oracle-db-secret
58+
key: password
59+
image: container-registry.oracle.com/database/enterprise:19.3.0.0
60+
imagePullPolicy: IfNotPresent
61+
name: oracle-db
62+
ports:
63+
- containerPort: 1521
64+
name: tns
65+
protocol: TCP
66+
resources:
67+
requests:
68+
cpu: "2"
69+
memory: "24Gi"
70+
limits:
71+
cpu: "4"
72+
memory: "40Gi"
73+
terminationMessagePath: /dev/termination-log
74+
terminationMessagePolicy: File
75+
dnsPolicy: ClusterFirst
76+
restartPolicy: Always
77+
schedulerName: default-scheduler
78+
securityContext: {}
79+
terminationGracePeriodSeconds: 30
80+
imagePullSecrets:
81+
- name: docker-store

kubernetes/samples/scripts/create-oracle-db-service/common/oracle.db.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (c) 2020, 2025, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
14
apiVersion: v1
25
kind: Service
36
metadata:

kubernetes/samples/scripts/create-oracle-db-service/start-db-service.sh

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright (c) 2019, 2022, Oracle and/or its affiliates.
2+
# Copyright (c) 2019, 2025, Oracle and/or its affiliates.
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44

55
# Bring up Oracle DB Instance in [default] NameSpace with a NodePort Service
@@ -9,7 +9,7 @@ scriptDir="$( cd "$( dirname "${script}" )" && pwd )"
99
source ${scriptDir}/../common/utility.sh
1010

1111
usage() {
12-
echo "usage: ${script} [-a <dbasecret>] [-p <nodeport>] [-i <image>] [-s <pullsecret>] [-n <namespace>] [-h]"
12+
echo "usage: ${script} [-a <dbasecret>] [-p <nodeport>] [-i <image>] [-s <pullsecret>] [-n <namespace>] [-l <pdb_id>] [-h]"
1313
echo " -a DB Sys Account Password Secret Name (optional)"
1414
echo " (default: oracle-db-secret, secret must include a key named 'password')"
1515
echo " If this secret is not deployed, then the database will not successfully deploy."
@@ -22,6 +22,7 @@ usage() {
2222
echo " If this secret is not deployed, then Kubernetes will try pull anonymously."
2323
echo " -n Configurable Kubernetes NameSpace for Oracle DB Service (optional)"
2424
echo " (default: default) "
25+
echo " -l db pdb id for Oracle DB service (optional, default: devpdb.k8s)"
2526
echo " -h Help"
2627
exit $1
2728
}
@@ -31,8 +32,9 @@ nodeport=30011
3132
dbimage="container-registry.oracle.com/database/enterprise:12.2.0.1-slim"
3233
pullsecret="docker-store"
3334
namespace="default"
35+
pdbid="devpdb.k8s"
3436

35-
while getopts ":a:p:i:s:n:h:" opt; do
37+
while getopts ":a:p:i:s:n:h:l:" opt; do
3638
case $opt in
3739
a) syssecret="${OPTARG}"
3840
;;
@@ -44,6 +46,8 @@ while getopts ":a:p:i:s:n:h:" opt; do
4446
;;
4547
n) namespace="${OPTARG}"
4648
;;
49+
l) pdbid="${OPTARG}"
50+
;;
4751
h) usage 0
4852
;;
4953
*) usage 1
@@ -65,11 +69,20 @@ echo "NodePort[$nodeport] ImagePullSecret[$pullsecret] Image[${dbimage}] NameSpa
6569

6670
#create unique db yaml file if does not exists
6771
dbYaml=${scriptDir}/common/oracle.db.${namespace}.yaml
72+
6873
if [ ! -f "$dbYaml" ]; then
6974
echo "$dbYaml does not exist."
70-
cp ${scriptDir}/common/oracle.db.yaml ${dbYaml}
75+
# Choose template based on dbimage version
76+
if echo "$dbimage" | grep -q "12\."; then
77+
templateYaml="${scriptDir}/common/oracle.db.yaml"
78+
else
79+
templateYaml="${scriptDir}/common/oracle.db.19plus.yaml"
80+
fi
81+
echo "Using template: $templateYaml"
82+
cp "$templateYaml" "$dbYaml"
7183
fi
7284

85+
7386
# Modify ImagePullSecret and DatabaseImage based on input
7487
sed -i -e '$d' ${dbYaml}
7588
echo ' - name: docker-store' >> ${dbYaml}
@@ -92,6 +105,7 @@ fi
92105
${KUBERNETES_CLI:-kubectl} delete service oracle-db -n ${namespace} --ignore-not-found
93106

94107
echo "Applying Kubernetes YAML file '${dbYaml}' to start database."
108+
cat ${dbYaml}
95109
${KUBERNETES_CLI:-kubectl} apply -f ${dbYaml}
96110

97111
detectPod ${namespace}
@@ -107,9 +121,30 @@ checkService oracle-db ${namespace}
107121
${KUBERNETES_CLI:-kubectl} get po -n ${namespace}
108122
${KUBERNETES_CLI:-kubectl} get service -n ${namespace}
109123

110-
${KUBERNETES_CLI:-kubectl} cp ${scriptDir}/common/checkDbState.sh -n ${namespace} ${dbpod}:/home/oracle/
124+
logfile="/tmp/setupDB.log"
125+
max=60
126+
counter=0
127+
while [ $counter -le ${max} ]
128+
do
129+
${KUBERNETES_CLI:-kubectl} logs ${dbpod} -n ${namespace} > $logfile
130+
grep -i "DATABASE IS READY" $logfile
131+
[[ $? == 0 ]] && break;
132+
((counter++))
133+
echo "${KUBERNETES_CLI:-kubectl} describe pod ${dbpod} -n ${namespace}"
134+
${KUBERNETES_CLI:-kubectl} describe pod ${dbpod} -n ${namespace}
135+
echo "[$counter/${max}] Retrying for Oracle Database Availability..."
136+
sleep 60
137+
done
138+
139+
if [ $counter -gt ${max} ]; then
140+
echo "[ERRORR] Oracle DB Service is not ready after [${max}] iterations ..."
141+
exit -1
142+
fi
143+
144+
# for db 19c only
145+
echo " set sys password "
146+
${KUBERNETES_CLI:-kubectl} exec -it ${dbpod} -n ${namespace} -- /bin/bash setPassword.sh Oradoc_db1
111147

112-
${KUBERNETES_CLI:-kubectl} exec -it ${dbpod} -n ${namespace} -- /bin/bash /home/oracle/checkDbState.sh
113148
if [ $? != 0 ]; then
114149
echo "######################";
115150
echo "[ERROR] Could not create Oracle DB Service, check the pod log for pod ${dbpod} in namespace ${namespace}";
@@ -122,4 +157,4 @@ if [ ! "${nodeport}" = "none" ]; then
122157
else
123158
echo "Oracle DB Service is RUNNING and does not specify a public NodePort"
124159
fi
125-
echo "Oracle DB Service URL [oracle-db.${namespace}.svc.cluster.local:1521/devpdb.k8s]"
160+
echo "Oracle DB Service URL [oracle-db.${namespace}.svc.cluster.local:1521/${pdbid}]"

operator/integration-tests/domain-on-pv/dpv-sample-wrapper/create-secrets.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright (c) 2023, Oracle and/or its affiliates.
2+
# Copyright (c) 2023, 2025, Oracle and/or its affiliates.
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44

55
#
@@ -15,7 +15,7 @@
1515
# Optional environment variables (see README for details):
1616
#
1717
# WORKDIR, DOMAIN_UID, DOMAIN_NAMESPACE, WDT_DOMAIN_TYPE,
18-
# DB_NAMESPACE, INCLUDE_DOMAIN_CREATION_CONFIGMAP, CORRECTED_DATASOURCE_SECRET,
18+
# DB_NAMESPACE, DB_PDB_ID, INCLUDE_DOMAIN_CREATION_CONFIGMAP, CORRECTED_DATASOURCE_SECRET,
1919
# KUBERNETES_CLI
2020

2121
set -eu
@@ -51,7 +51,7 @@ if [ "$WDT_DOMAIN_TYPE" = "JRF" ]; then
5151
-d $DOMAIN_UID -n $DOMAIN_NAMESPACE \
5252
-l rcu_prefix=FMW${CUSTOM_DOMAIN_NAME} \
5353
-l rcu_schema_password=Oradoc_db1 \
54-
-l rcu_db_conn_string=oracle-db.${DB_NAMESPACE}.svc.cluster.local:1521/devpdb.k8s
54+
-l rcu_db_conn_string=oracle-db.${DB_NAMESPACE}.svc.cluster.local:1521/${DB_PDB_ID}
5555
echo "@@ Info: Creating OPSS wallet password secret (ignored unless domain type is JRF)"
5656
$WORKDIR/domain-on-pv/utils/create-secret.sh $DRY_RUN -s ${DOMAIN_UID}-opss-wallet-password-secret \
5757
-d $DOMAIN_UID -n $DOMAIN_NAMESPACE \
@@ -84,5 +84,5 @@ if [ "${INCLUDE_DOMAIN_CREATION_CONFIGMAP}" = "true" ]; then
8484
-l "user=sys as sysdba" \
8585
-l password=$dspw \
8686
-l max-capacity=$dscap \
87-
-l url=jdbc:oracle:thin:@oracle-db.${DB_NAMESPACE}.svc.cluster.local:1521/devpdb.k8s
87+
-l url=jdbc:oracle:thin:@oracle-db.${DB_NAMESPACE}.svc.cluster.local:1521/${DB_PDB_ID}
8888
fi

0 commit comments

Comments
 (0)