-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.sh
executable file
·151 lines (123 loc) · 4.43 KB
/
test.sh
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
#!/usr/bin/env bash
set -o errexit
# xtrace turned on only within the travis folds
start() { echo travis_fold':'start:$1; echo $1; set -v; }
end() { set +v; echo travis_fold':'end:$1; echo; echo; }
die() { set +v; echo "$*" 1>&2 ; exit 1; }
retry() {
TRIES=1
until curl --silent --fail http://localhost:$PORT/ > /dev/null; do
echo "$TRIES: not up yet"
if (( $TRIES > 10 )); then
$OPT_SUDO docker logs $CONTAINER_NAME
die "HTTP requests to app never succeeded"
fi
(( TRIES++ ))
sleep 1
done
}
PORT=8888
start test
PYTHONPATH=context python -m unittest discover -s tests --verbose
end test
start format
flake8 context || die "Run 'autopep8 --in-place -r context'"
end format
start isort
isort --recursive context --check-only || die "Run 'isort --recursive context'"
end isort
start pip
# Request from githubusercontent.com was failing...
#URL_BASE=https://raw.githubusercontent.com/refinery-platform/heatmap-scatter-dash/master
#DIFF_RAW=$(diff <(cat context/requirements.txt; \
# cat requirements-dev.txt) \
# <(curl --silent $URL_BASE/context/requirements.txt; \
# curl --silent $URL_BASE/requirements-dev.txt))
#DIFF_FREEZE=$(diff requirements-freeze.txt <(curl --silent $URL_BASE/requirements-freeze.txt))
#[ "$DIFF_RAW" ] && [ -z "$DIFF_FREEZE" ] && \
# die "If raw changes, freeze should change: '$DIFF_RAW'"
#[ -z "$DIFF_RAW" ] && [ "$DIFF_FREEZE" ] && \
# die "If freeze changes, raw should change: '$DIFF_FREEZE'"
end pip
start usage
diff <(perl -ne 'print if /^usage:/../^ --api_prefix/' README.md) \
<(cd context; ./app_runner.py -h) || \
die '
Update README.md:
perl -ne '"'"'print unless /^usage:/../^ --api_prefix/; print `cd context; ./app_runner.py -h` if /^usage:/'"'"' -i README.md'
end usage
start refinery_data_envvar
# Since the input.json specifies a data directory which might not exist,
# and we want to minimize changes to the host running the test,
# we will check the other modes with the docker tests.
FIXTURES_URL_BASE='https://raw.githubusercontent.com/refinery-platform/heatmap-scatter-dash/v0.1.3/fixtures'
FILE_URLS="$FIXTURES_URL_BASE/good/data/counts-copy.csv.gz" \
DATA_DIR='/tmp' \
python context/app_runner_refinery.py --input /no/such/file --port $PORT &
retry
kill `jobs -p`
end refinery_data_envvar
start cypress
diff fixtures/good/data/counts.csv \
<(gunzip --to-stdout fixtures/good/data/counts-copy.csv.gz) || \
die 'Zip file should match raw file'
python context/app_runner.py \
--files fixtures/good/data/counts* \
--diffs fixtures/good/data/stats-* \
--metas fixtures/good/data/metadata.* \
--port $PORT &
node_modules/.bin/cypress run
kill `jobs -p`
end cypress
start docker_build
source define_repo.sh
# We don't want to run the whole script under sudo on Travis,
# because then it gets the system python instead of the version
# we've specified.
OPT_SUDO=''
if [ ! -z "$TRAVIS" ]; then
OPT_SUDO='sudo'
fi
echo "REPO: $REPO"
echo "IMAGE: $IMAGE"
$OPT_SUDO docker pull $REPO
$OPT_SUDO docker build --cache-from $REPO --tag $IMAGE context
end docker_build
start docker_json_file
CONTAINER_NAME=$IMAGE-container
# Preferred syntax, Docker version >= 17.06
# --mount type=bind,src=$(pwd)/fixtures/good/input.json,dst=/data/input.json \
# --mount type=volume,target=/refinery-data/ \
$OPT_SUDO docker run --name $CONTAINER_NAME --detach --publish $PORT:80 \
--volume $(pwd)/fixtures/good/input.json:/data/input.json \
--volume /refinery-data/ \
$IMAGE
retry
docker stop $CONTAINER_NAME | xargs docker rm
end docker_json
start docker_json_envvar
INPUT_JSON=`cat $(pwd)/fixtures/good/input.json`
$OPT_SUDO docker run --name $CONTAINER_NAME --detach --publish $PORT:80 \
--volume /refinery-data/ \
-e "INPUT_JSON=$INPUT_JSON" \
$IMAGE
retry
docker stop $CONTAINER_NAME | xargs docker rm
end docker_json_envvar
start docker_json_url_envvar
INPUT_JSON_URL="$FIXTURES_URL_BASE/good/input.json"
$OPT_SUDO docker run --name $CONTAINER_NAME --detach --publish $PORT:80 \
--volume /refinery-data/ \
-e "INPUT_JSON_URL=$INPUT_JSON_URL" \
$IMAGE
retry
docker stop $CONTAINER_NAME | xargs docker rm
end docker_json_url_envvar
start docker_envvars
FILE_URLS="$FIXTURES_URL_BASE/good/data/counts.csv"
$OPT_SUDO docker run --name $CONTAINER_NAME --detach --publish $PORT:80 \
-e "FILE_URLS=$FILE_URLS" \
$IMAGE
retry
docker stop $CONTAINER_NAME | xargs docker rm
end docker_envvars