forked from ComboStrikeHQ/docker-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·51 lines (40 loc) · 1.18 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
#!/bin/bash -xe
function testapp_run() {
if ! docker-compose run app "$@"; then
echo "Test '$@' failed!"
exit 1
fi
}
cd test
rm -rf testapp
# Set up testing rails app
gem install bundler rails
rails new testapp -d mysql -m template.rb --skip-bundle
cd testapp; bundle lock; cd ..
cp -r files/* testapp
# Build container
docker-compose kill
docker-compose rm -f
docker-compose build
docker-compose up -d
# Check that app server boots correctly, ENV variables are exposed and sidekiq works properly
if [ "$DOCKER_MACHINE_NAME" != "" ]; then
HOST=$(docker-machine ip $DOCKER_MACHINE_NAME)
fi
RESULT=$(wget -O - --retry-connrefused -T 60 http://${HOST:-localhost}:8080/)
[ "$RESULT" == "ok" ] || exit 1
# Clean up
docker-compose stop
# Check that imagemagick is present
testapp_run which convert
# Check that ruby uses jemalloc
testapp_run bash -c "ldd /usr/local/bin/ruby |grep jemalloc"
# Check that openssl/readline is working in ruby
testapp_run ruby -r readline -e puts
testapp_run ruby -r openssl -e puts
# Check that nodejs, npm and bower are present
RESULT=$(testapp_run node -p '1+1')
[[ "$RESULT" == "2"* ]] || exit 1
testapp_run npm -v
testapp_run bower -v
echo "Tests OK"