Skip to content

Commit 5c43524

Browse files
authored
Merge pull request #595 from oracle/custom-override-updates
Add data source custom override to introspect mock/unit test.
2 parents 60d43d5 + cd83dc1 commit 5c43524

File tree

7 files changed

+166
-26
lines changed

7 files changed

+166
-26
lines changed
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
/Servers/admin-server,ListenAddress,,domain1-admin-server
2-
#/Servers/admin-server,ListenAddress,foob,domain1-admin-server
3-
#/Servers/admin-server,ListenAddress,,foob
4-
#/Servers/admin-server,ListenAddress,,
5-
#,
6-
2+
/JDBCSystemResources/testDS/JDBCResource/testDS/JDBCDriverParams/testDS,Url,jdbc:oracle:thin:@myoriginalhostname:1521:myoriginalsid,jdbc:oracle:thin:@mynewhost:1521:mynewsid

src/integration-tests/introspector/createDomain.pyt

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,48 @@ cmo.setPassword(admin_password)
7070
# ==============================================
7171
setOption('OverwriteDomain', 'true')
7272

73-
# Configure the node manager
74-
# ==========================
75-
# cd('/NMProperties')
76-
# set('ListenAddress','0.0.0.0')
77-
# set('ListenPort',5556)
78-
# set('CrashRecoveryEnabled', 'true')
79-
# set('NativeVersionEnabled', 'true')
80-
# set('StartScriptEnabled', 'false')
81-
# set('SecureListener', 'false')
82-
# set('LogLevel', 'FINEST')
83-
# set('DomainsDirRemoteSharingEnabled', 'true')
84-
85-
# Set the Node Manager user name and password (domain name will change after writeDomain)
86-
# cd('/SecurityConfiguration/base_domain')
87-
# set('NodeManagerUsername', admin_username)
88-
# set('NodeManagerPasswordEncrypted', admin_password)
73+
# Setup a datasource
74+
# ============================================
75+
def createDataSource(dsName,dsJNDI,dsHost,dsSID,dsTarget):
76+
cd('/')
77+
print 'create JDBCSystemResource'
78+
create(dsName, 'JDBCSystemResource')
79+
cd('/JDBCSystemResource/' + dsName)
80+
#set('Target',dsTarget)
81+
cd('/JDBCSystemResource/' + dsName + '/JdbcResource/' + dsName)
82+
cmo.setName(dsName)
83+
84+
print 'create JDBCDataSourceParams'
85+
cd('/JDBCSystemResource/' + dsName + '/JdbcResource/' + dsName)
86+
create('testDataSourceParams','JDBCDataSourceParams')
87+
cd('JDBCDataSourceParams/NO_NAME_0')
88+
set('JNDIName', java.lang.String(dsJNDI))
89+
set('GlobalTransactionsProtocol', java.lang.String('None'))
90+
91+
print 'create JDBCDriverParams'
92+
cd('/JDBCSystemResource/' + dsName + '/JdbcResource/' + dsName)
93+
create('testDriverParams','JDBCDriverParams')
94+
cd('JDBCDriverParams/NO_NAME_0')
95+
set('DriverName','oracle.jdbc.OracleDriver')
96+
set('URL','jdbc:oracle:thin:@' + dsHost + ':1521:' + dsSID)
97+
set('PasswordEncrypted', 'manager')
98+
set('UseXADataSourceInterface', 'false')
99+
100+
print 'create JDBCDriverParams Properties'
101+
create('testProperties','Properties')
102+
cd('Properties/NO_NAME_0')
103+
create('user','Property')
104+
cd('Property')
105+
cd('user')
106+
set('Value', 'scott')
107+
108+
print 'create JDBCConnectionPoolParams'
109+
cd('/JDBCSystemResource/' + dsName + '/JdbcResource/' + dsName)
110+
create('testJdbcConnectionPoolParams','JDBCConnectionPoolParams')
111+
cd('JDBCConnectionPoolParams/NO_NAME_0')
112+
set('TestTableName','SQL SELECT 1 FROM DUAL')
113+
114+
createDataSource('testDS','testDS','myoriginalhostname','myoriginalsid','${ADMIN_NAME}')
89115

90116
# Create a cluster
91117
# ======================

src/integration-tests/introspector/introspectTest.sh

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
4242
SOURCEPATH="`echo $SCRIPTPATH | sed 's/weblogic-kubernetes-operator.*/weblogic-kubernetes-operator/'`"
4343
traceFile=${SOURCEPATH}/operator/src/main/resources/scripts/traceUtils.sh
4444
source ${traceFile}
45+
source ${SCRIPTPATH}/util_dots.sh
4546
[ $? -ne 0 ] && echo "Error: missing file ${traceFile}" && exit 1
4647

4748
# Set TRACE_INCLUDE_FILE to true to cause tracing to include filename & line number.
@@ -172,11 +173,15 @@ function cleanup() {
172173
# 2 - delete contents of k8s weblogic domain PV/PVC
173174
# (if CREATE_DOMAIN has been set to "true")
174175

176+
tracen "Info: Waiting for cleanup.sh to complete."
177+
printdots_start
175178
DELETE_FILES=${CREATE_DOMAIN:-false} \
176179
${SOURCEPATH}/src/integration-tests/bash/cleanup.sh 2>&1 > \
177180
${test_home}/cleanup.out
181+
status=$?
182+
printdots_end
178183

179-
if [ $? -ne 0 ]; then
184+
if [ $status -ne 0 ]; then
180185
trace "Error: cleanup failed. Cleanup output:"
181186
cat ${test_home}/cleanup.out
182187
exit 1
@@ -210,15 +215,20 @@ function runJob() {
210215

211216
# Run the job
212217

218+
tracen "Info: Waiting for job '$job_name' to complete."
219+
printdots_start
213220
env \
214221
KUBECONFIG=$KUBECONFIG \
215222
JOB_YAML=${test_home}/${yaml_file} \
216223
JOB_NAME=${job_name} \
217224
NAMESPACE=$NAMESPACE \
218225
${SCRIPTPATH}/util_job.sh \
219226
2>&1 > ${test_home}/job-${1}.out
227+
local status=$?
228+
printdots_end
220229

221-
if [ ! $? -eq 0 ]; then
230+
if [ ! $status -eq 0 ]; then
231+
printdots_end
222232
trace "Error: job failed, job contents"
223233
cat ${test_home}/job-${1}.out
224234
trace "Error: end of failed job contents"
@@ -335,6 +345,26 @@ function deployTestScriptConfigMap() {
335345

336346
}
337347

348+
#############################################################################
349+
#
350+
# Deploy custom override cm
351+
#
352+
#
353+
354+
function deployCustomOverridesConfigMap() {
355+
local cmdir="${test_home}/customOverrides"
356+
local cmname="${DOMAIN_UID}-mycustom-overrides-cm"
357+
mkdir -p $cmdir
358+
cp ${SCRIPTPATH}/jdbc-testDS.xml $cmdir || exit 1
359+
cp ${SCRIPTPATH}/version.txt $cmdir || exit 1
360+
361+
kubectl -n $NAMESPACE delete cm $cmname \
362+
--ignore-not-found \
363+
2>&1 | tracePipe "Info: kubectl output: "
364+
365+
createConfigMapFromDir $cmname $cmdir || exit 1
366+
}
367+
338368
#############################################################################
339369
#
340370
# Create base directory for PV (uses a job)
@@ -476,10 +506,10 @@ function deployPod() {
476506

477507
# Wait for pod to come up successfully
478508

479-
tracen "Info: Waiting for pod readiness"
480509
local status="0/1"
481510
local startsecs=$SECONDS
482511
local maxsecs=180
512+
tracen "Info: Waiting up to $maxsecs seconds for pod '$pod_name' readiness"
483513
while [ "${status}" != "1/1" ] ; do
484514
if [ $((SECONDS - startsecs)) -gt $maxsecs ]; then
485515
echo
@@ -493,7 +523,7 @@ function deployPod() {
493523
sleep 1
494524
status=`kubectl get pods -n $NAMESPACE 2>&1 | egrep $pod_name | awk '{print $2}'`
495525
done
496-
echo
526+
echo " ($((SECONDS - startsecs)) seconds)"
497527
}
498528

499529
function deploySinglePodService() {
@@ -552,6 +582,8 @@ deployDomainConfigMap
552582

553583
deployTestScriptConfigMap
554584

585+
deployCustomOverridesConfigMap
586+
555587
createTestRootPVDir
556588

557589
deployWebLogic_PV_PVC_and_Secret
@@ -584,12 +616,16 @@ deploySinglePodService ${MANAGED_SERVER_NAME_BASE?}1 ${MANAGED_SERVER_PORT?} 308
584616
trace "Info: Checking beans to see if sit-cfg took effect. Input file 'checkBeans.input', output file '$test_home/checkBeans.out'."
585617
kubectl cp checkBeans.input domain1-admin-server:/shared/checkBeans.input || exit 1
586618
kubectl cp checkBeans.py domain1-admin-server:/shared/checkBeans.py || exit 1
619+
tracen "Info: Waiting for WLST checkBeans.py to complete."
620+
printdots_start
587621
kubectl exec -it domain1-admin-server \
588622
wlst.sh /shared/checkBeans.py \
589623
weblogic welcome1 t3://domain1-admin-server:7001 \
590624
/shared/checkBeans.input \
591625
> $test_home/checkBeans.out 2>&1
592-
if [ $? -ne 0 ]; then
626+
status=$?
627+
printdots_end
628+
if [ $status -ne 0 ]; then
593629
trace "Error: checkBeans failed, see '$test_home/checkBeans.out'."
594630
exit 1
595631
fi
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<jdbc-data-source xmlns="http://xmlns.oracle.com/weblogic/jdbc-data-source" xmlns:f="http://xmlns.oracle.com/weblogic/jdbc-data-source-fragment" xmlns:s="http://xmlns.oracle.com/weblogic/situational-config">
3+
<name>testDS</name>
4+
<jdbc-driver-params>
5+
<url f:combine-mode="replace">jdbc:oracle:thin:@mynewhost:1521:mynewsid</url>
6+
</jdbc-driver-params>
7+
</jdbc-data-source>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# !/bin/sh
2+
3+
# Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
4+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
5+
6+
#
7+
# Description:
8+
# ------------
9+
#
10+
# This helper utility prints dots using a background process
11+
# while a foreground process runs. Use it to provide feedback
12+
# while you wait for the foreground process to finish.
13+
#
14+
# It stops printing dots when any of the following are true:
15+
# - printdots_end is called
16+
# - the process that called printdots_start is no longer around
17+
# - more than 120 seconds has passed
18+
#
19+
# Usage example:
20+
# source ./util_dots.sh
21+
#
22+
# echo -n "Hello"
23+
# printdots_start 1
24+
# sleep 6
25+
# printdots_end
26+
#
27+
# The first parameter of printdots_start is the number of seconds
28+
# to wait before each dot - default is 2 seconds.
29+
#
30+
# 'printdots_end' calls 'echo' without any parameters.
31+
#
32+
33+
printdots_inner() {
34+
local start_pids="`ps $PPID 2>&1`"
35+
local dotsfile=$1
36+
local begin_sec=$SECONDS
37+
[ -f "$dotsfile" ] || return
38+
while [ 1 -eq 1 ]; do
39+
sleep ${2:-1}
40+
# if parent pids changed, then our parent died and we should exit
41+
local end_pids="`ps $PPID 2>&1`"
42+
[ "$start_pids" = "$end_pids" ] || break
43+
44+
# if too much time has passed, then exit
45+
[ $((SECONDS-begin_sec)) -lt 120 ] || break
46+
47+
# if parent deleted our temp file, then exit
48+
[ -f "$dotsfile" ] || break
49+
50+
echo -n "."
51+
done
52+
rm -f $dotsfile
53+
}
54+
55+
printdots_start() {
56+
dotsfile=$(mktemp /tmp/dots.`basename $0`.XXXXXXXXX)
57+
touch $dotsfile
58+
printdots_inner $dotsfile $1 &
59+
printdots_pid=$!
60+
printdots_time_start=$SECONDS
61+
}
62+
63+
printdots_end() {
64+
rm -f $dotsfile
65+
wait $printdots_pid > /dev/null 2>&1
66+
echo " ($((SECONDS - printdots_time_start)) seconds)"
67+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.0

src/integration-tests/introspector/wl-job.yamlt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ spec:
4343
- name: weblogic-domain-cm-volume
4444
mountPath: /weblogic-operator/scripts
4545
readOnly: true
46+
- name: ${DOMAIN_UID}-mycustom-overrides-cm-volume
47+
mountPath: /weblogic-operator/config-overrides
48+
readOnly: true
4649
- name: test-script-cm-volume
4750
mountPath: /test-scripts
4851
readOnly: true
@@ -57,6 +60,10 @@ spec:
5760
configMap:
5861
defaultMode: 365
5962
name: weblogic-domain-cm
63+
- name: ${DOMAIN_UID}-mycustom-overrides-cm-volume
64+
configMap:
65+
defaultMode: 365
66+
name: ${DOMAIN_UID}-mycustom-overrides-cm
6067
- name: test-script-cm-volume
6168
configMap:
6269
defaultMode: 365

0 commit comments

Comments
 (0)