Skip to content

Commit

Permalink
[FIX] Not use python-dev on v17, and v16
Browse files Browse the repository at this point in the history
 -This is because it is incompatible with debian bookworm
  • Loading branch information
josep-tecnativa committed Nov 16, 2023
1 parent e749153 commit ae8c0c9
Show file tree
Hide file tree
Showing 42 changed files with 376 additions and 3 deletions.
200 changes: 197 additions & 3 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,115 @@ def compose_test(self, workdir, sub_env, *commands):

def test_addons_filtered(self):
"""Test addons filtering with ``ONLY`` keyword in ``addons.yaml``."""
project_dir = join(SCAFFOLDINGS_DIR, "dotd_ge_16")
for sub_env in matrix(odoo_skip={"16.0", "17.0"}):
self.compose_test(
project_dir,
dict(sub_env, DBNAME="prod"),
("test", "-e", "auto/addons/web"),
("test", "-e", "auto/addons/private_addon"),
(
"bash",
"-xc",
'test "$(addons list -p)" == disabled_addon,private_addon',
),
("bash", "-xc", 'test "$(addons list -ip)" == private_addon'),
("bash", "-xc", "addons list -c | grep ,crm,"),
# absent_addon is missing and should fail
("bash", "-xc", "! addons list -px"),
# Test addon inclusion, exclusion, dependencies...
(
"bash",
"-xc",
'test "$(addons list -dw private_addon)" == base,dummy_addon,website',
),
(
"bash",
"-xc",
'test "$(addons list -dwprivate_addon -Wwebsite)" == base,dummy_addon',
),
(
"bash",
"-xc",
'test "$(addons list -dw private_addon -W dummy_addon)" == base,website',
),
(
"bash",
"-xc",
'test "$(addons list -nd)" == base,iap',
),
(
"bash",
"-xc",
'test "$(addons list --enterprise)" == make_odoo_rich',
),
)
self.compose_test(
project_dir,
dict(sub_env, DBNAME="limited_private"),
("test", "-e", "auto/addons/web"),
("test", "!", "-e", "auto/addons/private_addon"),
("bash", "-xc", 'test -z "$(addons list -p)"'),
(
"bash",
"-xc",
'[ "$(addons list -s. -pwfake1 -wfake2)" == fake1.fake2 ]',
),
("bash", "-xc", "! addons list -wrepeat -Wrepeat"),
("bash", "-xc", "addons list -c | grep ,crm,"),
)
self.compose_test(
project_dir,
dict(sub_env, DBNAME="limited_core"),
("test", "!", "-e", "auto/addons/web"),
("test", "!", "-e", "auto/addons/private_addon"),
("bash", "-xc", 'test -z "$(addons list -p)"'),
("bash", "-xc", 'test "$(addons list -c)" == crm,sale'),
)
self.compose_test(
project_dir,
dict(sub_env, DBNAME="prod"),
("bash", "-xc", 'test "$(addons list -ped)" == base,web,website'),
# ``dummy_addon`` and ``private_addon`` exist
("test", "-d", "auto/addons/dummy_addon"),
("test", "-h", "auto/addons/dummy_addon"),
("test", "-f", "auto/addons/dummy_addon/__init__.py"),
("test", "-e", "auto/addons/dummy_addon"),
# Addon from extra repo takes higher priority than core version
("realpath", "auto/addons/product"),
(
"bash",
"-xc",
'test "$(realpath auto/addons/product)" == '
"/opt/odoo/custom/src/other-doodba/odoo/src/private/product",
),
("bash", "-xc", 'test "$(addons list -e)" == dummy_addon,product'),
)
self.compose_test(
project_dir,
dict(sub_env, DBNAME="limited_private"),
("test", "-e", "auto/addons/dummy_addon"),
("bash", "-xc", 'test "$(addons list -e)" == dummy_addon,product'),
)
self.compose_test(
project_dir,
dict(sub_env, DBNAME="limited_core"),
("test", "-e", "auto/addons/dummy_addon"),
(
"bash",
"-xc",
'[ "$(addons list -s. -pwfake1 -wfake2)" == fake1.fake2 ]',
),
("bash", "-xc", 'test "$(addons list -e)" == dummy_addon,product'),
("bash", "-xc", 'test "$(addons list -c)" == crm,sale'),
("bash", "-xc", 'test "$(addons list -cWsale)" == crm'),
)

def test_addons_filtered_ge_16(self):
"""Test addons filtering with ``ONLY`` keyword in ``addons.yaml``.
Only for versions greater or equal to 16"""
project_dir = join(SCAFFOLDINGS_DIR, "dotd")
for sub_env in matrix():
for sub_env in matrix(odoo_skip={"11.0", "12.0", "13.0", "14.0", "15.0"}):
self.compose_test(
project_dir,
dict(sub_env, DBNAME="prod"),
Expand Down Expand Up @@ -367,7 +474,7 @@ def test_addons_env_double(self):

def test_dotd(self):
"""Test environment with common ``*.d`` directories."""
for sub_env in matrix():
for sub_env in matrix(odoo_skip={"16.0", "17.0"}):
self.compose_test(
join(SCAFFOLDINGS_DIR, "dotd"),
sub_env,
Expand Down Expand Up @@ -406,10 +513,97 @@ def test_dotd(self):
("--version",),
)

def test_dotd_ge_16(self):
"""Test environment with common ``*.d`` directories.
Only for versions greater or equal to 16"""
for sub_env in matrix(odoo_skip={"11.0", "12.0", "13.0", "14.0", "15.0"}):
self.compose_test(
join(SCAFFOLDINGS_DIR, "dotd_ge_16"),
sub_env,
# ``custom/build.d`` was properly executed
("test", "-f", "/home/odoo/created-at-build"),
# ``custom/entrypoint.d`` was properly executed
("test", "-f", "/home/odoo/created-at-entrypoint"),
# ``custom/conf.d`` was properly concatenated
("grep", "test-conf", "auto/odoo.conf"),
# ``custom/dependencies`` were installed
("test", "!", "-e", "/usr/sbin/sshd"),
("test", "!", "-e", "/var/lib/apt/lists/lock"),
("busybox", "whoami"),
("bash", "-xc", "echo $NODE_PATH"),
("node", "-e", "require('test-npm-install')"),
("hello-world",),
(
"bash",
"-c",
'test "$(hello-world)" == "this is executable hello-world"',
),
("python", "-xc", "import Crypto; print(Crypto.__version__)"),
# ``requirements.txt`` from addon repos were processed
("python", "-c", "import numpy"),
# Local executable binaries found in $PATH
("sh", "-xc", "pip install --user -q flake8 && which flake8"),
# Addon cleanup works correctly
("test", "!", "-e", "custom/src/private/dummy_addon"),
("test", "!", "-e", "custom/src/dummy_repo/dummy_link"),
("test", "-d", "custom/src/private/private_addon"),
("test", "-f", "custom/src/private/private_addon/__init__.py"),
("test", "-e", "auto/addons/private_addon"),
# ``odoo`` command works
("odoo", "--version"),
# Implicit ``odoo`` command also works
("--version",),
)

def test_dependencies(self):
"""Test dependencies installation."""
dependencies_dir = join(SCAFFOLDINGS_DIR, "dependencies")
for sub_env in matrix():
for sub_env in matrix(odoo_skip={"16.0", "17.0"}):
self.compose_test(
dependencies_dir,
sub_env,
("test", "!", "-f", "custom/dependencies/apt.txt"),
("test", "!", "-f", "custom/dependencies/gem.txt"),
("test", "!", "-f", "custom/dependencies/npm.txt"),
("test", "!", "-f", "custom/dependencies/pip.txt"),
# apt_build.txt
("test", "-f", "custom/dependencies/apt_build.txt"),
("test", "!", "-e", "/usr/sbin/sshd"),
# apt-without-sequence.txt
("test", "-f", "custom/dependencies/apt-without-sequence.txt"),
("test", "!", "-e", "/bin/busybox"),
# 070-apt-bc.txt
("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"),
("node", "-e", "require('test-npm-install')"),
# 200-pip-without-ext
("test", "-f", "custom/dependencies/200-pip-without-ext"),
("python", "-c", "import Crypto; print(Crypto.__version__)"),
# 270-gem.txt
("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'
),
),
)

def test_dependencies_ge_16(self):
"""Test dependencies installation for greater or equal v16 version."""
dependencies_dir = join(SCAFFOLDINGS_DIR, "dependencies_ge_16")
for sub_env in matrix(odoo_skip={"11.0", "12.0", "13.0", "14.0", "15.0"}):
self.compose_test(
dependencies_dir,
sub_env,
Expand Down
2 changes: 2 additions & 0 deletions tests/scaffoldings/dependencies_ge_16/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,14 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Add ruby as a conditional dependency."""

import os

from doodbalib import ODOO_VERSION

if float(ODOO_VERSION) >= 13:
# These Doodba versions still can use the ruby gem autoinstaller, but
# need ruby to be manually installed because it is not in the base image
# by default (it was until Odoo 12.0)
with open("/opt/odoo/custom/dependencies/000-apt-ruby.txt", "w") as fd:
fd.writelines(["ruby"])
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This line should be ignored
bc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This line should be ignored
test-npm-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Compiled locally, which would fail if `apt_build.txt` fails
pycrypto==2.6.1 --no-binary :all:
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This line should be ignored
hello-world
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This package WON'T be installed
busybox
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This installs gcc among other things
build-essential
# This is the basic need to build any python extensions in v11-
python3-dev
# Just to test it is removed later
openssh-server
Empty file.
29 changes: 29 additions & 0 deletions tests/scaffoldings/dependencies_ge_16/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: 2 additions & 0 deletions tests/scaffoldings/dotd_ge_16/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ARG ODOO_VERSION
FROM tecnativa/doodba:${ODOO_VERSION}-onbuild
3 changes: 3 additions & 0 deletions tests/scaffoldings/dotd_ge_16/custom/build.d/10-touch-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -ex
touch /home/odoo/created-at-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -ex
test -f /home/odoo/created-at-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# Git aggregation is performed at step 100
set -ex
test -d /opt/odoo/custom/src/odoo
3 changes: 3 additions & 0 deletions tests/scaffoldings/dotd_ge_16/custom/build.d/15-broken-link
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -ex
ln -s brokenpath auto/addons/dummy_addon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Dependencies are processed at step 200
set -ex
which busybox
hello-world
node -e "require('test-npm-install')"
python -c "import numpy, Crypto"
1 change: 1 addition & 0 deletions tests/scaffoldings/dotd_ge_16/custom/conf.d/test-conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[test-conf]
5 changes: 5 additions & 0 deletions tests/scaffoldings/dotd_ge_16/custom/dependencies/apt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This line should be ignored
busybox
ruby
ninja-build
patchelf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This installs gcc among other things
build-essential
# This is the basic need to build any python extensions on v11-
python3-dev
# Just to test it is removed after building
openssh-server
2 changes: 2 additions & 0 deletions tests/scaffoldings/dotd_ge_16/custom/dependencies/gem.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This line should be ignored
hello-world
2 changes: 2 additions & 0 deletions tests/scaffoldings/dotd_ge_16/custom/dependencies/npm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This line should be ignored
test-npm-install
4 changes: 4 additions & 0 deletions tests/scaffoldings/dotd_ge_16/custom/dependencies/pip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Compiled locally, which would fail if `apt_build.txt` fails
pycrypto==2.6.1 --no-binary :all:
# External dependency files can be included too; example: numpy
-r https://raw.githubusercontent.com/Tecnativa/doodba/6cec8ea6eefa9d8de8cff103cfca6e373f8fe910/tests/scaffoldings/dotd/custom/src/dummy_repo/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -ex

# Check that --user installations work
pip install --user pg_activity

# Binary must be in $PATH
pg_activity --version
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -ex
touch /home/odoo/created-at-entrypoint
20 changes: 20 additions & 0 deletions tests/scaffoldings/dotd_ge_16/custom/src/addons.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
other-doodba/odoo/src/private:
- absent_addon
- dummy_addon
- product
enterprise:
- make_odoo_rich
---
ONLY:
PGDATABASE:
- limited_core
odoo/addons:
- crm
- sale

---
ONLY:
PGDATABASE:
- limited_private
- limited_core
private: []
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
numpy
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
{"name": "make_odoo_rich", "depends": ["iap"]}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
{"name": "dummy_addon", "depends": ["web"], "installable": True}
Empty file.
Loading

0 comments on commit ae8c0c9

Please sign in to comment.