Commit Graph
157 Commits
Author SHA1 Message Date
Christophe Monniez ecaa04ec82 [FIX] tests: increase browser_js ready code timeout
Before starting a JS test/tour the _wait_ready method evaluates if the
test is ready with a timeout of 10 sec. From times to times, it happens
that the page is not ready after this timeout but the problem is hidden.

In order to help fixing that kind of issue, the timeout is increased to
60 sec and a warning is logged to emphasis the fact that an
issue exists.

Also some unused imports are removed with this commit
2018-10-18 11:59:42 +02:00
Raphael Collet 614884928e [FIX] tests: clean up code
Closes #26467
2018-10-18 11:59:42 +02:00
Christophe Monniez 9973994660 [FIX] tests: clean the browser even on failure
When a Chrome headless test fails the browser is not cleaned and could
lead to a mix with other tests when the same method is called.

Also, the multiline assertions gives an unreadable message when the
assertion fails.
Finally, it happens that a thread does not have an 'url' attribute and lead to a crash when the logger tries to show the thread url.

With this commit, the browser is cleaned, even on failure and the
assertions are now one line.

Closes:  #26432
2018-10-18 11:59:42 +02:00
Christophe Monniez 9211121a57 [FIX] tests: avoid traceback when websocket-client is not installed
The account module needs to import Form from "tests.common" causing a
traceback when websocket-client module is not installed.

As this module is only required for the tests, there is no reason to add
it to the "requirements.txt" file.

With this commit, Odoo account can be installed even when
websocket-client is not installed, in that case, the HttpCase tests that
needs to run Chrome headless will be skipped with a warning.

Closes: #26404
2018-10-18 11:59:42 +02:00
antonylesuisse 1fe5145f0c [REF] tests: replace phantomjs by Chrome headless
As the phantomjs project was suspended[1], there was a need to change the js test
engine. Moreover, the engine was rather old and leading to non
deterministic crashes.

Chrome headless was choosen for simplicity and the long term vision of
the devtools protocol [2].

The 'phantom_js' method still exists but will be deprecated in
favor of 'browser_js' with the same parameters.

In order to communicate with the browser, the python websocket-client package
is needed.

[1] https://github.com/ariya/phantomjs/issues/15344
[2] https://chromedevtools.github.io/devtools-protocol/

closes #25991
2018-10-18 11:59:38 +02:00
Xavier Morel 35eaa523bd [IMP] tests logging
* Make phantomjs logging clearer by logging within the test case's
  module, not odoo.tests.common.

  This way, a tour in e.g. point of sale is clearly logged as that,
  rather than be logged as odoo.tests.common.phantomjs and require
  hunting which module/test we happen to be in.

* Clarify tagging causes for exclusion of selection of tests.
2018-10-18 11:59:08 +02:00
Christophe Simonis b81c2bce84 [MERGE] forward port branch saas-11.4 up to 3c108977c1 2018-10-22 16:59:51 +02:00
Thibault Delavallée 7429c61dfc [IMP] tests: add an helper in odoo tests in order to quickly create test users
Following great @odony review we decided to add a helper method allowing
to quickly create users in tests in a one-liner. It will allow to remove a
lot of duplicate code in various test classes and methods.

This method basically requires a login and a comma separated list of user
groups xml ids. Kwargs are supported to further customize the created
user. A custom context can be given to the creation as user creation in
odoo can support several options within standard addons, like mailing or
signup options.

Next commits will propagate the use of this helper in some test classes
notably in mail, hr and mass mailing.

This commit is linked to task ID 1889703 and PR #27526.
2018-10-18 13:56:56 +00:00
Jairo Llopis a362d0eb9f [FIX] tests: Make at_install and post_install backwards compatible
Fixes #27471 by just using `tagged()` behind the scenes.

calls to `tagged` were done in the wrong order

closes odoo/odoo#27531
2018-10-08 12:16:08 +00:00
Denis Ledoux 4fb5c57dc5 [FIX] tests: web tests, chromium fallback
On Ubuntu, the chromium executable is `chromium-browser`,
On other distributions, such as debian, it's `chromium`.

We therefore add another fallback
2018-09-14 11:28:56 +02:00
Denis Ledoux 6e3e195324 [FIX] tests: chromium executable is chromium-browser
When installing chromium using apt
e.g apt install chromium-browser
the executable is `chromium-browser`,
not just `chromium`
2018-09-14 10:43:28 +02:00
Christophe Simonis 68d36512ef [MERGE] forward port branch saas-11.4 up to d78f23df84 2018-09-07 20:20:45 +02:00
Christophe Simonis 49c3264ce0 [MERGE] forward port branch saas-11.3 up to 4850fb0838 2018-09-07 14:43:48 +02:00
Christophe Simonis f19e6ce561 [MERGE] forward port branch 11.0 up to 213759b03e 2018-09-05 18:52:27 +02:00
Christophe Monniez e312ec71dd [FIX] tests: detect coverage and adjust timeout
When computing coverage, the tests are slowed down and the timeout is
often exceeded.

With this commit, HttpCase headless Chrome tests timeout is increased if
coverage is detected.
2018-09-05 15:30:49 +02:00
Christophe Monniez 69a24eb84b [FIX] tests: close Chrome and shutdown on SIGXCPU
When Odoo receive a SIGXCPU (CPU time limit reached), it shuts down
immediately. If a headless Chrome is running, it stays alive after the
Odoo shutdown.

With this commit, the signal is intercepeted and the Chrome browser is
properly closed before shutting down the Odoo server.
2018-09-05 15:30:49 +02:00
Christophe Monniez f468023bd9 [FIX] tests: properly stop chrome when no tab found
In some situations, Chrome remote debugging is sending an empty list of
opened tabs. In that case, an orphan Chrome process stays alive.

With this commit, Chrome is stopped properly in those situations.
2018-09-05 15:30:49 +02:00
Christophe Monniez c6ed80e1b6 [FIX] tests: disable screencast when no logfile
When an HttpCase browser_js test is started, the screencast is started
and is discarded at the end of the test if no logfile was provided by
the config.

This behavior can impact the performances.

With this commit, the screencast does not start at all if not needed.
2018-09-04 19:17:01 +02:00
Martin Trigaux a9cd97f58e [MOV] tests: move test to be executed
The test was in a folder not checked by the runbot
The test, as it, is actually failing and it will be corrected in the next commit
2018-09-03 11:02:55 +02:00
Christophe Monniez 580a0b2ef7 [FIX] tests: redirect chrome headless stdout and stderr to dev null
When executing a very long HttpCase browser_js test, it happens that one
of the chrome process PIPE is full (ie. clickEverywhere test).
In that case, the communication with Chrome is blocked.

With this commit the stdout and stderr of the Chrome process are
redirected to /dev/null.
2018-08-31 15:03:11 +02:00
XavierDo 73f1d59096 [FIX] tests, web_tour: improve js error display in build details
Since chrome headless has been merged, js error messages are
difficult to read: some information was missing or only displayed in
full all log.

All console.error() will now be displayed in build details, and will
appear just before the python assertion.

XMO's improvement will also be used on all log: Using module and
classname of the class calling phantomJS.

Also: some small improvements on error messages to make them easier to read

Note: this commit also shown that some error were not detected:
now we will fail in any case if js log an error.
2018-08-30 15:11:38 +02:00
Raphael Collet 2f7c03d9ca [IMP] base: add regular user admin as uid 2
User 1 simply becomes a technical user (inactive, no password).
2018-08-23 21:38:57 +02:00
Christophe Simonis 6fd68c28cd [FIX] core: use actual chrome/chromium executable on macOs. 2018-08-23 16:37:17 +02:00
Christophe Monniez 334804347a [FIX] tests: increase browser_js ready code timeout
Before starting a JS test/tour the _wait_ready method evaluates if the
test is ready with a timeout of 10 sec. From times to times, it happens
that the page is not ready after this timeout but the problem is hidden.

In order to help fixing that kind of issue, the timeout is increased to
60 sec and a warning is logged to emphasis the fact that an
issue exists.

Also some unused imports are removed with this commit
2018-08-22 16:17:38 +02:00
XavierDo 2831fa7926 [IMP] core, test_mail: improve query count assertions
-remove margin
With the spirit of making tests determinists,
we can remove margins to have a real test of query count.

-mock random on assert query count
bus gc is triggered using random. Therefore, when send_many is called,
we have 1% chance to have more query. Mocking random.random to 1
will disable gc during query count tests (not during warmup).
Could be interresting to put gc collection in a cron latter

-add more info on querycount
Adding file and line number on query count failure/info will help to update
the query counts.

-update query count based on enterprise
Update all query count with enterprise values (exactly)

-normalize query counts with enterprise
voip module add a read on activity type (during create) in enterprise,
leading to one more query but also more information in cache.
Therefore, the next assertion will need one more query to access this data
in community.
Adding an access to activity type in the first assertion will allow
to have the same cache state in community and enterprise.

Task: #1878588
PR: #26476
2018-08-21 16:56:54 +02:00
Raphael Collet b1cc28be00 [FIX] tests: clean up code
Closes #26467
2018-08-21 09:21:11 +02:00
Christophe Monniez c6fa1796af [FIX] tests: clean the browser even on failure
When a Chrome headless test fails the browser is not cleaned and could
lead to a mix with other tests when the same method is called.

Also, the multiline assertions gives an unreadable message when the
assertion fails.
Finally, it happens that a thread does not have an 'url' attribute and lead to a crash when the logger tries to show the thread url.

With this commit, the browser is cleaned, even on failure and the
assertions are now one line.

Closes:  #26432
2018-08-17 14:49:53 +02:00
Christophe Monniez 49fb7a4682 [FIX] tests: avoid traceback when websocket-client is not installed
The account module needs to import Form from "tests.common" causing a
traceback when websocket-client module is not installed.

As this module is only required for the tests, there is no reason to add
it to the "requirements.txt" file.

With this commit, Odoo account can be installed even when
websocket-client is not installed, in that case, the HttpCase tests that
needs to run Chrome headless will be skipped with a warning.

Closes: #26404
2018-08-16 15:07:43 +02:00
antonylesuisse de84ad9c1f [REF] tests: replace phantomjs by Chrome headless
As the phantomjs project was suspended[1], there was a need to change the js test
engine. Moreover, the engine was rather old and leading to non
deterministic crashes.

Chrome headless was choosen for simplicity and the long term vision of
the devtools protocol [2].

The 'phantom_js' method still exists but will be deprecated in
favor of 'browser_js' with the same parameters.

In order to communicate with the browser, the python websocket-client package
is needed.

[1] https://github.com/ariya/phantomjs/issues/15344
[2] https://chromedevtools.github.io/devtools-protocol/

#closes 25991
2018-08-16 11:45:43 +02:00
Xavier Morel 61a6347c54 [IMP] tests logging
* Make phantomjs logging clearer by logging within the test case's
  module, not odoo.tests.common.

  This way, a tour in e.g. point of sale is clearly logged as that,
  rather than be logged as odoo.tests.common.phantomjs and require
  hunting which module/test we happen to be in.

* Clarify tagging causes for exclusion of selection of tests.
2018-08-14 15:37:26 +02:00
Christophe Simonis 4797627259 [MERGE] forward port branch saas-11.4 up to 8d9366197e 2018-08-01 18:02:29 +02:00
Christophe Simonis a719cf2563 [MERGE] forward port branch saas-11.3 up to b4555df336 2018-07-30 17:02:28 +02:00
xmo-odoo abc1289a4c [ADD] pagebreak to core qweb 2018-07-25 16:53:11 +02:00
Christophe Simonis ba202dbe63 [MERGE] forward port branch saas-11.2 up to 3c521f6d05 2018-07-24 18:10:32 +02:00
Laurent Smet 45cde5ff38 [IMP] tests: added assertRecordValues() in BaseCase
This method will help to compare a recordset with their expected values, in the form of a list of dict

Was task: 1856976
Was PR #25129
2018-07-23 11:13:39 +02:00
Christophe Monniez 23d840ddce [DOC] cmdline,testing: add documentation for test-tags
Closes #25789
2018-07-20 08:17:21 +02:00
Christophe Simonis 73652a0b19 [MERGE] forward port branch saas-11.3 up to 50860317cc
Note: 1aacc96262 has been ignored and will
be forward-ported later
2018-06-15 13:27:27 +02:00
Christophe Simonis 50860317cc [MERGE] forward port branch saas-11.2 up to b170a753e1 2018-06-15 11:30:27 +02:00
Christophe Simonis b170a753e1 [MERGE] forward port branch 11.0 up to b05e4d5f95 2018-06-15 10:15:27 +02:00
Christophe Simonis d45c32baac [MERGE] forward port branch saas-15 up to bdd051bf78 2018-06-13 18:13:48 +02:00
Christophe Simonis bdd051bf78 [MERGE] forward port branch saas-14 up to c43c540172 2018-06-13 14:12:12 +02:00
Toufik Benjaa c8243e71c6 [FIX] http: Consume less cursors for session checks
- Each time we check if a session is valid we create a new cursor.
  This could lead to issues with db_maxconn that limits the number of
connections to the postgresql server.
  In a perfect world, a worker should use a single connection to
postgres to process the request.
  The only known side effect is that the cursor is created earlier in
the execution of the code.

- This commit fixes issues with the longpolling raising
Psycopg2.PoolError exceptions on databases with a lot of clients.
2018-06-12 18:10:37 +02:00
Christophe Simonis f36e6917bd [MERGE] forward port branch saas-11.3 up to 37eed7c509 2018-05-29 17:34:43 +02:00
Christophe Simonis 644f0959d0 [MERGE] forward port branch saas-11.2 up to 1655202924 2018-05-17 14:23:37 +02:00
Raphael ColletandThibault Delavallee 4412cb0bf4 [IMP] tests: do not warn about margins and improve logging
* margin have been recently added on some query count tests as currently query
   count is not completely deterministic. Setting a warning is not really
   interesting as it is the current behavior. Being in margin is now green
   and solely provide a different logging message;
 * logged messages are improved to ease grep;

This also reverts aae54ecc15 .

Co-authored-by: Thibault Delavallee <tde@odoo.com>
Co-authored-by: Raphael Collet <rco@odoo.com>
2018-05-15 13:29:30 +02:00
Christophe Monniez 54ae09b100 [IMP] tests: improve log when phantomjs crashes
When phantomjs crashes, an error is logged only when the crash is a segfault.
From time to time, we see on the runbot some crashes without any
informations. When digging in the log files, it appears that the exit value
of phantomjs is -6 (that could correspond to the SIGABRT signal).

With this commit, the error message will clearly show the return code
and, above all, it will show that the test failed due to a phantomjs
crash.
2018-04-19 09:16:05 +02:00
Christophe Monniez 4ba6d2a405 [IMP] tests: make phantomjs work on Windows
Since Python 3.2, close_fds parameter is True by default on POSIX
platforms. On Windows, it's set to False when one of the standard descriptors
is set.

This commit will give the opportunity to run phantom js tests on
Windows.
2018-04-10 09:32:30 +02:00
Thibault Delavallée a03f8da8e4 [IMP] tests: allow to add a margin on performance tests
Purpose of this commit is to avoid errors for some performance tests that
have a slightly variable number of queries. Indeed some tests in test_mail
module vary of 1 or 2 queries due to a behavior still not found that does
not seem deterministic.

This should not be considered as a real error, but should not be considered
as completely valid. This is why a margin is accepted in some tests that
will raise a warning instead of an error. This warning tells people to
check if they have increased the query counter or if it is due to a random
effect in query count.

This is a manual forward-port of saas-11.2 commit 3fe0ee5ae6 .
2018-04-09 17:28:03 +02:00
Thibault Delavallée 3fe0ee5ae6 [IMP] tests: allow to add a margin on performance tests
Purpose of this commit is to avoid errors for some performance tests that
have a slightly variable number of queries. Indeed some tests in test_mail
module vary of 1 or 2 queries due to a behavior still not found that does
not seem deterministic.

This should not be considered as a real error, but should not be considered
as completely valid. This is why a margin is accepted in some tests that
will raise a warning instead of an error. This warning tells people to
check if they have increased the query counter or if it is due to a random
effect in query count.
2018-04-09 16:52:12 +02:00
Thibault Delavallée 3bb498d696 [REVERT] "[IMP] core: tolerate a 10% deviation for number of queries"
This reverts commit d565596868. Indeed whole purpose of having tests
based on query counters is to fail every time query count is greater than
expected. Query count could be greater than expected because
 * either it is required by a bug fix or a feature and tests should be
   updated accordingly in the same commit;
 * either implementation can be improved to avoid or lessen query count
   impact and code should be updated accordingly;
 * either we have some random queries due to nondeterministic behavior;

It seems purpose of the commit was to solve the third case. However we think
hiding first two cases can be dangerous compared to solving third case.
Moreover having a threshold of 10% does not make sense. It means some complex
test case could take 30 queries more without being noticed. Some tests could
fail after several commits adding queries and finding them afterwards could
be complicated.

Another solution based on flagging some tests that have a small random
behavior will come soon.
2018-04-09 16:52:12 +02:00