Skip to content

Commit

Permalink
fix(queue_job): out-of-the-box support in test environments
Browse files Browse the repository at this point in the history
When you use queue_job, it is common to add some configuration to it.

The canonical way to do that with doodba would be to put a file in some path such as `odoo/custom/conf.d/queue_job.conf` and contents like these:

```ini
[options]
(...)
workers = 6
server_wide_modules = base,web,queue_job

(...)
[queue_job]
channels = root:3
```

However, in that case, the file would be used too by a test environment.

Test environments have 2 workers hardcoded, to save computational power for the production instance: https://github.com/Tecnativa/doodba-copier-template/blob/e2f4efdab336d5cd32c327a007983011e1e4edbb/test.yaml.jinja#L50

However, if you configure 2 workers with `channels = root:3`, you're doomed. Any delayed action in a test environment will block the server. At least, if the amount of delayed actions in batch is more than the current workers.

I'm adding docs to queue_job in OCA/queue#650 to make this behavior clear. Also, here I'm adding an environment variable that will be harmless in test environments without `queue_job`, but will provide a sane default for those that use it.

Also I configure 3 workers by default because, if you use `queue_job` to print a report, one worker would be for printing, other for queue_job, and you'd still need another one to use the UI.

@moduon MT-6106
  • Loading branch information
yajo committed Sep 24, 2024
1 parent 25a63c3 commit 385aee3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ services:
WITHOUT_DEMO: "${DOODBA_WITHOUT_DEMO-all}"
SMTP_PORT: "1025"
SMTP_SERVER: smtplocal
# Just in case you use queue_job
ODOO_QUEUE_JOB_CHANNELS: "root:1"
restart: unless-stopped
{%- if domains_test %}
hostname: {{ macros.first_main_domain(domains_test)|tojson }}
Expand Down Expand Up @@ -48,7 +50,7 @@ services:
{%- endif %}
command:
- odoo
- --workers=2
- --workers=3
- --max-cron-threads=1

{% if postgres_version -%}
Expand Down

0 comments on commit 385aee3

Please sign in to comment.