Commit c3b1b2ca authored by gprasath's avatar gprasath

Including functional tests into packet pipeline

Signed-off-by: 's avatargprasath <giridhara.prasad@cloudbyte.com>
parent ea50e4e9
......@@ -159,6 +159,16 @@ volume-data-integrity-{fio-jiva}:
script:
- ./script/apps/fio/tests/jiva/fio-volume-data-integrity-check
volume-memory-consumption-{memcheck-jiva}:
extends: .func_test_template
script:
- ./script/apps/memleak/tests/jiva/memory-consumption
snapshot-clone-creation-{percona-jiva}:
extends: .func_test_template
script:
- ./script/apps/percona/functional/jiva/k8s-snapshot-clone
## Define job template for chaos jobs
.chaos_test_template:
......
#!/bin/bash
set -x
#################
## ENVIRONMENT ##
#################
## TODO: Ideally, run_metadata should be passed as gitlab runner (CI runtime) ENV
run_metadata=""
## https://github.com/openebs/litmus/blob/master/apps/fio/tests/data-integrity/test_vars.yml
test_name="memleak-test"
if [[ -n "$run_metadata" ]]; then
test_name="$test_name-$run_metadata"
fi
################
## FUNCTIONS ##
################
error_handler()
{
rc=$1; message=$(echo $2 | cut -d "=" -f 2); act=$(echo $3 | cut -d "=" -f 2)
if [ $rc -ne 0 ]; then
echo "$message"
if [ "$act" == "exit" ]; then
exit 1
fi
fi
}
task_delimiter()
{
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "%"
}
###################
## DEPENDENCIES ##
###################
## Derive the kubeconfig of the packet cluster into the gitlab job runner pod
echo "Setting up test dependencies.."
mkdir ~/.kube
cp -r openebs-packet/.kube/. ~/.kube/
git clone https://github.com/openebs/litmus.git
cd litmus
task_delimiter;
############################
## LITMUS PRECONDITIONING ##
############################
## TODO: Add logic to replace job ENV (SC, PVC, LABEL, NS) based on run instance intent
## TODO: Add logic to add ENV for run_instance_metadata/RunID
#Test
#################
## RUNNER MAIN ##
#################
echo "Running the litmus test.."
## Create the litmus job for fio data integrity test
jobNameCmd="kubectl get jobs -n litmus --no-headers -o jsonpath='{.items[?(@.metadata.labels.app==\"memleak-test\")].metadata.name}'"
job_deploy_out=$(kubectl create -f apps/memleak/tests/run_litmus_test.yml) && \
job_name=$(eval $jobNameCmd); retcode=$?
error_handler $retcode msg="Unable to run litmusbook, exiting" action="exit"
## Obtain the litmus pod name
litmusPodCmd="kubectl get pod --no-headers -n litmus -o jsonpath='{.items[?(@.metadata.labels.job-name==\"$job_name\")].metadata.name}'"
litmus_pod=$(eval $litmusPodCmd); retcode=$?
error_handler $retcode msg="Unable to find litmus test runner pod, exiting" action="exit"
## Wait till the ansibletest container terminates && also confirm job completion status. This is done to ensure
## that execution of auxiliary containers such as loggers is completed. Getting the ansibletest ccontainer to completed state
## satisfies the "necessary" condition for test job completion
containerStateCmd="kubectl get pod ${litmus_pod} -n litmus -o jsonpath='{.status.containerStatuses[?(@.name==\"ansibletest\")].state}'"
jobStateCmd="kubectl get pod ${litmus_pod} --no-headers -n litmus -o custom-columns=:status.phase"
## TODO: Consider cases where litmus pod is evicted
while [[ ! $(eval $containerStateCmd) =~ 'terminated' ]]; do
sleep 1
done
while [[ $(eval $jobStateCmd) =~ 'Running' ]]; do
sleep 1
done
echo "Litmus test run Job has completed"
task_delimiter;
## Printing the test logs & cluster state for debug purposes
echo "Dumping Litmus test pod logs for debug"; echo ""
kubectl logs $litmus_pod -n litmus -c ansibletest
task_delimiter;
echo "Dumping state of cluster post job run"; echo ""
kubectl get pods --all-namespaces
kubectl get pvc --all-namespaces
kubectl get sc
task_delimiter;
## Check the test status & result from the litmus result custom resource
testStatus=$(kubectl get lr $test_name --no-headers -o custom-columns=:spec.testStatus.phase) && \
testResult=$(kubectl get lr $test_name --no-headers -o custom-columns=:spec.testStatus.result); retcode=$?
error_handler $retcode msg="Unable to find litmus result custom resource, exiting" action="exit"
if [[ $testStatus == "completed" ]]; then
if [[ $testResult == "Pass" ]]; then
echo "TEST: PASS"
else
echo "TEST: FAILED"; exit 1
fi
else
echo "Test Execution was aborted"; exit 1
fi
#!/bin/bash
set -x
#################
## ENVIRONMENT ##
#################
## TODO: Ideally, run_metadata should be passed as gitlab runner (CI runtime) ENV
run_metadata=""
## https://github.com/openebs/litmus/blob/master/apps/percona/functional/k8s_snapshot/test_vars.yml
test_name="create-k8s-snapshot-clone"
if [[ -n "$run_metadata" ]]; then
test_name="$test_name-$run_metadata"
fi
################
## FUNCTIONS ##
################
error_handler()
{
rc=$1; message=$(echo $2 | cut -d "=" -f 2); act=$(echo $3 | cut -d "=" -f 2)
if [ $rc -ne 0 ]; then
echo "$message"
if [ "$act" == "exit" ]; then
exit 1
fi
fi
}
task_delimiter()
{
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "%"
}
###################
## DEPENDENCIES ##
###################
## Derive the kubeconfig of the packet cluster into the gitlab job runner pod
echo "Setting up test dependencies.."
mkdir ~/.kube
cp -r openebs-packet/.kube/. ~/.kube/
## Clone the litmus repo, checkout the e2e branch, navigate to litmus root
git clone https://github.com/openebs/litmus.git
cd litmus
task_delimiter;
############################
## LITMUS PRECONDITIONING ##
############################
## TODO: Add logic to replace job ENV (SC, PVC, LABEL, NS) based on run instance intent
## TODO: Add logic to add ENV for run_instance_metadata/RunID
#################
## RUNNER MAIN ##
#################
echo "Running the litmus test.."
## Create the litmus job for cassandra app func test: scale-app-replicas
jobNameCmd="kubectl get jobs -n litmus --no-headers -o jsonpath='{.items[?(@.metadata.labels.app==\"k8s-snapshot-litmus\")].metadata.name}'"
job_deploy_out=$(kubectl create -f apps/percona/functional/k8s_snapshot/run_litmus_test.yml) && \
job_name=$(eval $jobNameCmd); retcode=$?
error_handler $retcode msg="Unable to run litmusbook, exiting" action="exit"
## Obtain the litmus pod name
litmusPodCmd="kubectl get pod --no-headers -n litmus -o jsonpath='{.items[?(@.metadata.labels.job-name==\"$job_name\")].metadata.name}'"
litmus_pod=$(eval $litmusPodCmd); retcode=$?
error_handler $retcode msg="Unable to find litmus test runner pod, exiting" action="exit"
## Wait till the ansibletest container terminates && also confirm job completion status. This is done to ensure
## that execution of auxiliary containers such as loggers is completed. Getting the ansibletest ccontainer to completed state
## satisfies the "necessary" condition for test job completion
containerStateCmd="kubectl get pod ${litmus_pod} -n litmus -o jsonpath='{.status.containerStatuses[?(@.name==\"ansibletest\")].state}'"
jobStateCmd="kubectl get pod ${litmus_pod} --no-headers -n litmus -o custom-columns=:status.phase"
## TODO: Consider cases where litmus pod is evicted
while [[ ! $(eval $containerStateCmd) =~ 'terminated' ]]; do
sleep 1
done
while [[ $(eval $jobStateCmd) =~ 'Running' ]]; do
sleep 1
done
echo "Litmus test run Job has completed"
task_delimiter;
## Printing the test logs & cluster state for debug purposes
echo "Dumping Litmus test pod logs for debug"; echo ""
kubectl logs $litmus_pod -n litmus -c ansibletest
task_delimiter;
echo "Dumping state of cluster post job run"; echo ""
kubectl get pods --all-namespaces
kubectl get pvc --all-namespaces
kubectl get sc
task_delimiter;
## Check the test status & result from the litmus result custom resource
testStatus=$(kubectl get litmusresult $test_name --no-headers -o custom-columns=:spec.testStatus.phase) && \
testResult=$(kubectl get litmusresult $test_name --no-headers -o custom-columns=:spec.testStatus.result); retcode=$?
error_handler $retcode msg="Unable to find litmus result custom resource, exiting" action="exit"
if [[ $testStatus == "completed" ]]; then
if [[ $testResult == "Pass" ]]; then
echo "TEST: PASS"
else
echo "TEST: FAILED"; exit 1
fi
else
echo "Test Execution was aborted"; exit 1
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment