Commit Graph
3 Commits
Author SHA1 Message Date
Romain DerieandXavier-Do 6e21371c1c [FIX] test_assetsbundle: don't pregenerate assets outside test mode
Commit [1] and [2] introduced an assets pregeneration to speed up the
testing suite on runbot.

It seems like it was chosen to always pregenerate the assets when a
module was installed/upgraded. This was done in the `test_assetsbundle`
module to only impact the tests flows, but it was not correct as it was
not only impacting the tests flows but also regular runbot usage.
Indeed, any `all` runbot (the default one) will have that module
installed.
It means that any module operation through regular flow in those DB will
trigger the assets pregeneration.

One of the problem is then that during a theme switch through the
website builder (or configurator), assets would be pregenerated, adding
~40 seconds to the processing time.
Since that theme install was already taking ~30 seconds on `all` runbot,
it sometimes now total over 60 seconds, triggering the `CPU Time Limit`.
You can find some benchmark and metrics on this commit PR.

Obviously, that's not fine because runbot, despite being our testing
tool/platform, is also one of our main demo tool.
That's especially true around the OXP period, where people are recording
video on it but will also use it to show demo to the customers.

Finally, there is no reason to not limit this assets pregeneration to
the test mode anyway.

Note that sometimes, the theme install is failing and responding with a
502 error after a long time, this is yet unsure if this was the cause
but it was during this investigation that this commit fix was found.
It is probably the cause though.

[1]: https://github.com/odoo/odoo/commit/c764c38d7caf300dce7509e87d2bd268eee0161d
[2]: https://github.com/odoo/odoo/commit/d47cf37b688117d6b2514b9b620787aa66312c61

closes odoo/odoo#103105

X-original-commit: 5e77961e4768ef2d3d40f1600dd76a633a0e231b
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: Xavier-Do <xdo@odoo.com>
2022-10-11 18:56:16 +02:00
Xavier-Do d47cf37b68 [FIX] test_assetsbundle: no pregenerate when ready
The pregenerate of assets_bundle should be done maximum two times
- at the end of an install/update if the module test_assetsbundle is
installed

- at the beginning of post_install tests

Currently, during the nightly (install and all tests are ran at the
same time), the pregeration of assets is triggered at the end of some
tests

  File "/home/xdo/osrc/master/odoo/odoo/tests/common.py", line 319, in _tearDownPreviousClass
    super()._tearDownPreviousClass(test, result)
  File "/usr/lib/python3.8/unittest/suite.py", line 300, in _tearDownPreviousClass
    previousClass.doClassCleanups()
  File "/usr/lib/python3.8/unittest/case.py", line 731, in doClassCleanups
    function(*args, **kwargs)
  File "/home/xdo/osrc/master/odoo/odoo/modules/registry.py", line 704, in reset_changes
    self.setup_models(cr)
  File "/home/xdo/osrc/master/odoo/odoo/modules/registry.py", line 306, in setup_models
    model._register_hook()
  File "/home/xdo/osrc/master/odoo/odoo/addons/test_assetsbundle/models/ir_qweb.py", line 13, in _register_hook

The registry.updated_modules is set to allow post_install tests
to select the right tests to execute. This is a way to define if we
updated some modules loading this registry. This list is unfortunatelly
not emptied before running the test, meaning that if register hook are
called on the same registry again, pregenerate will be executed
a second time.

A solution here is to check if the registry is not ready,
meaning that this is the load_modules call to register_hook
and not the setup_models one

closes odoo/odoo#100079

Related: odoo/enterprise#31271
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-09-13 22:16:16 +02:00
Xavier-Do b58967d8d1 [IMP] loading: pregenerate assets bundles after install
During tests on runbot, the main reason tours are slow to start is
because the first loading of "/web" need to generate assets bundles.
Generation can take up to 5 seconds time the number of tour.

Before this, the first requests to /web takes around 7 seconds on
runbot and the next ones less than 1 second.

After this commit, the first request to /web takes around 1.5 seconds

Note that the main difficulty is to choose when to generate the assets.
(With optimisations from following commits) the generation time is
arround 30 seconds (21 css + 12 js) the first time, for all modules.
If the attachements exists the generation time is arround 3 seconds
(2.5 js + 0.5 css) mainly because of globs to find usefull files.

In practice for runbot the ideal would be to generate them at
the end of the install so that it is shared for all post_install builds.

Doint it at the end of an install is not wanted in all cases, saas
pregenerated templates and upgrade may avoid doing that.

Doing it in a special runbot step (subcommand) is not possible for niglty
execution (no split, in one go). This needs to be in the code.
It is also not practical for devs wanting to have the same behaviour on
a local machine.

A solution to make the test conditionnal at install is to base the
condion on an existing test_module. test_assetsbundle is a good
candidate here. On runbot, the at_install step (befor split) will
automatically generate assets with this solution.

Assets are also generated before post_install tests. This should be fast
if they already exists and ensure that assets are up to date after
modifying sources locally or after downloading a database on runbot.
It should be fast enough for small database and may be even faster
in the future for small diffs.

Part-of: odoo/odoo#99176
2022-09-12 13:48:59 +02:00