Skip to content

Commit eb0c7b3

Browse files
authored
Merge pull request #882 from oracle/introspect-mock-test-updates
Introspect mock test updates
2 parents 56483f8 + ce372f4 commit eb0c7b3

20 files changed

+553
-309
lines changed

src/integration-tests/bash/cleanup.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
# DELETE_FILES Delete local test files, and launch a job to delete PV
2525
# hosted test files (default true).
2626
#
27+
# FAST_DELETE Set to "--grace-period=1 --timeout=1" to speedup
28+
# deletes and skip phase 2.
29+
#
2730
# --------------------
2831
# Detailed Description
2932
# --------------------
@@ -98,13 +101,13 @@ function deleteWithOneLabel {
98101
getResWithLabel $1
99102
# delete namespaced types
100103
cat $1 | awk '{ print $4 }' | grep -v "^$" | sort -u | while read line; do
101-
kubectl -n $line delete $NAMESPACED_TYPES -l "$LABEL_SELECTOR"
104+
kubectl $FAST_DELETE -n $line delete $NAMESPACED_TYPES -l "$LABEL_SELECTOR"
102105
done
103106

104107
# delete non-namespaced types
105108
local no_namespace_count=`grep -c -v " -n " $1`
106109
if [ ! "$no_namespace_count" = "0" ]; then
107-
kubectl delete $NOT_NAMESPACED_TYPES -l "$LABEL_SELECTOR"
110+
kubectl $FAST_DELETE delete $NOT_NAMESPACED_TYPES -l "$LABEL_SELECTOR"
108111
fi
109112

110113
echo "@@ Waiting for pods to stop running."
@@ -136,7 +139,7 @@ function deleteWithOneLabel {
136139
function deleteNamespaces {
137140
cat $1 | awk '{ print $4 }' | grep -v "^$" | sort -u | while read line; do
138141
if [ "$line" != "default" ]; then
139-
kubectl delete namespace $line --ignore-not-found
142+
kubectl $FAST_DELETE delete namespace $line --ignore-not-found
140143
fi
141144
done
142145

@@ -246,7 +249,7 @@ function genericDelete {
246249
return 0
247250
fi
248251

249-
if [ "$iteration" = "first" ]; then
252+
if [ "$iteration" = "first" ] && [ "$FAST_DELETE" = "" ]; then
250253
# in the first iteration we just wait to see if artifacts go away on there own
251254

252255
echo "@@ Waiting for $artcount_total artifacts to delete. Wait time $((mnow - mstart)) seconds (max=$maxwaitsecs). Waiting for:"
@@ -269,8 +272,8 @@ function genericDelete {
269272

270273
if [ ${artcount_no} -gt 0 ]; then
271274
cat "$resfile_no" | while read line; do
272-
echo "kubectl delete $line --ignore-not-found"
273-
kubectl delete $line --ignore-not-found
275+
echo "kubectl $FAST_DELETE delete $line --ignore-not-found"
276+
kubectl $FAST_DELETE delete $line --ignore-not-found
274277
done
275278
fi
276279

@@ -292,9 +295,9 @@ function genericDelete {
292295
}
293296

294297
function cleanup_tiller {
295-
kubectl -n kube-system delete deployment tiller-deploy --ignore-not-found=true
296-
kubectl delete clusterrolebinding tiller-cluster-rule --ignore-not-found=true
297-
kubectl -n kube-system delete serviceaccount tiller --ignore-not-found=true
298+
kubectl $FAST_DELETE -n kube-system delete deployment tiller-deploy --ignore-not-found=true
299+
kubectl $FAST_DELETE delete clusterrolebinding tiller-cluster-rule --ignore-not-found=true
300+
kubectl $FAST_DELETE -n kube-system delete serviceaccount tiller --ignore-not-found=true
298301
}
299302

300303
function fail {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM mysql:5.6
2+
3+
RUN groupadd -g 1000 oracle && \
4+
mkdir -p /u01 && \
5+
chmod a+xr /u01 && \
6+
useradd -b /u01 -d /u01/oracle -g 1000 -u 1000 -m -s /bin/bash oracle && \
7+
chown oracle:oracle -R /u01
8+
9+
USER oracle

src/integration-tests/introspector/README

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Internal Test Flow:
3333

3434
Cleanup files in /tmp/introspect
3535

36-
() Cleanup test k8s artifacts and (optionally) an old created domain.
36+
() Cleanup test k8s artifacts and any old created domain.
3737

3838
<operator-src>/src/integration-tests/bash/cleanup.sh
3939

@@ -42,21 +42,22 @@ Internal Test Flow:
4242
create-test-root-pv.yamlt, create-test-root-pvc.yamlt
4343
create-test-root.sh, create-test-root-job.yamlt
4444

45-
() Optionally deploy pv/pvc for use by introspector job, the optional domain create step, and wl pods. (If PV_COMMENT != "#").
45+
() Deploy pv/pvc for use by introspector job, the domain create step, and wl pods. (If PV_COMMENT != "#").
4646

4747
wl-pv.yamlt, wl-pvc.yamlt
4848

4949
() Deploy a secret for the admin credentials.
5050

5151
wl-secret.yamlt
5252

53-
() Optionally create a domain home. (If CREATE_DOMAIN == "true").
53+
() Create a domain home.
5454

55-
wl-job.yamlt, createDomain.sh, createDomain.pyt
55+
wl-create-domain-pod.yamlt, wl-create-domain-pod.sh, wl-create-domain-pod.pyt
5656

57-
() Run the introspector job.
57+
() Run the introspector job (as a direct pod instead of a job)
5858

59-
wl-job.yamlt
59+
wl-instrospect-pod.yamlt
60+
wl-instrospect-pod.sh
6061
<operator-src>/operator/src/main/resources/scripts/introspectDomain.sh
6162
<operator-src>/operator/src/main/resources/scripts/startNodeManager.sh
6263
<operator-src>/operator/src/main/resources/scripts/introspectDomain.py

src/integration-tests/introspector/checkBeans.inputt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
# Note that a customer/admin should never override a port, they must stay fixed
2626
/ServerTemplates/mycluster-template,ListenPort,8001,8001
2727

28-
/JDBCSystemResources/testDS/JDBCResource/testDS/JDBCDriverParams/testDS,Url,jdbc:oracle:thin:@myoriginalhostname:1521:myoriginalsid,jdbc:oracle:thin:@mynewhost:1521:mynewsid
28+
/JDBCSystemResources/testDS/JDBCResource/testDS/JDBCDriverParams/testDS,Url,jdbc:oracle:thin:@invalid-host:1521:invalid-sid,jdbc:oracle:thin:@mynewhost:1521:mynewsid
2929
/JDBCSystemResources/testDS/JDBCResource/testDS/JDBCDriverParams/testDS,PasswordEncrypted,*,!
30-
/JDBCSystemResources/testDS/JDBCResource/testDS/JDBCDriverParams/testDS/Properties/testDS/Properties/user,Value,scott,supersecret
30+
/JDBCSystemResources/testDS/JDBCResource/testDS/JDBCDriverParams/testDS/Properties/testDS/Properties/user,Value,invalid-user,supersecret
3131

32+
/JDBCSystemResources/mysqlDS/JDBCResource/mysqlDS/JDBCDriverParams/mysqlDS,Url,jdbc:mysql://invalid-host:3306/invalid-db-name,jdbc:mysql://${DOMAIN_UID}-mysql:3306/mysql
33+
/JDBCSystemResources/mysqlDS/JDBCResource/mysqlDS/JDBCDriverParams/mysqlDS,PasswordEncrypted,*,!
34+
/JDBCSystemResources/mysqlDS/JDBCResource/mysqlDS/JDBCDriverParams/mysqlDS/Properties/mysqlDS/Properties/user,Value,invalid-user,root
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright 2018, 2019, 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+
#
5+
# purpose:
6+
#
7+
# invoke on-line WLST to check if a datasource is working
8+
#
9+
# assumes the admin user/pass was encoded to a userConfig/userKey by the
10+
# introspector these files have been mounted to /weblogic-operator/introspector
11+
#
12+
# usage:
13+
# wlst.sh checkDataSource.py url server-name data-source-name
14+
#
15+
# sample usage:
16+
# wlst.sh checkDataSource.py t3://domain1-admin-server:7001 admin-server mysqlDS
17+
#
18+
19+
import sys
20+
21+
url = sys.argv[1]
22+
server_name = sys.argv[2]
23+
data_source_name = sys.argv[3]
24+
25+
connect(userConfigFile='/weblogic-operator/introspector/userConfigNodeManager.secure',userKeyFile='/tmp/userKeyNodeManager.secure.bin',url=url)
26+
27+
serverRuntime()
28+
29+
cd('/JDBCServiceRuntime/' + server_name + '/JDBCDataSourceRuntimeMBeans/' + data_source_name)
30+
31+
ret=cmo.testPool()
32+
33+
if ret is None:
34+
print 'ok'
35+
exit(exitcode=0)
36+
else:
37+
print 'error: ' + ret
38+
exit(exitcode=1)

src/integration-tests/introspector/create-test-root-job.yamlt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ spec:
2323
env:
2424
- name: DOMAIN_UID
2525
value: "${DOMAIN_UID}"
26+
- name: JAVA_OPTIONS
27+
value: "-Djava.security.egd=file:/dev/./urandom "
28+
- name: USER_MEM_ARGS
29+
value: "-Xms64m -Xmx256m "
2630
image: "${WEBLOGIC_IMAGE_NAME}:${WEBLOGIC_IMAGE_TAG}"
2731
imagePullPolicy: ${WEBLOGIC_IMAGE_PULL_POLICY}
2832
name: weblogic-server

src/integration-tests/introspector/createDomain.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/integration-tests/introspector/createTestRoot.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# This script runs inside a job (create-test-root-job.yamlt), it sets up the top
44
# level directory for this test that in turn is mounted as /shared by the
5-
# test's wl-pvc, wl-pv, wl-job, and wl-pod yamlt.
5+
# test's wl-pvc, wl-pv, wl-job, and wl-pod yamlt (plus similar 'mysql' yamlt).
66

77
# The 'acceptance_test_pv' directory it creates matches the directory
88
# expected by the integration test 'cleanup.sh' script.
@@ -11,6 +11,9 @@
1111
# create-test-root-pv.yamlt, and create-test-root-pvc.yamlt. It physically
1212
# corresponds to the PV_ROOT env var path specified as an input to the test.
1313

14-
mkdir -p /pv-root/acceptance_test_pv/domain-${DOMAIN_UID?}-storage || exit 1
14+
mkdir -p /pv-root/acceptance_test_pv/domain-${DOMAIN_UID?}-storage/domains || exit 1
15+
mkdir -p /pv-root/acceptance_test_pv/domain-${DOMAIN_UID?}-storage/mysql || exit 1
1516
chmod 777 /pv-root/acceptance_test_pv || exit 1
1617
chmod 777 /pv-root/acceptance_test_pv/domain-${DOMAIN_UID?}-storage || exit 1
18+
chmod 777 /pv-root/acceptance_test_pv/domain-${DOMAIN_UID?}-storage/domains || exit 1
19+
chmod 777 /pv-root/acceptance_test_pv/domain-${DOMAIN_UID?}-storage/mysql || exit 1

0 commit comments

Comments
 (0)