Skip to content

Commit ef2be5f

Browse files
author
Tom Barnes
committed
(1) Initial version of introspectTest.sh sit-cfg checker, and (2) fix introspectTest.sh to account for recent change to ready probe.
1 parent b5d5846 commit ef2be5f

File tree

4 files changed

+140
-21
lines changed

4 files changed

+140
-21
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/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+
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.a
3+
4+
import sys
5+
import os
6+
7+
#
8+
# This program verifies that bean attr values are expected values.
9+
#
10+
# Usage:
11+
#
12+
# Create a file with lines of format:
13+
# bean-path,attr-name,original-val,overridden-val
14+
#
15+
# For example:
16+
# /Servers/admin-server,ListenAddress,,domain1-admin-server
17+
#
18+
# The program will check that the original-val matches the value
19+
# in the 'domainConfig' mbean tree and that the overridden-val
20+
# matches the value in the 'serverConfig' mbean tree.
21+
#
22+
# The program exits with a non-zero exit code on any failure
23+
# (including an unexpected attribute value).
24+
#
25+
#
26+
27+
admin_username = sys.argv[1]
28+
admin_password = sys.argv[2]
29+
input_file = sys.argv[3]
30+
31+
admin_port=os.getenv('LOCAL_SERVER_DEFAULT_PORT')
32+
33+
service_name=os.getenv('SERVICE_NAME')
34+
35+
connect(admin_username,admin_password,"t3://" + service_name + ":" + admin_port)
36+
37+
errors=[]
38+
def addError(err):
39+
errors.append(err)
40+
41+
file = open(input_file, 'r')
42+
43+
line_no=0
44+
for line in file:
45+
line=line.strip()
46+
line_no+=1
47+
print "Info: input file line# " + str(line_no) + " ='"+line+"'"
48+
if len(line)>0 and line[0]=='#':
49+
continue
50+
words=line.split(',')
51+
if (len(words) == 1 and line != '') or len(words) != 4:
52+
addError("Error in line syntax line#=" + str(line_no) + " line='"+line+"'")
53+
continue
54+
bean_path=words[0]
55+
attr=words[1]
56+
originalExpected=words[2]
57+
overriddenExpected=words[3]
58+
59+
print(
60+
"Info: Checking bean_path='" + bean_path + "'"
61+
+ " attr='" + attr + "'"
62+
+ " originalExpected='" + originalExpected + "'"
63+
+ " overriddenExpected='" + overriddenExpected + "'"
64+
)
65+
66+
domainConfig()
67+
cd(bean_path)
68+
originalActual=get(attr)
69+
serverConfig()
70+
cd(bean_path)
71+
overriddenActual=get(attr)
72+
73+
print("Info: originalActual='" + originalActual + "'")
74+
print("Info: overriddenActual='" + overriddenActual + "'")
75+
76+
if originalActual != originalExpected:
77+
addError(
78+
"Error: got '" + originalActual + "'"
79+
+ " but expected value '" + originalExpected + "'"
80+
+ " for bean_path=domainConfig/" + bean_path
81+
+ " attr='" + attr + "'. "
82+
)
83+
84+
if overriddenActual != overriddenExpected:
85+
addError(
86+
"Error: got '" + overriddenActual + "'"
87+
+ " but expected value '" + overriddenExpected + "'"
88+
+ " for bean_path=serverConfig/" + bean_path
89+
+ " attr='" + attr + "'. "
90+
)
91+
file.close()
92+
93+
if len(errors) > 0:
94+
print "Found " + str(len(errors)) + " errors:"
95+
for err in errors:
96+
print " --> " + err
97+
exit(exitcode=1)

src/integration-tests/introspector/introspectTest.sh

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ function deployYamlTemplate() {
241241
if [ -f "{test_home}/${yaml_file}" ]; then
242242
kubectl -n $NAMESPACE delete -f ${test_home}/${yaml_file} \
243243
--ignore-not-found \
244-
2>&1 | tracePipe "kubectl output: "
244+
2>&1 | tracePipe "Info: kubectl output: "
245245
rm -f ${test_home}/${yaml_file}
246246
fi
247247

@@ -250,7 +250,7 @@ function deployYamlTemplate() {
250250
${SCRIPTPATH}/util_subst.sh -g ${yaml_file}t ${test_home}/${yaml_file} || exit 1
251251

252252
kubectl create -f ${test_home}/${yaml_file} \
253-
2>&1 | tracePipe "kubectl output: " || exit 1
253+
2>&1 | tracePipe "Info: kubectl output: " || exit 1
254254
}
255255

256256
#############################################################################
@@ -265,13 +265,13 @@ createConfigMapFromDir() {
265265

266266
kubectl -n $NAMESPACE create cm ${cm_name} \
267267
--from-file ${cm_dir} \
268-
2>&1 | tracePipe "kubectl output: " || exit 1
268+
2>&1 | tracePipe "Info: kubectl output: " || exit 1
269269

270270
kubectl -n $NAMESPACE label cm ${cm_name} \
271271
weblogic.createdByOperator=true \
272272
weblogic.operatorName=look-ma-no-hands \
273273
weblogic.resourceVersion=domain-v2 \
274-
2>&1 | tracePipe "kubectl output: " || exit 1
274+
2>&1 | tracePipe "Info: kubectl output: " || exit 1
275275
}
276276

277277

@@ -300,7 +300,7 @@ function deployDomainConfigMap() {
300300

301301
kubectl -n $NAMESPACE delete cm weblogic-domain-cm \
302302
--ignore-not-found \
303-
2>&1 | tracePipe "kubectl output: "
303+
2>&1 | tracePipe "Info: kubectl output: "
304304

305305
createConfigMapFromDir weblogic-domain-cm ${SOURCEPATH}/operator/src/main/resources/scripts
306306
}
@@ -329,7 +329,7 @@ function deployTestScriptConfigMap() {
329329

330330
kubectl -n $NAMESPACE delete cm test-script-cm \
331331
--ignore-not-found \
332-
2>&1 | tracePipe "kubectl output: "
332+
2>&1 | tracePipe "Info: kubectl output: "
333333

334334
createConfigMapFromDir test-script-cm ${test_home}/test-scripts
335335

@@ -413,7 +413,7 @@ function deployIntrospectJob() {
413413

414414
kubectl -n $NAMESPACE delete cm $introspect_output_cm_name \
415415
--ignore-not-found \
416-
2>&1 | tracePipe "kubectl output: "
416+
2>&1 | tracePipe "Info: kubectl output: "
417417

418418
# run introspection job
419419

@@ -452,26 +452,31 @@ function deployPod() {
452452
if [ -f "${target_yaml}" ]; then
453453
kubectl -n $NAMESPACE delete -f ${target_yaml} \
454454
--ignore-not-found \
455-
2>&1 | tracePipe "kubectl output: "
455+
2>&1 | tracePipe "Info: kubectl output: "
456456
rm -f ${target_yaml}
457457
fi
458458

459459
# Generate server pod yaml from template and deploy it
460460

461461
(
462462
export SERVER_NAME=${server_name}
463-
# TBD SERVER_NAME should be derived from introspect results
463+
# TBD SERVER_NAME, ADMIN_PORT, MANAGED_SERVER_PORT should be derived from introspect results
464464
export SERVICE_NAME=`toDNS1123Legal ${DOMAIN_UID}-${server_name}`
465465
export AS_SERVICE_NAME=`toDNS1123Legal ${DOMAIN_UID}-${ADMIN_NAME}`
466+
if [ "${SERVER_NAME}" = "${ADMIN_NAME}" ]; then
467+
export LOCAL_SERVER_DEFAULT_PORT=$ADMIN_PORT
468+
else
469+
export LOCAL_SERVER_DEFAULT_PORT=$MANAGED_SERVER_PORT
470+
fi
466471
${SCRIPTPATH}/util_subst.sh -g wl-pod.yamlt ${target_yaml} || exit 1
467472
) || exit 1
468473

469474
kubectl create -f ${target_yaml} \
470-
2>&1 | tracePipe "kubectl output: " || exit 1
475+
2>&1 | tracePipe "Info: kubectl output: " || exit 1
471476

472477
# Wait for pod to come up successfully
473478

474-
tracen "Waiting for pod readiness"
479+
tracen "Info: Waiting for pod readiness"
475480
local status="0/1"
476481
local startsecs=$SECONDS
477482
local maxsecs=180
@@ -504,7 +509,7 @@ function deploySinglePodService() {
504509
if [ -f "${target_yaml}" ]; then
505510
kubectl -n $NAMESPACE delete -f ${target_yaml} \
506511
--ignore-not-found \
507-
2>&1 | tracePipe "kubectl output: "
512+
2>&1 | tracePipe "Info: kubectl output: "
508513
rm -f ${target_yaml}
509514
fi
510515

@@ -517,7 +522,7 @@ function deploySinglePodService() {
517522
)
518523

519524
kubectl create -f ${target_yaml} \
520-
2>&1 | tracePipe "kubectl output: " || exit 1
525+
2>&1 | tracePipe "Info: kubectl output: " || exit 1
521526

522527
local svc=""
523528
local startsecs=$SECONDS
@@ -561,14 +566,23 @@ deployIntrospectJob
561566
# topology file
562567
#
563568

564-
deployPod ${ADMIN_NAME}
569+
deployPod ${ADMIN_NAME?}
570+
571+
deploySinglePodService ${ADMIN_NAME?} ${ADMIN_PORT?} 30701
565572

566-
deploySinglePodService ${ADMIN_NAME} 7001 30701
573+
deployPod ${MANAGED_SERVER_NAME_BASE?}1
567574

568-
deployPod ${MANAGED_SERVER_NAME_BASE}1
575+
deploySinglePodService ${MANAGED_SERVER_NAME_BASE?}1 ${MANAGED_SERVER_PORT?} 30801
569576

570577
#
571578
# TBD potentially add additional checks to verify wl pods are healthy
572579
#
573580

581+
# TBD 1 weblogic/welcome1 should be deduced via a base64 of the admin secret
582+
# TBD 2 generate checkBeans.input instead of using a hard coded file, add more beans to check, and check mgd servers too
583+
584+
kubectl cp checkBeans.input domain1-admin-server:/shared/checkBeans.input
585+
kubectl cp checkBeans.py domain1-admin-server:/shared/checkBeans.py
586+
kubectl exec -it domain1-admin-server wlst.sh /shared/checkBeans.py weblogic welcome1 /shared/checkBeans.input
587+
574588
trace "Info: success!"

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ spec:
4343
value: "${SERVICE_NAME}"
4444
- name: AS_SERVICE_NAME
4545
value: "${AS_SERVICE_NAME}"
46+
- name: LOCAL_SERVER_DEFAULT_PORT
47+
value: "${LOCAL_SERVER_DEFAULT_PORT}"
4648
- name: ADMIN_USERNAME
4749
value: ""
4850
- name: ADMIN_PASSWORD
@@ -71,15 +73,16 @@ spec:
7173
# timeoutSeconds: 5
7274
name: weblogic-server
7375
ports:
74-
- containerPort: ${ADMIN_PORT}
76+
- containerPort: ${LOCAL_SERVER_DEFAULT_PORT}
7577
protocol: TCP
7678
readinessProbe:
77-
exec:
78-
command:
79-
- /weblogic-operator/scripts/readinessProbe.sh
8079
failureThreshold: 1
80+
httpGet:
81+
path: /weblogic
82+
port: ${LOCAL_SERVER_DEFAULT_PORT}
83+
scheme: HTTP
8184
initialDelaySeconds: 2
82-
periodSeconds: 5
85+
periodSeconds: 1
8386
successThreshold: 1
8487
timeoutSeconds: 5
8588
resources: {}

0 commit comments

Comments
 (0)