Commit Graph

66 Commits

Author SHA1 Message Date
Christophe Simonis d05ee26a72 [MERGE] forward port of branch saas-3 up to 24bcdb7 2015-09-22 15:40:28 +02:00
Christophe Simonis 24bcdb75fb [MERGE] forward port of branch 7.0 up to c2aff47 2015-09-22 15:30:22 +02:00
dufresnedavid cc9113f818 [IMP] Prevent unclosed cursor during tests
If an error happens in an overload of setUp, the already-open cursor
is likely not to get properly released before the next test,
deadlocking the db, because tearDown only runs if setUp has
succesfully completed.

Cleanups were added specifically to run every time, after tearDown has
(potentially) been executed.

closes #8327

Note: cleanups run in LIFO order (as they should).
2015-09-17 12:23:09 +02:00
Denis Ledoux 64e44c0a24 [IMP] base: tests, move patch_order to TransactionCase
In order to be able to redefine simply the order
of a model for testing purposes,
without having to re-define this method in each test class.
2015-09-08 11:53:18 +02:00
Christophe Simonis 6e59ea5db9 [FIX] tests: explain why we ignore phatomjs return code 2015-08-06 21:27:03 +02:00
Antony Lesuisse b4f7288193 [REM] test: phantom_jsfile method
deprecate phantom_jsfile method, keeping only phantom_js, phantom_js takes a
code argument to run client side only.

Removing phantom_jsfile will allow to switch from phantom to any other engine
such as running google chrome or firefox directly. The only use of
phantom_jsfile was an example.
2015-08-02 14:37:19 +02:00
Xavier Morel 11ba4689b1 [IMP] running speed of some tests & new testcase type
Some tests (e.g. mail) have expensive and significant DB setup for a
number of small and cheap tests. Using a TransactionCase, the DB setup
far dominates the tests themselves, by up to 10x (mail unit tests take
~130s on my machine, the tests themselves take ~15s).

The SavepointCase introduced here is an hybrid of SingleTransactionCase
and TransactionCase: it uses a single transaction for all tests in a
class, but each test case is isolated by a rollbacked savepoint. This
allows a common DB setup (via setUpClass) while keeping independent
tests.

TransactionCase should remain the primary test case superclass, but
SavepointCase can be a fair optimisation when setup costs far dominate.
2015-06-23 16:38:14 +02:00
Damián Soriano f7742add26 [FIX] tests: restore openerp.tests.common.DB for backwards compatibility
It was removed at 2df9060d97 and broke
tests in community modules that relied on it.

Tests using it should switch to the new get_db_name() method.

Closes #7054
2015-06-15 00:52:20 +02:00
Damián Soriano 2df9060d97 [FIX] tests: db name moved from constant to function
Avoids initializing the DB constant too early
when subcommand modules are loaded, making them
unable to run db-backed tests later.

Closes #6984
2015-06-12 12:43:01 +02:00
Antony Lesuisse 5a642a802e [FIX] test phantomjs discard stderr
To avoid phantomjs broken pipe messages on odoo stderr during testing.
2015-01-09 01:21:42 +01:00
Raphael Collet 86ba01976e [FIX] tests: make self.assertRaises() return the expected object 2014-11-17 15:39:14 +01:00
Raphael Collet 908252ec88 [FIX] tests: make sure that a failed tests does not leave the environment dirty
When a failure occurs, or when exiting an assertRaises(), the environment
should not contain fields to recompute.
2014-11-17 14:07:42 +01:00
Xavier Morel bc59cfce61 [IMP] doc: add testing reference and improve docstrings 2014-10-09 15:38:36 +02:00
Raphael Collet cbe2dbb672 [MERGE] new v8 api by rco
A squashed merge is required as the conversion of the apiculture branch from
bzr to git was not correctly done. The git history contains irrelevant blobs
and commits. This branch brings a lot of changes and fixes, too many to list
exhaustively.

- New orm api, objects are now used instead of ids
- Environements to encapsulates cr uid context while maintaining backward compatibility
- Field compute attribute is a new object oriented way to define function fields
- Shared browse record cache
- New onchange protocol
- Optional copy flag on fields
- Documentation update
- Dead code cleanup
- Lots of fixes
2014-07-06 17:05:41 +02:00
Antony Lesuisse 0ef85c5a60 [FIX] test phantomjs manually delete localstorage 2014-06-30 17:23:38 +02:00
Antony Lesuisse 78e044b5c7 [IMP] test impprove HTTPCase opener
Simplify website crawler using the generic HTTPCase opener
2014-06-29 20:04:30 +02:00
Simon Lejeune ebb3f1aad1 [FIX] use unique localstorage path when running phantomjs tests
this patch use a unique localstorage per test at al request. It could have used one localstorage per instance or even per module.
2014-06-26 14:06:20 +02:00
Antony Lesuisse 739793cdcd [FIX] tests race condition in phanthomjs tests
A deadlock occurs when
- phantomjs_test1 is executedd, enter_test_mode is activated
- console.log('ok') is issued, sigterm is sent to phantomjs_test1 process
- phantomjs_test1 is finished and leave_test_mode restores the registrymanager lock
- phantomjs_test1 process, just before dying, makes a last http request phantomjs_test1_last_request
- phantomjs_test1_last_request thread will wait for the registrymanager lock, when all tests will be completed 
- phantomjs_test2 is run, enter_test_mode is activated
- phantomjs_test2 is reach its end and _wait_remaining_requests is called
- phantomjs_test2 _wait_remaining_requests hangs forever waiting for phantomjs_test1_last_request

bzr revid: al@openerp.com-20140501150641-ua0b7pntesgm3n5p
2014-05-01 17:06:41 +02:00
Antony Lesuisse f0dcf52159 [FIX] instrumentation to debug a deadlock probably due to a race condition in
the test cursor

bzr revid: al@openerp.com-20140411143645-ojb4t9plop4dmizh
2014-04-11 16:36:45 +02:00
Christophe Simonis 95701c28c0 [FIX] test: HttpCase wait http requests to finish
bzr revid: chs@openerp.com-20140410123519-wngil3aghdc6llqc
2014-04-10 14:35:19 +02:00
Raphael Collet e5e00e4c0a [IMP] registry: now cursor() simply returns a cursor, which may itself be used as a context manager
bzr revid: rco@openerp.com-20140409095604-joh9dt0qkma12ykm
2014-04-09 11:56:04 +02:00
Raphael Collet f0fd48c44a [IMP] http tests: implement a test cursor that keeps a transaction open accross requests
- TestCursor subclasses Cursor, and simulates commit and rollback with savepoints
 - the registry manages a test mode, in which it only uses the test cursor
 - a reentrant lock forces the serialization of parallel requests

bzr revid: rco@openerp.com-20140408151736-j0guy68i2wjexy3d
2014-04-08 17:17:36 +02:00
Raphael Collet 6bc60505f4 [IMP] registry: add method get_cursor() to simply retrieve a new cursor, and refactor code to use it
bzr revid: rco@openerp.com-20140408125122-ki0zmin3m21k2itd
2014-04-08 14:51:22 +02:00
Raphael Collet b49f536baf [IMP] tests.common: turn class methods into instance methods (this will ease some future refactoring)
bzr revid: rco@openerp.com-20140408114936-jfagg4qvft8bk3ms
2014-04-08 13:49:36 +02:00
Raphael Collet 81b84c62b1 [IMP] registry: switch for a dummy lock only during the execution of http tests
bzr revid: rco@openerp.com-20140408094513-ahtwod1q17ijohbg
2014-04-08 11:45:13 +02:00
Antony Lesuisse 7c29e3847c [FIX] increase js test timeout to 60
when runbot is overloaded, test speed can be slow, 2s per HTTP request

bzr revid: al@openerp.com-20140403134109-nzg71xmybw1p5bsi
2014-04-03 15:41:09 +02:00
Antony Lesuisse 627b5b671e [FIX] tests dont log traceback on aborted request while testing
bzr revid: al@openerp.com-20140317135239-08aefkdxiil7bpcs
2014-03-17 14:52:39 +01:00
Antony Lesuisse 09deba4826 [FIX] tests dont generate traceback on aborted test requests
bzr revid: al@openerp.com-20140317124343-kgesa5c215z19vpn
2014-03-17 13:43:43 +01:00
Antony Lesuisse 338c0a3f5e [FIX] race condition for test cursors
If a test ends before handling all its http queries (serialised by a Rlock),
threads created for unfufilled queries may hang because the interrupted thread
might not have unlocked its cursor as it might have dissapeared from
HTTP_SESSION before request release_test_cursor. We now use the cursor itself
instead of HTTP_SESSION.

bzr revid: al@openerp.com-20140317031448-rffj7gixgk8jzeqp
2014-03-17 04:14:48 +01:00
Antony Lesuisse cde6e0f6c6 [FIX] no comments
bzr revid: al@openerp.com-20140316212127-l1rxz5zh4o92tv90
2014-03-16 22:21:27 +01:00
Antony Lesuisse c3ef6eb892 [FIX] tests typo in js tests result parsing
bzr revid: al@openerp.com-20140316200135-dyyl6u5uas4js90g
2014-03-16 21:01:35 +01:00
Antony Lesuisse 97a097dbab [IMP] tests log phantom to info the default loglevel of runbot
bzr revid: al@openerp.com-20140316195252-i6wr3scp0zmx92zu
2014-03-16 20:52:52 +01:00
Antony Lesuisse eac5185731 [IMP] phantom tests
- phantomjs more verbose
- revert to dumber console.log relay, dont try to be smart, just display it
- json is only optionally parsed for errors stack dumps

bzr revid: al@openerp.com-20140316160634-hh7br4mbg01xcrpk
2014-03-16 17:06:34 +01:00
Xavier Morel b3de4ca481 [IMP] readability of phantomjs timeouts
bzr revid: xmo@openerp.com-20140310101554-6imrb3hnd95q1wgu
2014-03-10 11:15:54 +01:00
Antony Lesuisse 3aa98edaaf [IMP] test add an url_open helper to http case
bzr revid: al@openerp.com-20140306234535-9zhumihumbzcddb2
2014-03-07 00:45:35 +01:00
Xavier Morel 013d27b850 [IMP] filter out phantomjs warning on OSX
bzr revid: xmo@openerp.com-20140221143448-tpx62ua785kc8gfx
2014-02-21 15:34:48 +01:00
Xavier Morel fc780d5a81 [FIX] actually retry select on EINTR
Turns out select has its own select.error which does *not* subclass
EnvironmentError (or OSError or IOError) and does *not* have a .errno
attribute. So use the correct exception, might just work better than using
a completely different one with no relation.

bzr revid: xmo@openerp.com-20140219155303-sgz7m3gnzr2bmani
2014-02-19 16:53:03 +01:00
Xavier Morel d5cb5c2a14 [FIX] correctly display JS stack frames in phantomjs runner
altered reporting to handle and deserialize JSON if JSON-deserializable. Can't
just send multiple lines as driver currently does not handle multiple lines of
message... Yeah turns out having a JSON-based protocol between phantomjs and
the python runner allowed multiple lines in messages, who'd have thought eh?

bzr revid: xmo@openerp.com-20140219123850-0h0upb3x33j7leqk
2014-02-19 13:38:50 +01:00
Xavier Morel fbead8fab1 [IMP] style
use break instead of return so cleanup can eventually be put after loop if necessary (?)

bzr revid: xmo@openerp.com-20140219101334-n8fcmzxptrqj717a
2014-02-19 11:13:34 +01:00
Xavier Morel abb58ee3b8 [FIX] possibility of select being interrupted, just restart the call
uses EnvironmentError because not sure if socket.error or os.error

bzr revid: xmo@openerp.com-20140219101110-4g4o658vzsol7jae
2014-02-19 11:11:10 +01:00
Xavier Morel cb03b384b0 [IMP] phantomjs runner
* use Skip exception to skip tests in case phantomjs binary not found
* remove spurious logging, move some to debug when debatable
* use testing assertions for correct reporting
* allow failure message
* use mutable buffer to accumulate stdout data

bzr revid: xmo@openerp.com-20140218133445-e5l155j10i934o88
2014-02-18 14:34:45 +01:00
Xavier Morel 71259f09f4 [ADD] hooks to enable/disable tests running during install
also add flag for post_install run, but not used yet

bzr revid: xmo@openerp.com-20140218095452-pptez5rlpdez1ttl
2014-02-18 10:54:52 +01:00
Antony Lesuisse c8324bafcc [IMP] phantomjs testing
- avoid dbmanager by presetting db in the test session
- correctly handle login option
- serialize test cursor access

bzr revid: al@openerp.com-20140216212222-4o6x9uljyua3g1og
2014-02-16 22:22:22 +01:00
Antony Lesuisse 42db02f73c [FIX] tests HTTPCase if phantomjs is not installed
bzr revid: al@openerp.com-20140216162026-ymbzoi70txbr64yl
2014-02-16 17:20:26 +01:00
Antony Lesuisse 1f78dfb76d [IMP] phantomjs testing add an easy phantom_js helper
self.phantom_js(<page_to_load>, <code_to_run>, <global_object_to_wait>, **options)

example:

self.phantom_js("/", "openerp.module.mytest()", "openerp.module.mytest");

console.log('ok') or console.log('error') should be used to signal success or
failure. Other console.log's will be passed to the test logger.

bzr revid: al@openerp.com-20140210004517-jc2cobc31qshxchm
2014-02-10 01:45:17 +01:00
Antony Lesuisse 1f67b2165c [IMP] phantomtest helper
bzr revid: al@openerp.com-20140209223917-vruzjvl0mtsqoo87
2014-02-09 23:39:17 +01:00
Antony Lesuisse e6ac29ee43 [IMP] move test cases to tests.py remove deprecated wsgi import
bzr revid: al@openerp.com-20140209151822-cgk0wibqe1kfd42w
2014-02-09 16:18:22 +01:00
Antony Lesuisse 278ed718e9 new test execution engine
remove deprecated zipfile support
add preload_registry option when server is running
allow registries to be used in contruction in test mode
add a rollback test case for http tests
add a phantomjs helper

bzr revid: al@openerp.com-20140209004005-p5pwym4sqc23vw5b
2014-02-09 01:40:05 +01:00
Antony Lesuisse 82372e6a02 move tests
move test modules
remove xml test
add phantomjs test
readd remove uninstall test (currently disabled because of cr.commit)

bzr revid: al@openerp.com-20140209003745-ehrx8ikwkmusa644
2014-02-09 01:37:45 +01:00
Antony Lesuisse 780ae08294 [IMP] add an easier to use XML-RPC faultCode compliant protocol
remove the /openerp/* routes, they were never used because the protocol was too 
different from the historical /xmlrpc/ routes. Instead we introduce a
/xmlrpc/2/ route identical to /xmlrpc/ with the only difference that it returns
int faultCodes making it compliant with the XML-RPC specification.

bzr revid: al@openerp.com-20131006102131-707kxc9zyd1mvlps
2013-10-06 12:21:31 +02:00