From 3486a9218bc8d396dce8cdde32d0b1e38490bacf Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 10 May 2021 15:36:30 -0400 Subject: Merge csits into docker/csit Decided to move CSIT test source code from the individual repos into the docker repo. This review modifies the scripts to begin the process, and includes the CSIT code from xacml-pdp, as the first one to move. Note: while the xacml-pdp files are new to the docker repo, they are not actually new, thus their licenses were retained. Issue-ID: POLICY-3299 Change-Id: I7cce548ceec38c9c1615af883f08eb118e84d132 Signed-off-by: Jim Hahn --- csit/run-project-csit.sh | 75 ++++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 34 deletions(-) (limited to 'csit/run-project-csit.sh') diff --git a/csit/run-project-csit.sh b/csit/run-project-csit.sh index 07b9dea2..e9c75851 100755 --- a/csit/run-project-csit.sh +++ b/csit/run-project-csit.sh @@ -27,17 +27,17 @@ function on_exit(){ rc=$? if [[ ${WORKSPACE} ]]; then if [[ ${WORKDIR} ]]; then - rsync -av "$WORKDIR/" "$WORKSPACE/csit/archives/$TESTPLAN" + rsync -av "${WORKDIR}/" "${WORKSPACE}/csit/archives/${PROJECT}" fi # Record list of active docker containers - docker ps --format "{{.Image}}" > "$WORKSPACE/csit/archives/$TESTPLAN/_docker-images.log" + docker ps --format "{{.Image}}" > "${WORKSPACE}/csit/archives/${PROJECT}/_docker-images.log" # show memory consumption after all docker instances initialized - docker_stats | tee "$WORKSPACE/csit/archives/$TESTPLAN/_sysinfo-2-after-robot.txt" + docker_stats | tee "${WORKSPACE}/csit/archives/${PROJECT}/_sysinfo-2-after-robot.txt" fi # Run teardown script plan if it exists - cd "${TESTPLANDIR}/csit/plans/" - TEARDOWN="${TESTPLANDIR}/csit/plans/teardown.sh" + cd "${TESTPLANDIR}/plans/" + TEARDOWN="${TESTPLANDIR}/plans/teardown.sh" if [ -f "${TEARDOWN}" ]; then echo "Running teardown script ${TEARDOWN}" source_safely "${TEARDOWN}" @@ -72,7 +72,7 @@ function docker_stats(){ # save current set options function save_set() { RUN_CSIT_SAVE_SET="$-" - RUN_CSIT_SHELLOPTS="$SHELLOPTS" + RUN_CSIT_SHELLOPTS="${SHELLOPTS}" } # load the saved set options @@ -80,10 +80,10 @@ function load_set() { _setopts="$-" # bash shellopts - for i in $(echo "$SHELLOPTS" | tr ':' ' ') ; do + for i in $(echo "${SHELLOPTS}" | tr ':' ' ') ; do set +o ${i} done - for i in $(echo "$RUN_CSIT_SHELLOPTS" | tr ':' ' ') ; do + for i in $(echo "${RUN_CSIT_SHELLOPTS}" | tr ':' ' ') ; do set -o ${i} done @@ -132,7 +132,7 @@ then exit 1 fi -if [ -z "$WORKSPACE" ]; then +if [ -z "${WORKSPACE}" ]; then export WORKSPACE=$(git rev-parse --show-toplevel) fi @@ -145,29 +145,36 @@ export ROBOT_VARIABLES= source ${SCRIPTS}/get-branch-mariadb.sh export PROJECT="${1}" -rm -rf ${WORKSPACE}/${PROJECT} -mkdir ${WORKSPACE}/${PROJECT} + cd ${WORKSPACE} -# get the plan from git clone -if ! `git clone -b ${GERRIT_BRANCH} --single-branch https://github.com/onap/policy-${PROJECT}.git ${PROJECT}` ; then - echo "repo not found: policy/${PROJECT}" - exit 1 -fi +case "${PROJECT}" in +xacml-pdp) + export TESTPLANDIR="${WORKSPACE}/csit/${PROJECT}" + ;; +*) + export TESTPLANDIR="${WORKSPACE}/${PROJECT}/csit" -if [ -f "${WORKSPACE}/${1}/csit/plans/testplan.txt" ]; then - export TESTPLAN="${1}" -else - echo "testplan not found: ${WORKSPACE}/${1}/csit/plans/testplan.txt" - exit 2 -fi + rm -rf ${WORKSPACE}/${PROJECT} + mkdir ${WORKSPACE}/${PROJECT} -export TESTOPTIONS="${2}" + # get the plan from git clone + if ! `git clone -b ${GERRIT_BRANCH} --single-branch https://github.com/onap/policy-${PROJECT}.git ${PROJECT}` ; then + echo "repo not found: policy/${PROJECT}" + exit 1 + fi -rm -rf "$WORKSPACE/csit/archives/$TESTPLAN" -mkdir -p "$WORKSPACE/csit/archives/$TESTPLAN" + if [ ! -f "${TESTPLANDIR}/plans/testplan.txt" ]; then + echo "testplan not found: ${TESTPLANDIR}/plans/testplan.txt" + exit 2 + fi + ;; +esac -TESTPLANDIR="${WORKSPACE}/${TESTPLAN}" +export TESTOPTIONS="${2}" + +rm -rf "${WORKSPACE}/csit/archives/${PROJECT}" +mkdir -p "${WORKSPACE}/csit/archives/${PROJECT}" # Run installation of prerequired libraries source_safely "${SCRIPTS}/prepare-csit.sh" @@ -187,29 +194,29 @@ cp ${SCRIPTS}/config/ks.jks ${SCRIPTS}/config/drools/custom/policy-keystore cp ${SCRIPTS}/config/ks.jks ${SCRIPTS}/config/drools-apps/custom/policy-keystore # Run setup script plan if it exists -cd "${TESTPLANDIR}/csit/plans/" -SETUP="${TESTPLANDIR}/csit/plans/setup.sh" +cd "${TESTPLANDIR}/plans/" +SETUP="${TESTPLANDIR}/plans/setup.sh" if [ -f "${SETUP}" ]; then echo "Running setup script ${SETUP}" source_safely "${SETUP}" fi # show memory consumption after all docker instances initialized -docker_stats | tee "$WORKSPACE/csit/archives/$TESTPLAN/_sysinfo-1-after-setup.txt" +docker_stats | tee "${WORKSPACE}/csit/archives/${PROJECT}/_sysinfo-1-after-setup.txt" # Run test plan -cd "$WORKDIR" +cd "${WORKDIR}" echo "Reading the testplan:" -cat "${TESTPLANDIR}/csit/plans/testplan.txt" | egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' | sed "s|^|${TESTPLANDIR}/csit/tests/|" > testplan.txt +cat "${TESTPLANDIR}/plans/testplan.txt" | egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' | sed "s|^|${TESTPLANDIR}/tests/|" > testplan.txt cat testplan.txt SUITES=$( xargs -a testplan.txt ) echo ROBOT_VARIABLES="${ROBOT_VARIABLES}" echo "Starting Robot test suites ${SUITES} ..." relax_set -python -m robot.run -N ${TESTPLAN} -v WORKSPACE:/tmp ${ROBOT_VARIABLES} ${SUITES} +python -m robot.run -N ${PROJECT} -v WORKSPACE:/tmp ${ROBOT_VARIABLES} ${SUITES} RESULT=$? load_set -echo "RESULT: $RESULT" +echo "RESULT: ${RESULT}" # Note that the final steps are done in on_exit function after this exit! -exit $RESULT +exit ${RESULT} -- cgit 1.2.3-korg