|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -o nounset |
| 4 | +set -o errexit |
| 5 | + |
| 6 | +declare -r tmp_file="$(mktemp)" |
| 7 | +declare -r script_arg="${1:-unset}" |
| 8 | + |
| 9 | +function onexit |
| 10 | +{ |
| 11 | + rm -vf "$tmp_file" |
| 12 | +} |
| 13 | + |
| 14 | +trap onexit EXIT |
| 15 | + |
| 16 | +function main |
| 17 | +{ |
| 18 | + # Note: if script_arg is kiex_cleanup, |
| 19 | + # this function exits early |
| 20 | + kiex_cleanup |
| 21 | + |
| 22 | + # Note: if script_arg is tests, |
| 23 | + # this function exits early |
| 24 | + maybe_run_tests "$@" |
| 25 | + |
| 26 | + ensure_directories |
| 27 | + ensure_kerl |
| 28 | + ensure_kiex |
| 29 | + ensure_make |
| 30 | + ensure_otp |
| 31 | +} |
| 32 | + |
| 33 | +function test_group_0 |
| 34 | +{ |
| 35 | + make ct-backing_queue |
| 36 | + make ct-channel_interceptor |
| 37 | + make ct-channel_operation_timeout |
| 38 | + make ct-cluster_formation_locking |
| 39 | +} |
| 40 | + |
| 41 | +function test_group_1 |
| 42 | +{ |
| 43 | + make ct-clustering_management |
| 44 | + make ct-cluster_rename |
| 45 | + make ct-cluster |
| 46 | + make ct-config_schema |
| 47 | +} |
| 48 | + |
| 49 | +function test_group_2 |
| 50 | +{ |
| 51 | + make ct-crashing_queues |
| 52 | + make ct-credential_validation |
| 53 | + make ct-disconnect_detected_during_alarm |
| 54 | + make ct-dynamic_ha |
| 55 | +} |
| 56 | + |
| 57 | +function test_group_3 |
| 58 | +{ |
| 59 | + make ct-eager_sync |
| 60 | + make ct-gm |
| 61 | + make ct-health_check |
| 62 | + make ct-lazy_queue |
| 63 | +} |
| 64 | + |
| 65 | +function test_group_4 |
| 66 | +{ |
| 67 | + make ct-list_consumers_sanity_check |
| 68 | + make ct-list_queues_online_and_offline |
| 69 | + make ct-many_node_ha |
| 70 | + make ct-metrics |
| 71 | +} |
| 72 | + |
| 73 | +function test_group_5 |
| 74 | +{ |
| 75 | + make ct-mirrored_supervisor |
| 76 | + make ct-msg_store |
| 77 | + # TODO FUTURE HACK |
| 78 | + # This suite fails frequently on Travis CI |
| 79 | + # make ct-partitions |
| 80 | + make ct-peer_discovery_dns |
| 81 | +} |
| 82 | + |
| 83 | +function test_group_6 |
| 84 | +{ |
| 85 | + make ct-per_user_connection_tracking |
| 86 | + make ct-per_vhost_connection_limit_partitions |
| 87 | + make ct-per_vhost_connection_limit |
| 88 | + make ct-per_vhost_msg_store |
| 89 | +} |
| 90 | + |
| 91 | +function test_group_7 |
| 92 | +{ |
| 93 | + make ct-per_vhost_queue_limit |
| 94 | + make ct-plugin_versioning |
| 95 | + make ct-policy |
| 96 | + make ct-priority_queue_recovery |
| 97 | +} |
| 98 | + |
| 99 | +function test_group_8 |
| 100 | +{ |
| 101 | + make ct-priority_queue |
| 102 | + make ct-proxy_protocol |
| 103 | + make ct-queue_master_location |
| 104 | + make ct-rabbit_core_metrics_gc |
| 105 | +} |
| 106 | + |
| 107 | +function test_group_9 |
| 108 | +{ |
| 109 | + make ct-rabbitmqctl_integration |
| 110 | + make ct-rabbitmqctl_shutdown |
| 111 | + make ct-simple_ha |
| 112 | + make ct-sup_delayed_restart |
| 113 | +} |
| 114 | + |
| 115 | +function test_group_10 |
| 116 | +{ |
| 117 | + make ct-sync_detection |
| 118 | + make ct-term_to_binary_compat_prop |
| 119 | + make ct-topic_permission |
| 120 | + make ct-unit_inbroker_non_parallel |
| 121 | +} |
| 122 | + |
| 123 | +function test_group_11 |
| 124 | +{ |
| 125 | + make ct-unit_inbroker_parallel |
| 126 | + make ct-unit |
| 127 | + make ct-worker_pool |
| 128 | +} |
| 129 | + |
| 130 | +function maybe_run_tests |
| 131 | +{ |
| 132 | + if [[ $script_arg == 'tests' ]] |
| 133 | + then |
| 134 | + # Note: Travis env specifies test suite number |
| 135 | + local -ri group="${2:-999}" |
| 136 | + |
| 137 | + local -r test_func="test_group_$group" |
| 138 | + "$test_func" |
| 139 | + |
| 140 | + # Only doing tests, so early exit |
| 141 | + exit 0 |
| 142 | + fi |
| 143 | +} |
| 144 | + |
| 145 | +function kiex_cleanup |
| 146 | +{ |
| 147 | + rm -vf "$HOME"/.kiex/bin/*.bak* |
| 148 | + rm -vf "$HOME"/.kiex/elixirs/.*.old |
| 149 | + rm -vf "$HOME"/.kiex/elixirs/*.old |
| 150 | + rm -vf "$HOME"/.kiex/scripts/*.bak* |
| 151 | + |
| 152 | + if [[ $script_arg == 'kiex_cleanup' ]] |
| 153 | + then |
| 154 | + # Only doing cleanup, so early exit |
| 155 | + exit 0 |
| 156 | + fi |
| 157 | +} |
| 158 | + |
| 159 | + |
| 160 | +function ensure_directories |
| 161 | +{ |
| 162 | + set +o errexit |
| 163 | + mkdir "$HOME/otp" |
| 164 | + mkdir "$HOME/bin" |
| 165 | + set -o errexit |
| 166 | + export PATH="$HOME/bin:$PATH" |
| 167 | +} |
| 168 | + |
| 169 | +function ensure_kerl |
| 170 | +{ |
| 171 | + curl -Lo "$HOME/bin/kerl" https://raw.githubusercontent.com/kerl/kerl/master/kerl |
| 172 | + chmod 755 "$HOME/bin/kerl" |
| 173 | +} |
| 174 | + |
| 175 | +function ensure_kiex |
| 176 | +{ |
| 177 | + curl -sSL https://raw.githubusercontent.com/taylor/kiex/master/install | /usr/bin/env bash -s |
| 178 | + local -r kiex_script="$HOME/.kiex/scripts/kiex" |
| 179 | + if [[ -s $kiex_script ]] |
| 180 | + then |
| 181 | + source "$kiex_script" |
| 182 | + # Note: this produces a lot of output but without running |
| 183 | + # "list known" first, kiex install ... sometimes fails |
| 184 | + kiex list known |
| 185 | + kiex_cleanup |
| 186 | + else |
| 187 | + echo "Did not find kiex at $kiex_script" 1>&2 |
| 188 | + exit 1 |
| 189 | + fi |
| 190 | +} |
| 191 | + |
| 192 | +function ensure_make |
| 193 | +{ |
| 194 | + # GNU Make build variables |
| 195 | + local -r make_install_dir="$HOME/gmake" |
| 196 | + local -r make_bin_dir="$make_install_dir/bin" |
| 197 | + |
| 198 | + export PATH="$make_bin_dir:$PATH" |
| 199 | + |
| 200 | + if [[ -x $make_bin_dir/make ]] |
| 201 | + then |
| 202 | + echo "Found GNU Make installation at $make_install_dir" |
| 203 | + else |
| 204 | + mkdir -p "$make_install_dir" |
| 205 | + curl -sLO http://ftp.gnu.org/gnu/make/make-4.2.1.tar.gz |
| 206 | + tar xf make-4.2.1.tar.gz |
| 207 | + pushd make-4.2.1 |
| 208 | + ./configure --prefix="$make_install_dir" |
| 209 | + make |
| 210 | + make install |
| 211 | + popd |
| 212 | + fi |
| 213 | +} |
| 214 | + |
| 215 | +function build_ticker |
| 216 | +{ |
| 217 | + local status |
| 218 | + |
| 219 | + status=$(< "$tmp_file") |
| 220 | + while [[ $status == 'true' ]] |
| 221 | + do |
| 222 | + echo '------------------------------------------------------------------------------------------------------------------------------------------------' |
| 223 | + echo "$(date) building $otp_tag_name ..." |
| 224 | + if ls "$otp_build_log_dir"/otp_build*.log > /dev/null |
| 225 | + then |
| 226 | + tail "$otp_build_log_dir"/otp_build*.log |
| 227 | + fi |
| 228 | + sleep 10 |
| 229 | + status=$(< "$tmp_file") |
| 230 | + done |
| 231 | + echo '.' |
| 232 | +} |
| 233 | + |
| 234 | +function ensure_otp |
| 235 | +{ |
| 236 | + # OTP build variables |
| 237 | + local -r otp_tag_name="$script_arg" |
| 238 | + local -r otp_build_log_dir="$HOME/.kerl/builds/$otp_tag_name" |
| 239 | + local -r otp_install_dir="$HOME/otp/$otp_tag_name" |
| 240 | + if [[ -s $otp_install_dir/activate ]] |
| 241 | + then |
| 242 | + echo "Found OTP installation at $otp_install_dir" |
| 243 | + else |
| 244 | + export KERL_CONFIGURE_OPTIONS='--enable-hipe --enable-smp-support --enable-threads --enable-kernel-poll' |
| 245 | + rm -rf "$otp_install_dir" |
| 246 | + mkdir -p "$otp_install_dir" |
| 247 | + |
| 248 | + echo -n 'true' > "$tmp_file" |
| 249 | + build_ticker & |
| 250 | + kerl build git https://github.com/erlang/otp.git "$otp_tag_name" "$otp_tag_name" |
| 251 | + echo -n 'false' > "$tmp_file" |
| 252 | + wait |
| 253 | + |
| 254 | + kerl install "$otp_tag_name" "$otp_install_dir" |
| 255 | + fi |
| 256 | +} |
| 257 | + |
| 258 | +main "$@" |
0 commit comments