forked from koding/koding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-tests
More file actions
executable file
·45 lines (32 loc) · 877 Bytes
/
Copy pathrun-tests
File metadata and controls
executable file
·45 lines (32 loc) · 877 Bytes
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
#!/bin/bash
SCRIPTS=$(dirname $0)/..
TASKS="nodeservertests socialworkertests"
INSTANCE_DATA_FILE=$1
INSTANCE_COUNT=$(wc -l $INSTANCE_DATA_FILE | awk '{print $1}')
OUTPUT_DIR=$(mktemp -d)
function run_task() {
TASK=$1
HOST=$(echo $2 | awk '{print $2}')
OUTFILE=$OUTPUT_DIR/$TASK.log
$SCRIPTS/test-instance/ssh \
$HOST "MOCHA_VERBOSE=1 /opt/koding/run $TASK" \
2>&1 >$OUTFILE
EXIT_CODE=$?
echo $EXIT_CODE >$OUTPUT_DIR/$TASK.exit_code
}
LINE_NUMBER=0
for TASK in $TASKS; do
LINE_NUMBER=$(($LINE_NUMBER + 1))
INSTANCE=$(sed -n "${LINE_NUMBER}p" $INSTANCE_DATA_FILE)
run_task $TASK "$INSTANCE" &
LINE_NUMBER=$(($LINE_NUMBER % $INSTANCE_COUNT))
done
wait
EXIT_CODE=0
for TASK in $TASKS; do
cat $OUTPUT_DIR/$TASK.log
TASK_EXIT_CODE=$(cat $OUTPUT_DIR/$TASK.exit_code)
[ $TASK_EXIT_CODE -eq 0 ] && continue
EXIT_CODE=$TASK_EXIT_CODE
done
exit $EXIT_CODE