forked from camptocamp/docker-odoo-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·108 lines (86 loc) · 3.07 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
#!/bin/bash
set -Eeuo pipefail
#
# Run tests on the image
#
# It assumes the image already exists.
# Normally run by the Makefile:
#
# $ make VERSION=$VERSION build
# $ make VERSION=$VERSION test
#
# It expects the following variables to be set:
#
# * VERSION (9.0, 10.0, 11.0, ...)
# * IMAGE_LATEST (tag of the 'latest' image built)
#
if [ -z "$VERSION" ]; then
echo "VERSION environment variable is missing"
exit 1
fi
ODOO_URL="https://github.com/odoo/odoo/archive/${VERSION}.tar.gz"
TMP=$(mktemp -d)
echo "Working in $TMP"
on_exit() {
echo "Cleaning up temporary directory..."
cd $TMP
docker-compose -f test-compose.yml down
rm -rf $TMP
rm -f /tmp/odoo.tar.gz
}
trap on_exit EXIT
# run 'runtests' in the container
# extra arguments are passed to the 'run' command (example: -e FOO=bar is added to the list of args)
docoruntests() {
docker-compose -f test-compose.yml run --rm -e LOCAL_USER_ID=$(id -u) $@ odoo runtests
}
# run 'runmigration' in the container
# extra arguments are passed to the 'run' command (example: -e FOO=bar is added to the list of args)
docorunmigration() {
docker-compose -f test-compose.yml run --rm -e LOCAL_USER_ID=$(id -u) $@ odoo runmigration
}
docodown() {
docker-compose -f test-compose.yml down
}
docoruncmd() {
docker-compose -f test-compose.yml run --rm -e LOCAL_USER_ID=$(id -u) $@
}
cp -ra ./example/. "$TMP/"
cd "$TMP"
echo '>>> Downloading Odoo src'
rm -rf "$TMP/odoo/src"
wget -nv -O /tmp/odoo.tar.gz "$ODOO_URL"
tar xfz /tmp/odoo.tar.gz -C odoo/
mv "odoo/odoo-$VERSION" odoo/src
echo '>>> Run test for base image'
sed "s|FROM .*|FROM ${IMAGE_LATEST}|" -i odoo/Dockerfile
mkdir .cachedb
echo '>>> * migration: standard'
docoruncmd -e LOAD_DB_CACHE="false" odoo odoo --stop-after-init
echo '>>> * migration: create the dump for a base version'
docorunmigration -v ${TMP}/.cachedb:/.cachedb -e CREATE_DB_CACHE="true"
docoruncmd odoo dropdb odoodb
echo '>>> * migration: use the dump and migrate to new version'
docorunmigration -v ${TMP}/.cachedb:/.cachedb -e LOAD_DB_CACHE="true"
docodown
echo " - version: 9.0.1" >> odoo/migration.yml
echo " operations:">> odoo/migration.yml
echo " post:" >> odoo/migration.yml
echo " - anthem songs.install.demo::create_partners" >> odoo/migration.yml
docoruncmd odoo dropdb odoodb
echo '>>> * migration: use a ceil version'
docoruntests -v ${TMP}/.cachedb:/.cachedb -e LOAD_DB_CACHE="true" -e MIG_LOAD_VERSION_CEIL="9.0.1"
echo '>>> * run unit tests with runtests'
docoruntests -e LOAD_DB_CACHE="false" -e CREATE_DB_CACHE="false"
echo '>>> * run unit tests with runtests and create a dump'
docoruntests -v ${TMP}/.cachedb:/.cachedb -e CREATE_DB_CACHE="true" -e SUBS_MD5=testcache
echo '>>> * run unit tests with runtests and re-use a dump'
docoruntests -v ${TMP}/.cachedb:/.cachedb -e LOAD_DB_CACHE="true" -e SUBS_MD5=testcache
docodown
echo '>>> * run tests for onbuild image'
cp odoo/Dockerfile-onbuild odoo/Dockerfile
sed "s|FROM .*|FROM ${IMAGE_LATEST}-onbuild|" -i odoo/Dockerfile
cat odoo/Dockerfile
docoruncmd odoo odoo --stop-after-init
docoruntests
docodown