diff options
author | 2021-05-10 15:36:30 -0400 | |
---|---|---|
committer | 2021-05-20 14:52:37 -0400 | |
commit | 0b3d50f77e3b4122bafd4b8f396e86d5135c2b5a (patch) | |
tree | a1be4a178a856fcaf8af64b8fecb7c956a7291cd /csit/run-project-csit.sh | |
parent | 21adf7bca98f9cbf721b825b03c60352e1a0ccf0 (diff) |
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 <jrh3@att.com>
(cherry picked from commit 3486a9218bc8d396dce8cdde32d0b1e38490bacf)
Signed-off-by: Ram Krishna Verma <ram_krishna.verma@bell.ca>
Diffstat (limited to 'csit/run-project-csit.sh')
-rwxr-xr-x | csit/run-project-csit.sh | 75 |
1 files changed, 41 insertions, 34 deletions
diff --git a/csit/run-project-csit.sh b/csit/run-project-csit.sh index 8c020b12..702c4020 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 git://gerrit-mirror-ap.onap.org/mirror/policy/${PROJECT}.git` ; 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" @@ -182,29 +189,29 @@ cd "${WORKDIR}" docker login -u docker -p docker nexus3.onap.org:10001 # 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} |