Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/integration-tests/introspector/checkBeans.input
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
/Servers/admin-server,ListenAddress,,domain1-admin-server
#/Servers/admin-server,ListenAddress,foob,domain1-admin-server
#/Servers/admin-server,ListenAddress,,foob
#/Servers/admin-server,ListenAddress,,
#,

/JDBCSystemResources/testDS/JDBCResource/testDS/JDBCDriverParams/testDS,Url,jdbc:oracle:thin:@myoriginalhostname:1521:myoriginalsid,jdbc:oracle:thin:@mynewhost:1521:mynewsid
58 changes: 42 additions & 16 deletions src/integration-tests/introspector/createDomain.pyt
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,48 @@ cmo.setPassword(admin_password)
# ==============================================
setOption('OverwriteDomain', 'true')

# Configure the node manager
# ==========================
# cd('/NMProperties')
# set('ListenAddress','0.0.0.0')
# set('ListenPort',5556)
# set('CrashRecoveryEnabled', 'true')
# set('NativeVersionEnabled', 'true')
# set('StartScriptEnabled', 'false')
# set('SecureListener', 'false')
# set('LogLevel', 'FINEST')
# set('DomainsDirRemoteSharingEnabled', 'true')

# Set the Node Manager user name and password (domain name will change after writeDomain)
# cd('/SecurityConfiguration/base_domain')
# set('NodeManagerUsername', admin_username)
# set('NodeManagerPasswordEncrypted', admin_password)
# Setup a datasource
# ============================================
def createDataSource(dsName,dsJNDI,dsHost,dsSID,dsTarget):
cd('/')
print 'create JDBCSystemResource'
create(dsName, 'JDBCSystemResource')
cd('/JDBCSystemResource/' + dsName)
#set('Target',dsTarget)
cd('/JDBCSystemResource/' + dsName + '/JdbcResource/' + dsName)
cmo.setName(dsName)

print 'create JDBCDataSourceParams'
cd('/JDBCSystemResource/' + dsName + '/JdbcResource/' + dsName)
create('testDataSourceParams','JDBCDataSourceParams')
cd('JDBCDataSourceParams/NO_NAME_0')
set('JNDIName', java.lang.String(dsJNDI))
set('GlobalTransactionsProtocol', java.lang.String('None'))

print 'create JDBCDriverParams'
cd('/JDBCSystemResource/' + dsName + '/JdbcResource/' + dsName)
create('testDriverParams','JDBCDriverParams')
cd('JDBCDriverParams/NO_NAME_0')
set('DriverName','oracle.jdbc.OracleDriver')
set('URL','jdbc:oracle:thin:@' + dsHost + ':1521:' + dsSID)
set('PasswordEncrypted', 'manager')
set('UseXADataSourceInterface', 'false')

print 'create JDBCDriverParams Properties'
create('testProperties','Properties')
cd('Properties/NO_NAME_0')
create('user','Property')
cd('Property')
cd('user')
set('Value', 'scott')

print 'create JDBCConnectionPoolParams'
cd('/JDBCSystemResource/' + dsName + '/JdbcResource/' + dsName)
create('testJdbcConnectionPoolParams','JDBCConnectionPoolParams')
cd('JDBCConnectionPoolParams/NO_NAME_0')
set('TestTableName','SQL SELECT 1 FROM DUAL')

createDataSource('testDS','testDS','myoriginalhostname','myoriginalsid','${ADMIN_NAME}')

# Create a cluster
# ======================
Expand Down
46 changes: 41 additions & 5 deletions src/integration-tests/introspector/introspectTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
SOURCEPATH="`echo $SCRIPTPATH | sed 's/weblogic-kubernetes-operator.*/weblogic-kubernetes-operator/'`"
traceFile=${SOURCEPATH}/operator/src/main/resources/scripts/traceUtils.sh
source ${traceFile}
source ${SCRIPTPATH}/util_dots.sh
[ $? -ne 0 ] && echo "Error: missing file ${traceFile}" && exit 1

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

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

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

# Run the job

tracen "Info: Waiting for job '$job_name' to complete."
printdots_start
env \
KUBECONFIG=$KUBECONFIG \
JOB_YAML=${test_home}/${yaml_file} \
JOB_NAME=${job_name} \
NAMESPACE=$NAMESPACE \
${SCRIPTPATH}/util_job.sh \
2>&1 > ${test_home}/job-${1}.out
local status=$?
printdots_end

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

}

#############################################################################
#
# Deploy custom override cm
#
#

function deployCustomOverridesConfigMap() {
local cmdir="${test_home}/customOverrides"
local cmname="${DOMAIN_UID}-mycustom-overrides-cm"
mkdir -p $cmdir
cp ${SCRIPTPATH}/jdbc-testDS.xml $cmdir || exit 1
cp ${SCRIPTPATH}/version.txt $cmdir || exit 1

kubectl -n $NAMESPACE delete cm $cmname \
--ignore-not-found \
2>&1 | tracePipe "Info: kubectl output: "

createConfigMapFromDir $cmname $cmdir || exit 1
}

#############################################################################
#
# Create base directory for PV (uses a job)
Expand Down Expand Up @@ -476,10 +506,10 @@ function deployPod() {

# Wait for pod to come up successfully

tracen "Info: Waiting for pod readiness"
local status="0/1"
local startsecs=$SECONDS
local maxsecs=180
tracen "Info: Waiting up to $maxsecs seconds for pod '$pod_name' readiness"
while [ "${status}" != "1/1" ] ; do
if [ $((SECONDS - startsecs)) -gt $maxsecs ]; then
echo
Expand All @@ -493,7 +523,7 @@ function deployPod() {
sleep 1
status=`kubectl get pods -n $NAMESPACE 2>&1 | egrep $pod_name | awk '{print $2}'`
done
echo
echo " ($((SECONDS - startsecs)) seconds)"
}

function deploySinglePodService() {
Expand Down Expand Up @@ -552,6 +582,8 @@ deployDomainConfigMap

deployTestScriptConfigMap

deployCustomOverridesConfigMap

createTestRootPVDir

deployWebLogic_PV_PVC_and_Secret
Expand Down Expand Up @@ -584,12 +616,16 @@ deploySinglePodService ${MANAGED_SERVER_NAME_BASE?}1 ${MANAGED_SERVER_PORT?} 308
trace "Info: Checking beans to see if sit-cfg took effect. Input file 'checkBeans.input', output file '$test_home/checkBeans.out'."
kubectl cp checkBeans.input domain1-admin-server:/shared/checkBeans.input || exit 1
kubectl cp checkBeans.py domain1-admin-server:/shared/checkBeans.py || exit 1
tracen "Info: Waiting for WLST checkBeans.py to complete."
printdots_start
kubectl exec -it domain1-admin-server \
wlst.sh /shared/checkBeans.py \
weblogic welcome1 t3://domain1-admin-server:7001 \
/shared/checkBeans.input \
> $test_home/checkBeans.out 2>&1
if [ $? -ne 0 ]; then
status=$?
printdots_end
if [ $status -ne 0 ]; then
trace "Error: checkBeans failed, see '$test_home/checkBeans.out'."
exit 1
fi
Expand Down
7 changes: 7 additions & 0 deletions src/integration-tests/introspector/jdbc-testDS.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<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">
<name>testDS</name>
<jdbc-driver-params>
<url f:combine-mode="replace">jdbc:oracle:thin:@mynewhost:1521:mynewsid</url>
</jdbc-driver-params>
</jdbc-data-source>
67 changes: 67 additions & 0 deletions src/integration-tests/introspector/util_dots.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# !/bin/sh

# Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.

#
# Description:
# ------------
#
# This helper utility prints dots using a background process
# while a foreground process runs. Use it to provide feedback
# while you wait for the foreground process to finish.
#
# It stops printing dots when any of the following are true:
# - printdots_end is called
# - the process that called printdots_start is no longer around
# - more than 120 seconds has passed
#
# Usage example:
# source ./util_dots.sh
#
# echo -n "Hello"
# printdots_start 1
# sleep 6
# printdots_end
#
# The first parameter of printdots_start is the number of seconds
# to wait before each dot - default is 2 seconds.
#
# 'printdots_end' calls 'echo' without any parameters.
#

printdots_inner() {
local start_pids="`ps $PPID 2>&1`"
local dotsfile=$1
local begin_sec=$SECONDS
[ -f "$dotsfile" ] || return
while [ 1 -eq 1 ]; do
sleep ${2:-1}
# if parent pids changed, then our parent died and we should exit
local end_pids="`ps $PPID 2>&1`"
[ "$start_pids" = "$end_pids" ] || break

# if too much time has passed, then exit
[ $((SECONDS-begin_sec)) -lt 120 ] || break

# if parent deleted our temp file, then exit
[ -f "$dotsfile" ] || break

echo -n "."
done
rm -f $dotsfile
}

printdots_start() {
dotsfile=$(mktemp /tmp/dots.`basename $0`.XXXXXXXXX)
touch $dotsfile
printdots_inner $dotsfile $1 &
printdots_pid=$!
printdots_time_start=$SECONDS
}

printdots_end() {
rm -f $dotsfile
wait $printdots_pid > /dev/null 2>&1
echo " ($((SECONDS - printdots_time_start)) seconds)"
}
1 change: 1 addition & 0 deletions src/integration-tests/introspector/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.0
7 changes: 7 additions & 0 deletions src/integration-tests/introspector/wl-job.yamlt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ spec:
- name: weblogic-domain-cm-volume
mountPath: /weblogic-operator/scripts
readOnly: true
- name: ${DOMAIN_UID}-mycustom-overrides-cm-volume
mountPath: /weblogic-operator/config-overrides
readOnly: true
- name: test-script-cm-volume
mountPath: /test-scripts
readOnly: true
Expand All @@ -57,6 +60,10 @@ spec:
configMap:
defaultMode: 365
name: weblogic-domain-cm
- name: ${DOMAIN_UID}-mycustom-overrides-cm-volume
configMap:
defaultMode: 365
name: ${DOMAIN_UID}-mycustom-overrides-cm
- name: test-script-cm-volume
configMap:
defaultMode: 365
Expand Down