Spurious failures in test_regionservice
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MAAS |
Fix Released
|
Critical
|
Unassigned |
Bug Description
Asynchronous tests in maasserver.
fail, often (always?) with log messages from other tests, i.e. there is
an isolation issue. I suspect this has been brought out into the light
since we started using the new twisted.logger package, though I have not
been able to identify a root cause.
Isolation between asynchronous tests has been a bit of a lingering
problem in the region tests. In the rack tests we use testtools'
AsynchronousDef
and stops the Twisted reactor, checks for junk, and cleans up between
tests, but in the region that hasn't been possible because of Django's
TransactionTestCase and TestCase. These make too many assumptions to be
used alongside testtools' asynchronous test support.
We need to run the region's asynchronous tests with testtools' help, or
with Twisted's test runner, trial, ideally the former... or either.
In the rack we run tests with only a kimono-thin wrapper around
nosetests. We can, right now, run nearly all the rack tests with trial
(there's a bug preventing a completely clean run) for example, because
of the composition of tests.
In the region, however, we must invoke Django's test command, which then
loads the maas.development settings in which the django_nose app is
installed and TEST_RUNNER is set to something custom; the net result is
that the test command eventually invokes nosetests. In other words,
set-up and tear-down is a distinctly "as grafted-on by Victor F." deal.
The region can no longer be called just a "Django application". We do
use Django's ORM widely, forms too, and its request/response machinery
is used in the Web API (though we hope to remove that in the fullness of
time). As such, Django's assumption of sovereignty is a throwback.
Recasting Django's test database set-up and tear-down as a test fixture
and/or test resource would allow us to run with much better support for
asynchronous tests, and allow us to bypass Django's smothering and
clunky command-line tools.
It ought to allow us to also speed up the test suite because we would
have finer control over what exactly to set-up or tear-down, and because
testresources (the library) can optimise the order in which tests are
run to minimise overall set-up/tear-down costs.
Related branches
- Gavin Panella (community): Approve
-
Diff: 28 lines (+18/-0)1 file modifiedsrc/maasserver/rpc/tests/test_regionservice.py (+18/-0)
- Jeffrey C Jones (community): Approve
- LaMont Jones (community): Approve
- MAAS Maintainers: Pending requested
-
Diff: 666 lines (+154/-50)16 files modifiedsrc/maasserver/api/tests/test_boot_resources.py (+11/-0)
src/maasserver/api/tests/test_machine.py (+4/-2)
src/maasserver/api/tests/test_tag.py (+4/-0)
src/maasserver/models/signals/testing.py (+48/-0)
src/maasserver/models/signals/tests/test_power.py (+9/-6)
src/maasserver/rack_controller.py (+4/-1)
src/maasserver/rpc/tests/test_regionservice.py (+4/-19)
src/maasserver/tests/test_bootresources.py (+7/-0)
src/maasserver/tests/test_node_action.py (+2/-0)
src/maasserver/tests/test_rack_controller.py (+1/-1)
src/maasserver/tests/test_region_controller.py (+9/-0)
src/maasserver/tests/test_status_monitor.py (+5/-5)
src/maasserver/utils/tests/test_osystems.py (+4/-11)
src/maastesting/testcase.py (+14/-3)
src/metadataserver/tests/test_api.py (+23/-2)
src/metadataserver/tests/test_api_status.py (+5/-0)
Changed in maas: | |
status: | New → Triaged |
importance: | Undecided → Critical |
status: | Triaged → Fix Released |