|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -x -o pipefail |
| 3 | + |
| 4 | +behave_tests_dir="gpMgmt/test/behave/mgmt_utils" |
| 5 | + |
| 6 | +# TODO concourse_cluster tests are not stable |
| 7 | +# clusters="concourse_cluster ~concourse_cluster,demo_cluster" |
| 8 | + |
| 9 | +clusters="~concourse_cluster" |
| 10 | + |
| 11 | +if [ $# -eq 0 ] |
| 12 | +then |
| 13 | + # TODO cross_subnet and gpssh tests are excluded |
| 14 | + features=`ls $behave_tests_dir -1 | grep feature | grep -v -E "cross_subnet|gpssh" | sed 's/\.feature$//'` |
| 15 | +else |
| 16 | + for feature in $@ |
| 17 | + do |
| 18 | + if [ ! -f "$behave_tests_dir/$feature.feature" ] |
| 19 | + then |
| 20 | + echo "Feature '$feature' doesn't exists" |
| 21 | + exit 1 |
| 22 | + fi |
| 23 | + done |
| 24 | + features=$@ |
| 25 | +fi |
| 26 | + |
| 27 | +processes=3 |
| 28 | + |
| 29 | +rm -rf allure-results |
| 30 | +mkdir allure-results -pm 777 |
| 31 | +mkdir ssh_keys -p |
| 32 | +if [ ! -e "ssh_keys/id_rsa" ] |
| 33 | +then |
| 34 | + ssh-keygen -P "" -f ssh_keys/id_rsa |
| 35 | +fi |
| 36 | + |
| 37 | +run_feature() { |
| 38 | + local feature=$1 |
| 39 | + local cluster=$2 |
| 40 | + if [ $cluster = "concourse_cluster" ]; then |
| 41 | + local project="${feature}_concourse" |
| 42 | + else |
| 43 | + local project="${feature}_demo" |
| 44 | + fi |
| 45 | + echo "Started $feature behave tests on cluster $cluster and project $project" |
| 46 | + docker-compose -p $project -f arenadata/docker-compose.yaml --env-file arenadata/.env up -d |
| 47 | + # Prepare ALL containers first |
| 48 | + local services=$(docker-compose -p $project -f arenadata/docker-compose.yaml config --services | tr '\n' ' ') |
| 49 | + for service in $services |
| 50 | + do |
| 51 | + docker-compose -p $project -f arenadata/docker-compose.yaml exec -T \ |
| 52 | + $service bash -c "mkdir -p /data/gpdata && chmod -R 777 /data && |
| 53 | + source gpdb_src/concourse/scripts/common.bash && install_gpdb && |
| 54 | + ./gpdb_src/concourse/scripts/setup_gpadmin_user.bash" & |
| 55 | + done |
| 56 | + wait |
| 57 | + |
| 58 | + # Add host keys to known_hosts after containers setup |
| 59 | + for service in $services |
| 60 | + do |
| 61 | + docker-compose -p $project -f arenadata/docker-compose.yaml exec -T \ |
| 62 | + $service bash -c "ssh-keyscan ${services/$service/} >> /home/gpadmin/.ssh/known_hosts" & |
| 63 | + done |
| 64 | + wait |
| 65 | + |
| 66 | + docker-compose -p $project -f arenadata/docker-compose.yaml exec -T \ |
| 67 | + -e FEATURE="$feature" -e BEHAVE_FLAGS="--tags $feature --tags=$cluster \ |
| 68 | + -f behave_utils.arenadata.formatter:CustomFormatter \ |
| 69 | + -o non-existed-output \ |
| 70 | + -f allure_behave.formatter:AllureFormatter \ |
| 71 | + -o /tmp/allure-results" \ |
| 72 | + cdw gpdb_src/arenadata/scripts/behave_gpdb.bash |
| 73 | + status=$? |
| 74 | + |
| 75 | + docker-compose -p $project -f arenadata/docker-compose.yaml --env-file arenadata/.env down -v |
| 76 | + |
| 77 | + if [[ $status > 0 ]]; then echo "Feature $feature failed with exit code $status"; fi |
| 78 | + exit $status |
| 79 | +} |
| 80 | + |
| 81 | +pids="" |
| 82 | +exits=0 |
| 83 | +for feature in $features |
| 84 | +do |
| 85 | + for cluster in $clusters |
| 86 | + do |
| 87 | + run_feature $feature $cluster & |
| 88 | + pids+="$! " |
| 89 | + if [[ $(jobs -r -p | wc -l) -ge $processes ]]; then |
| 90 | + wait -n |
| 91 | + ((exits += $?)) |
| 92 | + fi |
| 93 | + done |
| 94 | +done |
| 95 | +for pid in $pids |
| 96 | + do |
| 97 | + wait $pid |
| 98 | + exits=$((exits + $?)) |
| 99 | + done |
| 100 | +if [[ $exits > 0 ]]; then exit 1; fi |
0 commit comments