summaryrefslogtreecommitdiff
path: root/.travis.sh
blob: f5f786b9071dc5607bb3b54e98e8561ace3e184b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#!/usr/bin/env bash

set -o nounset
set -o errexit

declare -r tmp_file="$(mktemp)"
declare -r script_arg="${1:-unset}"

function onexit
{
    rm -vf "$tmp_file"
}

trap onexit EXIT

function main
{
    # Note: if script_arg is kiex_cleanup,
    # this function exits early
    kiex_cleanup

    # Note: if script_arg is tests,
    # this function exits early
    maybe_run_tests "$@"

    ensure_directories
    ensure_kerl
    ensure_kiex
    ensure_make
    ensure_otp
}

function test_group_0
{
    make ct-backing_queue
    make ct-channel_interceptor
    make ct-channel_operation_timeout
    make ct-cluster_formation_locking
}

function test_group_1
{
    make ct-clustering_management
    make ct-cluster_rename
    make ct-cluster
    make ct-config_schema
}

function test_group_2
{
    make ct-crashing_queues
    make ct-credential_validation
    make ct-disconnect_detected_during_alarm
    make ct-dynamic_ha
}

function test_group_3
{
    make ct-eager_sync
    make ct-gm
    make ct-health_check
    make ct-lazy_queue
}

function test_group_4
{
    make ct-list_consumers_sanity_check
    make ct-list_queues_online_and_offline
    make ct-many_node_ha
    make ct-metrics
}

function test_group_5
{
    make ct-mirrored_supervisor
    make ct-msg_store
    # TODO FUTURE HACK
    # This suite fails frequently on Travis CI
    # make ct-partitions
    make ct-peer_discovery_dns
}

function test_group_6
{
    make ct-per_user_connection_tracking
    make ct-per_vhost_connection_limit_partitions
    make ct-per_vhost_connection_limit
    make ct-per_vhost_msg_store
}

function test_group_7
{
    make ct-per_vhost_queue_limit
    make ct-plugin_versioning
    make ct-policy
    make ct-priority_queue_recovery
}

function test_group_8
{
    make ct-priority_queue
    make ct-proxy_protocol
    make ct-queue_master_location
    make ct-rabbit_core_metrics_gc
}

function test_group_9
{
    make ct-rabbitmqctl_integration
    make ct-rabbitmqctl_shutdown
    make ct-simple_ha
    make ct-sup_delayed_restart
}

function test_group_10
{
    make ct-sync_detection
    make ct-term_to_binary_compat_prop
    make ct-topic_permission
    make ct-unit_inbroker_non_parallel
}

function test_group_11
{
    make ct-unit_inbroker_parallel
    make ct-unit
    make ct-worker_pool
}

function maybe_run_tests
{
    if [[ $script_arg == 'tests' ]]
    then
        # Note: Travis env specifies test suite number
        local -ri group="${2:-999}"

        local -r test_func="test_group_$group"
        "$test_func"

        # Only doing tests, so early exit
        exit 0
    fi
}

function kiex_cleanup
{
    rm -vf "$HOME"/.kiex/bin/*.bak*
    rm -vf "$HOME"/.kiex/elixirs/.*.old
    rm -vf "$HOME"/.kiex/elixirs/*.old
    rm -vf "$HOME"/.kiex/scripts/*.bak*

    if [[ $script_arg == 'kiex_cleanup' ]]
    then
        # Only doing cleanup, so early exit
        exit 0
    fi
}


function ensure_directories
{
    set +o errexit
    mkdir "$HOME/otp"
    mkdir "$HOME/bin"
    set -o errexit
    export PATH="$HOME/bin:$PATH"
}

function ensure_kerl
{
    curl -Lo "$HOME/bin/kerl"  https://raw.githubusercontent.com/kerl/kerl/master/kerl
    chmod 755 "$HOME/bin/kerl"
}

function ensure_kiex
{
    curl -sSL https://raw.githubusercontent.com/taylor/kiex/master/install | /usr/bin/env bash -s
    local -r kiex_script="$HOME/.kiex/scripts/kiex"
    if [[ -s $kiex_script ]]
    then
        source "$kiex_script"
        # Note: this produces a lot of output but without running
        # "list known" first, kiex install ... sometimes fails
        kiex list known
        kiex_cleanup
    else
        echo "Did not find kiex at $kiex_script" 1>&2
        exit 1
    fi
}

function ensure_make
{
    # GNU Make build variables
    local -r make_install_dir="$HOME/gmake"
    local -r make_bin_dir="$make_install_dir/bin"

    export PATH="$make_bin_dir:$PATH"

    if [[ -x $make_bin_dir/make ]]
    then
        echo "Found GNU Make installation at $make_install_dir"
    else
        mkdir -p "$make_install_dir"
        curl -sLO http://ftp.gnu.org/gnu/make/make-4.2.1.tar.gz
        tar xf make-4.2.1.tar.gz
        pushd make-4.2.1
        ./configure --prefix="$make_install_dir"
        make
        make install
        popd
    fi
}

function build_ticker
{
    local status

    status=$(< "$tmp_file")
    while [[ $status == 'true' ]]
    do
        echo '------------------------------------------------------------------------------------------------------------------------------------------------'
        echo "$(date) building $otp_tag_name ..."
        if ls "$otp_build_log_dir"/otp_build*.log > /dev/null
        then
            tail "$otp_build_log_dir"/otp_build*.log
        fi
        sleep 10
        status=$(< "$tmp_file")
    done
    echo '.'
}

function ensure_otp
{
    # OTP build variables
    local -r otp_tag_name="$script_arg"
    local -r otp_build_log_dir="$HOME/.kerl/builds/$otp_tag_name"
    local -r otp_install_dir="$HOME/otp/$otp_tag_name"
    if [[ -s $otp_install_dir/activate ]]
    then
        echo "Found OTP installation at $otp_install_dir"
    else
        export KERL_CONFIGURE_OPTIONS='--enable-hipe --enable-smp-support --enable-threads --enable-kernel-poll'
        rm -rf "$otp_install_dir"
        mkdir -p "$otp_install_dir"

        echo -n 'true' > "$tmp_file"
        build_ticker &
        kerl build git https://github.com/erlang/otp.git "$otp_tag_name" "$otp_tag_name"
        echo -n 'false' > "$tmp_file"
        wait

        kerl install "$otp_tag_name" "$otp_install_dir"
    fi
}

main "$@"