Skip to content

Commit 08719c0

Browse files
author
Tom Barnes
committed
Update introspector mock/unit test: check admin server log for sit-cfg errors, a bit of code cleanup, and finally now can optionally rerun just the introspector.
1 parent 0d39062 commit 08719c0

10 files changed

+185
-78
lines changed

src/integration-tests/introspector/checkBeans.input

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/Servers/${ADMIN_NAME},ListenAddress,,${DOMAIN_UID}-${ADMIN_NAME}
2+
/Servers/${ADMIN_NAME}/Log/${ADMIN_NAME},FileName,logs/${ADMIN_NAME}.log,/shared/logs/${ADMIN_NAME}.log
3+
/Servers/${ADMIN_NAME}/NetworkAccessPoints/T3Channel,ListenAddress,,${DOMAIN_UID}-${ADMIN_NAME}
4+
# /Servers/${ADMIN_NAME},MaxMessageSize,10000000,78787878 TBD Waiting on bug fix to WL 19.1
5+
# /Servers/${ADMIN_NAME}/NetworkAccessPoints/T3Channel,PublicAddress,,${TEST_HOST} TBD Waiting on bug fix to WL 19.1
6+
/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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ set('Name', '${ADMIN_NAME}')
4949
create('T3Channel', 'NetworkAccessPoint')
5050
cd('/Servers/${ADMIN_NAME}/NetworkAccessPoints/T3Channel')
5151
set('PublicPort', ${T3_CHANNEL_PORT})
52-
set('PublicAddress', '${T3_PUBLIC_ADDRESS}')
52+
#set('PublicAddress', '${T3_PUBLIC_ADDRESS}')
53+
#set('PublicAddress', 'invalid-${T3_PUBLIC_ADDRESS}')
5354
#set('ListenAddress', '${DOMAIN_UID}-${ADMIN_NAME}')
5455
#set('ListenAddress', 'invalid-${DOMAIN_UID}-${ADMIN_NAME}')
5556
set('ListenPort', ${T3_CHANNEL_PORT})
@@ -110,6 +111,8 @@ def createDataSource(dsName,dsJNDI,dsHost,dsSID,dsTarget):
110111
create('testJdbcConnectionPoolParams','JDBCConnectionPoolParams')
111112
cd('JDBCConnectionPoolParams/NO_NAME_0')
112113
set('TestTableName','SQL SELECT 1 FROM DUAL')
114+
set('InitialCapacity', 0)
115+
set('MinCapacity', 0)
113116

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

src/integration-tests/introspector/introspectTest.sh

Lines changed: 138 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,6 @@ export DOMAIN_HOME=${DOMAIN_HOME:-/shared/domains/${DOMAIN_UID}}
105105

106106
export NODEMGR_HOME=${NODEMGR_HOME:-/shared/nodemanagers}
107107

108-
# TBD As a test enhancement, the following env vars could solely be derived
109-
# from the introspect topology file output, and
110-
# so should only need to be specified when creating a new domain.
111-
#
112-
# E.g. we ideally shouldn't need to define them here, and should
113-
# only need to explicitly set them when 'CREATE_DOMAIN' is set to true.
114-
# Plus the introspection parsing step in this test should parse
115-
# the topology file and use the parse results to export the needed values
116-
# for the subsequent admin and managed server pod launches, or if
117-
# the macros are already set, the test should verify the topology file
118-
# values match the values in those macros.
119-
120108
export ADMIN_NAME=${ADMIN_NAME:-"admin-server"}
121109
export ADMIN_PORT=${ADMIN_PORT:-7001}
122110
export MANAGED_SERVER_NAME_BASE=${MANAGED_SERVER_NAME_BASE:-"managed-server"}
@@ -127,20 +115,17 @@ export DOMAIN_NAME=${DOMAIN_NAME:-"base_domain"}
127115
# Set extra env vars needed when CREATE_DOMAIN == true
128116
#
129117

130-
if [ "$CREATE_DOMAIN" = "true" ]; then
131-
132-
publicip="`kubectl cluster-info | grep KubeDNS | sed 's;.*https://\(.*\):.*;\1;'`"
133-
publicdns="`nslookup $publicip | grep 'name =' | sed 's/.*name = \(.*\)./\1/'`"
118+
#publicip="`kubectl cluster-info | grep KubeDNS | sed 's;.*//\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\):.*;\1;'`"
119+
#export TEST_HOST="`nslookup $publicip | grep 'name =' | sed 's/.*name = \(.*\)./\1/'`"
120+
export TEST_HOST="mycustompublicaddress"
134121

135-
export CLUSTER_NAME="${CLUSTER_NAME:-mycluster}"
136-
export MANAGED_SERVER_PORT=${MANAGED_SERVER_PORT:-8001}
137-
export CONFIGURED_MANAGED_SERVER_COUNT=${CONFIGURED_MANAGED_SERVER_COUNT:-2}
138-
export CLUSTER_TYPE="${CLUSTER_TYPE:-DYNAMIC}"
139-
export T3_CHANNEL_PORT=${T3_CHANNEL_PORT:-30012}
140-
export T3_PUBLIC_ADDRESS=${T3_PUBLIC_ADDRESS:-${publicdns}}
141-
export PRODUCTION_MODE_ENABLED=${PRODUCTION_MODE_ENABLED:-true}
142-
143-
fi
122+
export CLUSTER_NAME="${CLUSTER_NAME:-mycluster}"
123+
export MANAGED_SERVER_PORT=${MANAGED_SERVER_PORT:-8001}
124+
export CONFIGURED_MANAGED_SERVER_COUNT=${CONFIGURED_MANAGED_SERVER_COUNT:-2}
125+
export CLUSTER_TYPE="${CLUSTER_TYPE:-DYNAMIC}"
126+
export T3_CHANNEL_PORT=${T3_CHANNEL_PORT:-30012}
127+
export T3_PUBLIC_ADDRESS=${T3_PUBLIC_ADDRESS:-}
128+
export PRODUCTION_MODE_ENABLED=${PRODUCTION_MODE_ENABLED:-true}
144129

145130
#############################################################################
146131
#
@@ -155,9 +140,9 @@ fi
155140
# Location for this test to put its temporary files
156141
test_home=/tmp/introspect
157142

158-
function cleanup() {
143+
function cleanupMajor() {
159144
trace "Info: Cleaning files and k8s artifacts from previous run."
160-
145+
161146
# first, let's delete the test's local tmp files for rm -fr
162147
#
163148
# CAUTION: We deliberately hard code the path here instead of using
@@ -188,6 +173,22 @@ function cleanup() {
188173
fi
189174
}
190175

176+
function cleanupMinor() {
177+
trace "Info: RERUN_INTROSPECT_ONLY==true, skipping cleanup.sh and domain home setup, and only deleting wl pods + introspector job."
178+
179+
kubectl -n $NAMESPACE delete pod ${DOMAIN_UID}-${ADMIN_NAME} > /dev/null 2>&1
180+
kubectl -n $NAMESPACE delete pod ${DOMAIN_UID}-${MANAGED_SERVER_NAME_BASE}1 > /dev/null 2>&1
181+
kubectl -n $NAMESPACE delete job ${DOMAIN_UID}-introspect-domain-job > /dev/null 2>&1
182+
rm -fr ${test_home}/jobfiles
183+
tracen "Info: Waiting for wl pods to completely go away before continuing."
184+
while [ 1 -eq 1 ]; do
185+
echo -n "."
186+
[ "`kubectl -n ${NAMESPACE} get pods | grep '${DOMAIN_UID}.*server'`" = "" ] && break
187+
sleep 1
188+
done
189+
echo
190+
}
191+
191192
#############################################################################
192193
#
193194
# Helper function for running a job
@@ -301,7 +302,8 @@ function toDNS1123Legal {
301302
#############################################################################
302303
#
303304
# Deploy domain cm
304-
# - contains introspect, nm, start server scripts, etc.
305+
# - this emulates what the operator pod would do
306+
# - contains the operator's introspect, nm, start server scripts, etc.
305307
# - mounted by create domain job, introspect job, and wl pods
306308
#
307309

@@ -347,16 +349,29 @@ function deployTestScriptConfigMap() {
347349

348350
#############################################################################
349351
#
350-
# Deploy custom override cm
351-
#
352+
# Deploy custom override cm, just like a customer would
352353
#
353354

355+
354356
function deployCustomOverridesConfigMap() {
355357
local cmdir="${test_home}/customOverrides"
356358
local cmname="${DOMAIN_UID}-mycustom-overrides-cm"
359+
360+
trace "Info: Setting up custom overrides map '$cmname' using directory '$cmdir'."
361+
357362
mkdir -p $cmdir
358-
cp ${SCRIPTPATH}/jdbc-testDS.xml $cmdir || exit 1
359-
cp ${SCRIPTPATH}/version.txt $cmdir || exit 1
363+
rm -f $cmdir/*.xml
364+
rm -f $cmdir/*.txt
365+
local bfilname dfilname filname
366+
for filname in override--*.xmlt override--*.txtt; do
367+
bfilname="`basename $filname`"
368+
bfilname="${bfilname/override--/}"
369+
bfilname="${bfilname/xmlt/xml}"
370+
bfilname="${bfilname/txtt/txt}"
371+
#echo $filname "+" $bfilname "+" ${cmdir}/${bfilname}
372+
#cp ${filname} ${cmdir}/${bfilname} || exit 1
373+
${SCRIPTPATH}/util_subst.sh -g ${filname} ${cmdir}/${bfilname} || exit 1
374+
done
360375

361376
kubectl -n $NAMESPACE delete cm $cmname \
362377
--ignore-not-found \
@@ -365,6 +380,7 @@ function deployCustomOverridesConfigMap() {
365380
createConfigMapFromDir $cmname $cmdir || exit 1
366381
}
367382

383+
368384
#############################################################################
369385
#
370386
# Create base directory for PV (uses a job)
@@ -432,6 +448,7 @@ function deployCreateDomainJob() {
432448
#############################################################################
433449
#
434450
# Run introspection job, parse its output to files, and put files in a cm
451+
# - this emulates what the operator pod would do prior to start wl-pods
435452
#
436453

437454
function deployIntrospectJob() {
@@ -466,8 +483,9 @@ function deployIntrospectJob() {
466483

467484
#############################################################################
468485
#
469-
# Launch admin pod and wait up to 180 seconds for it to succeed, then launch
470-
# a managed server pod.
486+
# Launch pod and wait up to 180 seconds for it to succeed, also launch
487+
# services.
488+
# - this emulates what the operator pod would do after running the introspect job
471489
#
472490

473491
function deployPod() {
@@ -490,7 +508,6 @@ function deployPod() {
490508

491509
(
492510
export SERVER_NAME=${server_name}
493-
# TBD SERVER_NAME, ADMIN_PORT, MANAGED_SERVER_PORT should be derived from introspect results
494511
export SERVICE_NAME=`toDNS1123Legal ${DOMAIN_UID}-${server_name}`
495512
export AS_SERVICE_NAME=`toDNS1123Legal ${DOMAIN_UID}-${ADMIN_NAME}`
496513
if [ "${SERVER_NAME}" = "${ADMIN_NAME}" ]; then
@@ -521,7 +538,7 @@ function deployPod() {
521538
fi
522539
echo -n "."
523540
sleep 1
524-
status=`kubectl get pods -n $NAMESPACE 2>&1 | egrep $pod_name | awk '{print $2}'`
541+
status=`kubectl -n $NAMESPACE get pods -n $NAMESPACE 2>&1 | egrep $pod_name | awk '{print $2}'`
525542
done
526543
echo " ($((SECONDS - startsecs)) seconds)"
527544
}
@@ -568,6 +585,58 @@ function deploySinglePodService() {
568585
done
569586
}
570587

588+
589+
#############################################################################
590+
#
591+
# Check if automatic overrides and custom overrides took effect on the admin pod
592+
#
593+
594+
function checkOverrides() {
595+
596+
trace "Info: Checking admin server stdout to make sure situational config was loaded and there are no reported situational config errors."
597+
598+
# Check for exactly 3 occurances of Info.*.BEA.*situational lines -- one for each file we're overriding.
599+
# the awk expression below gets the tail of the log, everything after the last occurance of 'Starting WebLogic...'
600+
601+
linecount="`kubectl -n ${NAMESPACE} logs ${DOMAIN_UID}-${ADMIN_NAME} | awk '/.*Starting WebLogic server with command/ { buf = "" } { buf = buf "\n" $0 } END { print buf }' | grep -ci 'Info.*BEA.*situational'`"
602+
logstatus=0
603+
604+
if [ "$linecount" != "3" ]; then
605+
trace "Error: The latest boot in 'kubectl -n ${NAMESPACE} logs ${DOMAIN_UID}-${ADMIN_NAME}' does not contain exactly 3 lines that match ' grep 'Info.*BEA.*situational' ', this probably means that it's reporting situational config problems."
606+
logstatus=1
607+
fi
608+
609+
#
610+
# Call on-line WLST on the admin-server to determine if overrides are
611+
# taking effect in the admin tree
612+
#
613+
614+
trace "Info: Checking beans to see if sit-cfg took effect. Input file '$test_home/checkBeans.input', output file '$test_home/checkBeans.out'."
615+
616+
rm -f ${test_home}/checkBeans.input
617+
${SCRIPTPATH}/util_subst.sh -g checkBeans.inputt ${test_home}/checkBeans.input || exit 1
618+
kubectl -n ${NAMESPACE} cp ${test_home}/checkBeans.input ${DOMAIN_UID}-${ADMIN_NAME}:/shared/checkBeans.input || exit 1
619+
kubectl -n ${NAMESPACE} cp ${SCRIPTPATH}/checkBeans.py ${DOMAIN_UID}-${ADMIN_NAME}:/shared/checkBeans.py || exit 1
620+
tracen "Info: Waiting for WLST checkBeans.py to complete."
621+
printdots_start
622+
# TBD weblogic/welcome1 should be deduced via a base64 of the admin secret
623+
kubectl exec -it ${DOMAIN_UID}-${ADMIN_NAME} \
624+
wlst.sh /shared/checkBeans.py \
625+
weblogic welcome1 t3://${DOMAIN_UID}-${ADMIN_NAME}:${ADMIN_PORT} \
626+
/shared/checkBeans.input \
627+
> $test_home/checkBeans.out 2>&1
628+
status=$?
629+
printdots_end
630+
if [ $status -ne 0 ]; then
631+
trace "Error: The checkBeans verification failed, see '$test_home/checkBeans.out'."
632+
fi
633+
634+
if [ $status -ne 0 ] || [ $logstatus -ne 0 ]; then
635+
exit 1
636+
fi
637+
}
638+
639+
571640
#############################################################################
572641
#
573642
# Main
@@ -576,58 +645,52 @@ function deploySinglePodService() {
576645
# PVCOMMENT is set, or if CREATE_DOMAIN is set to false.
577646
#
578647

579-
cleanup
648+
#
649+
# TBD ADMIN_NAME, ADMIN_PORT, and MANAGED_SERVER_NAME_BASE, etc env vars
650+
# should be checked to see if topology file the introspector generated
651+
# matches
652+
#
580653

581-
deployDomainConfigMap
654+
if [ ! "$RERUN_INTROSPECT_ONLY" = "true" ]; then
582655

583-
deployTestScriptConfigMap
656+
cleanupMajor
584657

585-
deployCustomOverridesConfigMap
658+
deployDomainConfigMap
659+
deployTestScriptConfigMap
660+
deployCustomOverridesConfigMap
661+
createTestRootPVDir
662+
deployWebLogic_PV_PVC_and_Secret
663+
deployCreateDomainJob
664+
deployIntrospectJob
665+
deployPod ${ADMIN_NAME?}
666+
deploySinglePodService ${ADMIN_NAME?} ${ADMIN_PORT?} 30701
667+
deployPod ${MANAGED_SERVER_NAME_BASE?}1
668+
deploySinglePodService ${MANAGED_SERVER_NAME_BASE?}1 ${MANAGED_SERVER_PORT?} 30801
586669

587-
createTestRootPVDir
670+
else
588671

589-
deployWebLogic_PV_PVC_and_Secret
672+
# This path assumes we've already run the test succesfully once, it re-uses
673+
# the existing domain-home/pv/pvc/secret/etc, deletes wl pods, deletes introspect job, then
674+
# redeploys the custom overrides, reruns the introspect job, and restarts the admin server pod.
590675

591-
deployCreateDomainJob
676+
cleanupMinor
592677

593-
deployIntrospectJob
678+
deployCustomOverridesConfigMap
679+
deployIntrospectJob
680+
deployPod ${ADMIN_NAME?}
681+
682+
fi
594683

595684
#
596-
# TBD ADMIN_NAME, 7001, and MANAGED_SERVER_NAME_BASE
597-
# below should all be derived from introspect
598-
# topology file
685+
# Check admin-server pod log and also Call on-line WLST to check
686+
# if automatic and custom overrides are taking effect in the bean
687+
# tree.
599688
#
600689

601-
deployPod ${ADMIN_NAME?}
602-
603-
deploySinglePodService ${ADMIN_NAME?} ${ADMIN_PORT?} 30701
604-
605-
deployPod ${MANAGED_SERVER_NAME_BASE?}1
606-
607-
deploySinglePodService ${MANAGED_SERVER_NAME_BASE?}1 ${MANAGED_SERVER_PORT?} 30801
690+
checkOverrides
608691

609692
#
610693
# TBD potentially add additional checks to verify wl pods are healthy
611694
#
612695

613-
# TBD 1 weblogic/welcome1 should be deduced via a base64 of the admin secret
614-
# TBD 2 generate checkBeans.input instead of using a hard coded file, add more beans to check, and check mgd servers too
615-
616-
trace "Info: Checking beans to see if sit-cfg took effect. Input file 'checkBeans.input', output file '$test_home/checkBeans.out'."
617-
kubectl cp checkBeans.input domain1-admin-server:/shared/checkBeans.input || exit 1
618-
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
621-
kubectl exec -it domain1-admin-server \
622-
wlst.sh /shared/checkBeans.py \
623-
weblogic welcome1 t3://domain1-admin-server:7001 \
624-
/shared/checkBeans.input \
625-
> $test_home/checkBeans.out 2>&1
626-
status=$?
627-
printdots_end
628-
if [ $status -ne 0 ]; then
629-
trace "Error: checkBeans failed, see '$test_home/checkBeans.out'."
630-
exit 1
631-
fi
632-
633-
trace "Info: success!"
696+
trace "Info: Success!"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<domain xmlns="http://xmlns.oracle.com/weblogic/domain" xmlns:f="http://xmlns.oracle.com/weblogic/domain-fragment" xmlns:s="http://xmlns.oracle.com/weblogic/situational-config">
3+
<server>
4+
<name>${ADMIN_NAME}</name>
5+
<network-access-point>
6+
<name>T3Channel</name>
7+
<public-address f:combine-mode="replace">${TEST_HOST}</public-address>
8+
</network-access-point>
9+
</server>
10+
</domain>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<d:domain xmlns:d="http://xmlns.oracle.com/weblogic/domain" xmlns:f="http://xmlns.oracle.com/weblogic/domain-fragment" xmlns:s="http://xmlns.oracle.com/weblogic/situational-config" >
3+
<d:name>'*'</d:name>
4+
<d:server>
5+
<d:name>'*'</d:name>
6+
<d:max-message-size f:combine-mode="replace">78787878</d:max-message-size>
7+
</d:server>
8+
</d:domain>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<domain xmlns="http://xmlns.oracle.com/weblogic/domain" xmlns:f="http://xmlns.oracle.com/weblogic/domain-fragment" xmlns:s="http://xmlns.oracle.com/weblogic/situational-config">
3+
<name>${DOMAIN_UID}</name>
4+
<server>
5+
<name>admin-server</name>
6+
<network-access-point>
7+
<name>T3Channel</name>
8+
<public-port f:combine-mode="replace">30123</public-port>
9+
</network-access-point>
10+
</server>
11+
</domain>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<d:domain xmlns:d="http://xmlns.oracle.com/weblogic/domain" xmlns:f="http://xmlns.oracle.com/weblogic/domain-fragment" xmlns:s="http://xmlns.oracle.com/weblogic/situational-config" >
3+
<d:name>${DOMAIN_UID}</d:name>
4+
<d:server>
5+
<d:name>${ADMIN_SERVER}</d:name>
6+
<d:max-message-size f:combine-mode="replace">78787878</d:max-message-size>
7+
</d:server>
8+
</d:domain>

0 commit comments

Comments
 (0)