diff options
Diffstat (limited to 'csit/run-project-csit.sh')
-rwxr-xr-x | csit/run-project-csit.sh | 121 |
1 files changed, 67 insertions, 54 deletions
diff --git a/csit/run-project-csit.sh b/csit/run-project-csit.sh index 8183cdee..e355d5ff 100755 --- a/csit/run-project-csit.sh +++ b/csit/run-project-csit.sh @@ -18,6 +18,23 @@ # limitations under the License. # +# even with forced finish, clean up docker containers +function on_exit(){ + rm -rf ${CSAR_DIR}/csar_temp.csar + + # teardown of compose containers for acm-replicas doesn't work with normal stop-compose script + if [ "${ACM_REPLICA_TEARDOWN}" = true ]; then + source ${DOCKER_COMPOSE_DIR}/start-acm-replica.sh --stop --replicas=2 + elif [ "${APEX_REPLICA_TEARDOWN}" = true ]; then + source ${DOCKER_COMPOSE_DIR}/start-multiple-pdp.sh --stop --replicas=2 + else + source ${DOCKER_COMPOSE_DIR}/stop-compose.sh ${PROJECT} + fi + + mv ${DOCKER_COMPOSE_DIR}/*.log ${ROBOT_LOG_DIR} + exit $RC +} + function docker_stats(){ # General memory details if [ "$(uname -s)" == "Darwin" ] @@ -40,11 +57,41 @@ function docker_stats(){ echo } +function apex_healthcheck() { + sleep 20 + + healthy=false + + while [ $healthy = false ] + do + msg=`curl -s -k --user 'policyadmin:zb!XztG34' http://localhost:${APEX_PORT}/policy/apex-pdp/v1/healthcheck` + echo "${msg}" | grep -q true + if [ "${?}" -eq 0 ] + then + healthy=true + break + fi + sleep 10s + done + + if [ $healthy = false ]; then + exit 2 + fi +} + +function check_rest_endpoint() { + bash ${SCRIPTS}/wait_for_rest.sh localhost "${1}" + rc=$? + if [ $rc -ne 0 ]; then + on_exit + fi +} + function setup_clamp() { export ROBOT_FILES="policy-clamp-test.robot clamp-slas.robot" source ${DOCKER_COMPOSE_DIR}/start-compose.sh policy-clamp-runtime-acm --grafana sleep 30 - bash ${SCRIPTS}/wait_for_rest.sh localhost "${ACM_PORT}" + check_rest_endpoint "${ACM_PORT}" } function setup_clamp_replica() { @@ -56,31 +103,32 @@ function setup_clamp_replica() { echo "Waiting a minute for the replicas to be started..." sleep 60 # checking on apex-pdp status because acm-r replicas only start after apex-pdp is running - bash ${SCRIPTS}/wait_for_rest.sh localhost ${APEX_PORT} + check_rest_endpoint ${PAP_PORT} + check_rest_endpoint ${APEX_PORT} apex_healthcheck - bash ${SCRIPTS}/wait_for_rest.sh localhost ${ACM_PORT} + check_rest_endpoint ${ACM_PORT} } function setup_api() { export ROBOT_FILES="api-test.robot api-slas.robot" source ${DOCKER_COMPOSE_DIR}/start-compose.sh api --grafana sleep 10 - bash ${SCRIPTS}/wait_for_rest.sh localhost ${API_PORT} + check_rest_endpoint ${API_PORT} } function setup_pap() { export ROBOT_FILES="pap-test.robot pap-slas.robot" source ${DOCKER_COMPOSE_DIR}/start-compose.sh apex-pdp --grafana sleep 10 - bash ${SCRIPTS}/wait_for_rest.sh localhost ${PAP_PORT} + check_rest_endpoint ${PAP_PORT} } function setup_apex() { export ROBOT_FILES="apex-pdp-test.robot apex-slas.robot" source ${DOCKER_COMPOSE_DIR}/start-compose.sh apex-pdp --grafana sleep 10 - bash ${SCRIPTS}/wait_for_rest.sh localhost ${PAP_PORT} - bash ${SCRIPTS}/wait_for_rest.sh localhost ${APEX_PORT} + check_rest_endpoint ${PAP_PORT} + check_rest_endpoint ${APEX_PORT} apex_healthcheck } @@ -89,8 +137,8 @@ function setup_apex_medium() { export APEX_REPLICA_TEARDOWN=true source ${DOCKER_COMPOSE_DIR}/start-multiple-pdp.sh --start --replicas=3 sleep 10 - bash ${SCRIPTS}/wait_for_rest.sh localhost ${PAP_PORT} - bash ${SCRIPTS}/wait_for_rest.sh localhost ${APEX_PORT} + check_rest_endpoint ${PAP_PORT} + check_rest_endpoint ${APEX_PORT} apex_healthcheck } @@ -99,52 +147,34 @@ function setup_apex_large() { export APEX_REPLICA_TEARDOWN=true source ${DOCKER_COMPOSE_DIR}/start-multiple-pdp.sh --start --replicas=10 sleep 10 - bash ${SCRIPTS}/wait_for_rest.sh localhost ${PAP_PORT} - bash ${SCRIPTS}/wait_for_rest.sh localhost ${APEX_PORT} + check_rest_endpoint ${PAP_PORT} + check_rest_endpoint ${APEX_PORT} apex_healthcheck } -function apex_healthcheck() { - sleep 20 - - healthy=false - - while [ $healthy = false ] - do - msg=`curl -s -k --user 'policyadmin:zb!XztG34' http://localhost:${APEX_PORT}/policy/apex-pdp/v1/healthcheck` - echo "${msg}" | grep -q true - if [ "${?}" -eq 0 ] - then - healthy=true - break - fi - sleep 10s - done -} - function setup_drools_apps() { export ROBOT_FILES="drools-applications-test.robot drools-applications-slas.robot" source ${DOCKER_COMPOSE_DIR}/start-compose.sh drools-applications --grafana sleep 10 - bash ${SCRIPTS}/wait_for_rest.sh localhost ${PAP_PORT} + check_rest_endpoint ${PAP_PORT} sleep 10 - bash ${SCRIPTS}/wait_for_rest.sh localhost ${DROOLS_APPS_PORT} + check_rest_endpoint ${DROOLS_APPS_PORT} sleep 10 - bash ${SCRIPTS}/wait_for_rest.sh localhost ${DROOLS_APPS_TELEMETRY_PORT} + check_rest_endpoint ${DROOLS_APPS_TELEMETRY_PORT} } function setup_xacml_pdp() { export ROBOT_FILES="xacml-pdp-test.robot xacml-pdp-slas.robot" source ${DOCKER_COMPOSE_DIR}/start-compose.sh xacml-pdp --grafana sleep 10 - bash ${SCRIPTS}/wait_for_rest.sh localhost "${XACML_PORT}" + check_rest_endpoint "${XACML_PORT}" } function setup_drools_pdp() { export ROBOT_FILES="drools-pdp-test.robot" - source ${DOCKER_COMPOSE_DIR}/start-compose.sh drools-pdp + source ${DOCKER_COMPOSE_DIR}/start-compose.sh drools-pdp --grafana sleep 30 - bash ${SCRIPTS}/wait_for_rest.sh localhost ${DROOLS_TELEMETRY_PORT} + check_rest_endpoint ${DROOLS_TELEMETRY_PORT} } function setup_distribution() { @@ -155,9 +185,9 @@ function setup_distribution() { sudo mkdir /tmp/distribution export ROBOT_FILES="distribution-test.robot" - source ${DOCKER_COMPOSE_DIR}/start-compose.sh distribution + source ${DOCKER_COMPOSE_DIR}/start-compose.sh distribution --grafana sleep 10 - bash ${SCRIPTS}/wait_for_rest.sh localhost "${DIST_PORT}" + check_rest_endpoint "${DIST_PORT}" } function build_robot_image() { @@ -229,23 +259,6 @@ function set_project_config() { esac } -# even with forced finish, clean up docker containers -function on_exit(){ - rm -rf ${CSAR_DIR}/csar_temp.csar - - # teardown of compose containers for acm-replicas doesn't work with normal stop-compose script - if [ "${ACM_REPLICA_TEARDOWN}" = true ]; then - source ${DOCKER_COMPOSE_DIR}/start-acm-replica.sh --stop --replicas=2 - elif [ "${APEX_REPLICA_TEARDOWN}" = true ]; then - source ${DOCKER_COMPOSE_DIR}/start-multiple-pdp.sh --stop --replicas=2 - else - source ${DOCKER_COMPOSE_DIR}/stop-compose.sh ${PROJECT} - fi - - mv ${DOCKER_COMPOSE_DIR}/*.log ${ROBOT_LOG_DIR} - exit $RC -} - # ensure that teardown and other finalizing steps are always executed trap on_exit EXIT |