Skip to content

Commit 6db2f8c

Browse files
committed
Add a test case for reclaim policy "recycle"
Signed-off-by: Dongbo Xiao <[email protected]>
1 parent b49dcef commit 6db2f8c

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

src/integration-tests/bash/cleanup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ OCOUNT=${#OPER_NAMESPACES[@]}
5151
SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
5252
PROJECT_ROOT="$SCRIPTPATH/../../.."
5353
RESULT_ROOT=${RESULT_ROOT:-/scratch/$USER/wl_k8s_test_results}
54+
PV_ROOT=${PV_ROOT:-$RESULT_ROOT}
5455
RESULT_DIR="$RESULT_ROOT/acceptance_test_tmp"
5556
USER_PROJECTS_DIR="$RESULT_DIR/user-projects"
5657
TMP_DIR="$RESULT_DIR/cleanup_tmp"

src/integration-tests/bash/run.sh

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ function state_dump {
383383
# use a job to archive PV, /scratch mounts to PV_ROOT in the K8S cluster
384384
trace "Archiving pv directory using a kubernetes job. Look for it on k8s cluster in $PV_ROOT/acceptance_test_pv_archive"
385385
local outfile=${DUMP_DIR}/archive_pv_job.out
386-
$SCRIPTPATH/job.sh "/scripts/archive.sh $PV_ROOT/acceptance_test_pv $PV_ROOT/acceptance_test_pv_archive" > ${outfile} 2>&1
386+
$SCRIPTPATH/job.sh "/scripts/archive.sh /scratch/acceptance_test_pv /scratch/acceptance_test_pv_archive" > ${outfile} 2>&1
387387
if [ "$?" = "0" ]; then
388388
trace Job complete.
389389
else
@@ -768,12 +768,17 @@ function run_create_domain_job {
768768
sed -i -e "s/^configuredManagedServerCount:.*/configuredManagedServerCount: 3/" $inputs
769769
fi
770770

771+
# we will test pv reclaim policy in domain6. We choose to do this way to void adding too many parameters in dom_define
772+
if [ "$DOMAIN_UID" == "domain6" ] ; then
773+
sed -i -e "s/^weblogicDomainStorageReclaimPolicy:.*/weblogicDomainStorageReclaimPolicy: Recycle/" $inputs
774+
fi
775+
771776
local outfile="${tmp_dir}/mkdir_physical_nfs.out"
772777
trace "Use a job to create the k8s host directory \"$PV_ROOT/acceptance_test_pv/$DOMAIN_STORAGE_DIR\" that we will use for the domain's persistent volume, see \"$outfile\" for job tracing."
773778

774779
# Note that the job.sh job mounts PV_ROOT to /scratch and runs as UID 1000,
775780
# so PV_ROOT must already exist and have 777 or UID=1000 permissions.
776-
$SCRIPTPATH/job.sh "mkdir -p $PV_ROOT/acceptance_test_pv/$DOMAIN_STORAGE_DIR" > ${outfile} 2>&1
781+
$SCRIPTPATH/job.sh "mkdir -p /scratch/acceptance_test_pv/$DOMAIN_STORAGE_DIR" > ${outfile} 2>&1
777782
if [ "$?" = "0" ]; then
778783
cat ${outfile} | sed 's/^/+/g'
779784
trace Job complete. Directory created on k8s cluster.
@@ -2250,6 +2255,32 @@ function test_create_domain_startup_control_admin {
22502255
declare_test_pass
22512256
}
22522257

2258+
2259+
function test_create_domain_pv_reclaim_policy_recycle {
2260+
declare_new_test 1 "$@"
2261+
2262+
if [ "$#" != 1 ] ; then
2263+
fail "requires 1 parameters: domainKey"
2264+
fi
2265+
2266+
local DOM_KEY=${1}
2267+
local DOMAIN_UID="`dom_get $1 DOMAIN_UID`"
2268+
local NAMESPACE="`dom_get $1 NAMESPACE`"
2269+
2270+
run_create_domain_job $DOMAIN_UID
2271+
verify_domain_created $DOMAIN_UID
2272+
shutdown_domain $DOM_KEY
2273+
2274+
kubectl delete pvc ${DOMAIN_UID}-weblogic-domain-pvc -n $NAMESPACE
2275+
2276+
local count=`kubectl get pv $DOMAIN_UID-weblogic-domain-pv -n $NAMESPACE |grep "^$DOMAIN_UID " | wc -l `
2277+
if [ ${count:=Error} != 0 ] ; then
2278+
fail "ERROR: pv for $DOMAIN_UID still exists after the pvc is deleted, exiting!"
2279+
fi
2280+
2281+
declare_test_pass
2282+
}
2283+
22532284
# scale domain $1 up and down, and optionally verify the scaling had no effect on domain $2
22542285
function test_cluster_scale {
22552286
declare_new_test 1 "$@"
@@ -2453,7 +2484,7 @@ function test_suite_init {
24532484
# 777 is needed because this script, k8s pods, and/or jobs may need access.
24542485

24552486
/usr/local/packages/aime/ias/run_as_root "mkdir -p $RESULT_ROOT/acceptance_test_tmp"
2456-
/usr/local/packages/aime/ias/run_as_root "chmod 777 $RESULTPV_ROOT/acceptance_test_tmp"
2487+
/usr/local/packages/aime/ias/run_as_root "chmod 777 $RESULT_ROOT/acceptance_test_tmp"
24572488

24582489
/usr/local/packages/aime/ias/run_as_root "mkdir -p $RESULT_ROOT/acceptance_test_tmp_archive"
24592490
/usr/local/packages/aime/ias/run_as_root "chmod 777 $RESULT_ROOT/acceptance_test_tmp_archive"
@@ -2524,6 +2555,7 @@ function test_suite {
25242555
dom_define domain3 oper1 test1 domain3 AUTO cluster-1 managed-server 7021 30041 30703 8031 30307 30317
25252556
dom_define domain4 oper2 test2 domain4 AUTO cluster-1 managed-server 7041 30051 30704 8041 30308 30318
25262557
dom_define domain5 oper1 default domain5 ADMIN cluster-1 managed-server 7051 30061 30705 8051 30309 30319
2558+
dom_define domain6 oper1 default domain6 AUTO cluster-1 managed-server 7061 30071 30706 8061 30310 30320
25272559

25282560
# create namespaces for domains (the operator job creates a namespace if needed)
25292561
# TODO have the op_define commands themselves create target namespace if it doesn't already exist, or test if the namespace creation is needed in the first place, and if so, ask MikeG to create them as part of domain create job
@@ -2588,9 +2620,12 @@ function test_suite {
25882620
# cycle domain1 down and back up, plus verify no impact on domain4
25892621
test_domain_lifecycle domain1 domain4
25902622

2591-
# create another domain in the default namespace with startupControl="ADMIN", and verify that only admin server is created
2623+
# create domain5 in the default namespace with startupControl="ADMIN", and verify that only admin server is created
25922624
test_create_domain_startup_control_admin domain5
25932625

2626+
# create domain6 in the default namespace with pvReclaimPolicy="Recycle", and verify that the PV is deleted once the domain and PVC are deleted
2627+
test_create_domain_pv_reclaim_policy_recycle domain6
2628+
25942629
# test managed server 1 pod auto-restart
25952630
test_wls_liveness_probe domain1
25962631

src/test/scripts/unit-test-generate-weblogic-operator-cert.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ fi
2020

2121
script_dir="$( cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 ; pwd -P)"
2222

23+
2324
CERT_DIR="${script_dir}/weblogic-operator-cert"
2425
OP_PREFIX="weblogic-operator"
2526
OP_CERT_PEM="${CERT_DIR}/${OP_PREFIX}.cert.pem"

0 commit comments

Comments
 (0)