-
Notifications
You must be signed in to change notification settings - Fork 335
/
Copy pathcircle_parallel
executable file
·70 lines (60 loc) · 2.42 KB
/
circle_parallel
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
#!/usr/bin/env bash
set -e -u -x
# Always run the lint tests on the first node (since these are quick and only
# need to be run on a single node).
if [ "$CIRCLE_NODE_INDEX" -eq "0" ]; then
make lint
fi
# Split up the tests between the available CI testing nodes.
#
# Our Rails tests will run on one node. The rest of our gatekeeper and
# integration tests will be split up among the remaining nodes.
#
# See: https://circleci.com/docs/parallel-manual-setup
# If we have multiple test node, split the tests among all the nodes except the
# first (the first is dedicated to the Rails tests).
#
# If we don't have multiple nodes, run all the tests on the single node
if [ "$CIRCLE_NODE_INDEX" -gt "0" ] || [ "$CIRCLE_NODE_TOTAL" -lt "2" ]; then
mocha_node_total="$CIRCLE_NODE_TOTAL"
mocha_node_index="$CIRCLE_NODE_INDEX"
if [ "$CIRCLE_NODE_TOTAL" -gt "1" ]; then
# Subtract 1 from the totals available, since the first is being used only
# for Rails.
((mocha_node_total=mocha_node_total-1)) || true
((mocha_node_index=mocha_node_index-1)) || true
fi
# Split the test files into even groups depending on how many nodes are
# available.
index=0
node_files=()
for test_file in $(cd test && find ./server ./integration -name "*.js" | sort); do
if [ $((index % mocha_node_total)) -eq $mocha_node_index ]; then
node_files+=("$test_file")
fi
((index=index+1)) || true
done
# Run the integration/gatekeeper tests.
make test-proxy MOCHA_FILES="${node_files[*]}"
# Also run the analytics specific proxy tests against Elasticsearch v2 for
# compatibility.
last_node=$((CIRCLE_NODE_TOTAL-1))
if [ "$CIRCLE_NODE_INDEX" -eq "$last_node" ]; then
API_UMBRELLA_CONFIG="test/config/test.yml:test/config/test_elasticsearch2.yml" ./test/node_modules/.bin/mocha test/integration/logging.js
fi
fi
# Run the Rails tests on the first node.
if [ "$CIRCLE_NODE_INDEX" -eq "0" ]; then
make test-web-app
# Also run the analytics specific web tests against Elasticsearch v2 for
# compatibility.
cd src/api-umbrella/web-app && \
env \
PATH="../../../build/work/stage/opt/api-umbrella/embedded/bin:$PATH" \
INTEGRATION_TEST_SUITE=true \
PRECOMPILE_TEST_ASSETS=false \
API_UMBRELLA_CONFIG="../../../test/config/test.yml:../../../test/config/test_elasticsearch2.yml" \
bundle exec rspec \
spec/controllers/admin/stats_controller_spec.rb \
spec/controllers/api/v1/analytics_controller_spec.rb
fi