Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Make necessary fixes to get v14 out of pre-release mode
Configure test_qa for new images
Add npm for tests that need it
Check for patched werkzeug version only in versions < 14.0
Fix test_addons_env for 11.0 - 13.0
New openupgrade_scripts only exists from 14.0
Enable all tests already working in 15.0
Make dependency test for base_search_fuzzy a separate test. This enables us to run all other dependency tests with 15.0 already

Co-authored-by: Andreas Perhab <[email protected]>
  • Loading branch information
joao-p-marques and ap-wtioit committed Oct 13, 2021
1 parent 74ba134 commit 7803131
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 35 deletions.
92 changes: 59 additions & 33 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# preparing the pre-release for the next version of Odoo, which hasn't been
# released yet.
prerelease_skip = unittest.skipIf(
ODOO_VERSIONS & {"14.0", "15.0"}, "Tests not supported in pre-release"
ODOO_VERSIONS & {"15.0"}, "Tests not supported in pre-release"
)


Expand Down Expand Up @@ -191,23 +191,27 @@ def test_addons_filtered(self):
("bash", "-xc", 'test "$(addons list -cWsale)" == crm'),
)

@prerelease_skip
def test_qa(self):
"""Test that QA tools are in place and work as expected."""
folder = join(SCAFFOLDINGS_DIR, "settings")
commands = (
("./custom/scripts/qa-insider-test",),
("/qa/node_modules/.bin/eslint", "--version"),
("/qa/venv/bin/flake8", "--version"),
("/qa/venv/bin/pylint", "--version"),
("/qa/venv/bin/python", "--version"),
("/qa/venv/bin/python", "-c", "import pylint_odoo"),
("test", "-d", "/qa/mqt"),
)
commands = (("./custom/scripts/qa-insider-test",),)
for sub_env in matrix():
# Images up to v12 (inclusive) still had QA/NodeJS dependencies.
# Check if they are correctly installed.
if float(sub_env["ODOO_MINOR"]) < 13:
commands += (
("/qa/node_modules/.bin/eslint", "--version"),
("/qa/venv/bin/flake8", "--version"),
("/qa/venv/bin/pylint", "--version"),
("/qa/venv/bin/python", "-c", "import pylint_odoo"),
)
if sub_env["ODOO_MINOR"] != "11.0":
commands += (("/qa/node_modules/.bin/eslint", "--env-info"),)
commands += (("/qa/venv/bin/python", "--version"),)
if float(sub_env["ODOO_MINOR"]) < 14:
commands += (("test", "-d", "/qa/mqt"),)
self.compose_test(folder, sub_env, *commands)

@prerelease_skip
def test_settings(self):
"""Test settings are filled OK"""
folder = join(SCAFFOLDINGS_DIR, "settings")
Expand Down Expand Up @@ -301,7 +305,9 @@ def test_smallest(self):
def test_addons_env(self):
"""Test environment variables in addons.yaml"""
# The test is hacking ODOO_VERSION to pin a commit
for sub_env in matrix():
# It uses OCA/OpenUpgrade as base for Odoo, which won't work from v14
# and onwards as it no longer is a fork from Odoo
for sub_env in matrix(odoo={"11.0", "12.0", "13.0"}):
self.compose_test(
join(SCAFFOLDINGS_DIR, "addons_env"),
sub_env,
Expand All @@ -313,10 +319,20 @@ def test_addons_env(self):
("test", "-e", "auto/addons/crm"),
("test", "-d", "auto/addons/crm/migrations"),
)
for sub_env in matrix(odoo_skip={"11.0", "12.0", "13.0"}):
self.compose_test(
join(SCAFFOLDINGS_DIR, "addons_env_ou"),
sub_env,
# check module from custom repo pattern
("test", "-d", "custom/src/misc-addons"),
("test", "-d", "custom/src/misc-addons/web_debranding"),
("test", "-e", "auto/addons/web_debranding"),
# Migrations folder
("test", "-e", "auto/addons/openupgrade_scripts"),
("test", "-d", "auto/addons/openupgrade_scripts/scripts"),
)

# HACK https://github.com/itpp-labs/misc-addons/issues/1014
# TODO Remove decorator
@prerelease_skip
def test_addons_env_double(self):
"""Test double addon reference in addons.yaml"""
common_tests = (
Expand Down Expand Up @@ -384,8 +400,6 @@ def test_dotd(self):
("--version",),
)

# TODO Remove decorator when base_search_fuzzy is migrated to 14.0
@prerelease_skip
def test_dependencies(self):
"""Test dependencies installation."""
dependencies_dir = join(SCAFFOLDINGS_DIR, "dependencies")
Expand All @@ -397,17 +411,6 @@ def test_dependencies(self):
("test", "!", "-f", "custom/dependencies/gem.txt"),
("test", "!", "-f", "custom/dependencies/npm.txt"),
("test", "!", "-f", "custom/dependencies/pip.txt"),
# It should have base_search_fuzzy available
("test", "-d", "custom/src/server-tools/base_search_fuzzy"),
# Patched Werkzeug version
(
"bash",
"-xc",
(
'test "$(python -c "import werkzeug; '
'print(werkzeug.__version__)")" == 0.14.1'
),
),
# apt_build.txt
("test", "-f", "custom/dependencies/apt_build.txt"),
("test", "!", "-e", "/usr/sbin/sshd"),
Expand All @@ -418,11 +421,7 @@ def test_dependencies(self):
("test", "-f", "custom/dependencies/070-apt-bc.txt"),
("test", "-e", "/usr/bin/bc"),
# 150-npm-aloha_world-install.txt
(
"test",
"-f",
("custom/dependencies/" "150-npm-aloha_world-install.txt"),
),
("test", "-f", "custom/dependencies/150-npm-aloha_world-install.txt"),
("node", "-e", "require('test-npm-install')"),
# 200-pip-without-ext
("test", "-f", "custom/dependencies/200-pip-without-ext"),
Expand All @@ -432,6 +431,33 @@ def test_dependencies(self):
("test", "-f", "custom/dependencies/270-gem.txt"),
("hello-world",),
)
if float(sub_env["ODOO_MINOR"]) < 14:
self.compose_test(
dependencies_dir,
sub_env,
# For odoo versions < 14.0 we make sure we have a patched Werkzeug version
(
"bash",
"-xc",
(
'test "$(python -c "import werkzeug; '
'print(werkzeug.__version__)")" == 0.14.1'
),
),
)

# TODO Remove decorator when base_search_fuzzy is migrated to 15.0
@prerelease_skip
def test_dependencies_base_search_fuzzy(self):
"""Test dependencies installation."""
dependencies_dir = join(SCAFFOLDINGS_DIR, "dependencies_base_search_fuzzy")
for sub_env in matrix():
self.compose_test(
dependencies_dir,
sub_env,
# It should have base_search_fuzzy available
("test", "-d", "custom/src/server-tools/base_search_fuzzy"),
)

def test_modified_uids(self):
"""tests if we can build an image with a custom uid and gid of odoo"""
Expand Down
2 changes: 2 additions & 0 deletions tests/scaffoldings/addons_env_ou/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ARG ODOO_VERSION
FROM tecnativa/doodba:${ODOO_VERSION}-onbuild
16 changes: 16 additions & 0 deletions tests/scaffoldings/addons_env_ou/custom/src/addons.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
server-tools:
- module_auto_update
OpenUpgrade:
- openupgrade_scripts
---
ENV:
DEFAULT_REPO_PATTERN_ODOO: https://github.com/OCA/OCB.git
odoo/addons:
- crm
- sale
---
ENV:
DEFAULT_REPO_PATTERN: https://github.com/itpp-labs/{}.git
ODOO_VERSION: 554222498d5101ef59fc4d3e1059e2b407dffd6f
misc-addons:
- web_debranding
29 changes: 29 additions & 0 deletions tests/scaffoldings/addons_env_ou/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: "2.1"
services:
odoo:
build:
context: ./
args:
COMPILE: "false"
ODOO_VERSION: $ODOO_MINOR
WITHOUT_DEMO: "false"
tty: true
depends_on:
- db
environment:
PYTHONOPTIMIZE: ""
UNACCENT: "false"
volumes:
- filestore:/var/lib/odoo:z

db:
image: postgres:${DB_VERSION}-alpine
environment:
POSTGRES_USER: odoo
POSTGRES_PASSWORD: odoopassword
volumes:
- db:/var/lib/postgresql/data:z

volumes:
db:
filestore:
2 changes: 0 additions & 2 deletions tests/scaffoldings/dependencies/custom/src/addons.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
server-tools:
- base_search_fuzzy
2 changes: 2 additions & 0 deletions tests/scaffoldings/dependencies_base_search_fuzzy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ARG ODOO_VERSION
FROM tecnativa/doodba:${ODOO_VERSION}-onbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server-tools:
- base_search_fuzzy
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: "2.1"
services:
odoo:
build:
context: ./
args:
COMPILE: "false"
ODOO_VERSION: $ODOO_MINOR
WITHOUT_DEMO: "false"
tty: true
depends_on:
- db
environment:
PYTHONOPTIMIZE: ""
UNACCENT: "false"
volumes:
- filestore:/var/lib/odoo:z

db:
image: postgres:${DB_VERSION}-alpine
environment:
POSTGRES_USER: odoo
POSTGRES_PASSWORD: odoopassword
volumes:
- db:/var/lib/postgresql/data:z

volumes:
db:
filestore:

0 comments on commit 7803131

Please sign in to comment.