Attempting to run tests


I am attempting to contribute to maas and am working on fixing some tests. I am doing my development on a vagrant box with the following vagrant file

Vagrant.configure('2') do |config| = 'bento/ubuntu-18.04'
  config.vm.provision 'shell', inline: <<-SHELL
    cd /vagrant
    sudo apt-get update
    make install-dependencies

The HACKING.rst document specifies that individual tests can be run by passing ./bin/test.region path/to/test/file

However, when I run the following, every test fails with a twisted.internet.error.ReactorAlreadyRunning error

vagrant@vagrant:/vagrant$ ./bin/test.region src/provisioningserver/drivers/power/tests/ 
ERROR: provisioningserver.drivers.power.tests.test_redfish.TestRedfishPowerDriver.test_redfish_request_retries_404s_trailing_slash
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/nose/", line 133, in run
  File "/usr/lib/python3/dist-packages/nose/", line 151, in runTest
  File "/vagrant/src/maastesting/", line 279, in __call__
    super(MAASTestCase, self).__call__(result)
  File "/vagrant/src/maastesting/", line 34, in __call__
    super(WithScenarios, self).__call__(result)
  File "/home/vagrant/.buildout/eggs/unittest2-1.1.0-py3.6.egg/unittest2/", line 673, in __call__
    return*args, **kwds)
  File "/vagrant/src/maastesting/", line 275, in run
    super(MAASTestCase, self).run(result)
  File "/home/vagrant/.buildout/eggs/testscenarios-0.5.0-py3.6.egg/testscenarios/", line 65, in run
    return super(WithScenarios, self).run(result)
  File "/home/vagrant/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/", line 671, in run
  File "/home/vagrant/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/", line 80, in run
    return self._run_one(actual_result)
  File "/home/vagrant/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/", line 94, in _run_one
    return self._run_prepared_result(ExtendedToOriginalDecorator(result))
  File "/home/vagrant/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/", line 108, in _run_prepared_result
  File "/home/vagrant/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/twistedsupport/", line 432, in _run_core
  File "/home/vagrant/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/twistedsupport/", line 393, in _blocking_run_deferred, self._timeout, self._run_deferred)
  File "/home/vagrant/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/twistedsupport/", line 77, in trap_unhandled_errors
    result = function(*args, **kwargs)
  File "/home/vagrant/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/twistedsupport/", line 49, in decorated
    return function(*args, **kwargs)
  File "/home/vagrant/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/twistedsupport/", line 295, in run
  File "/usr/lib/python3/dist-packages/twisted/internet/", line 266, in run
  File "/usr/lib/python3/dist-packages/twisted/internet/", line 1222, in startRunning
  File "/usr/lib/python3/dist-packages/twisted/internet/", line 728, in startRunning
    raise error.ReactorAlreadyRunning()

These tests do not fail with this error when running make test. Is there some additional setup needed in order to run the granular tests? It would really speed up my iteration time.


tl;dr: try bin/test.rack src/provisioningserver/drivers/power/tests/ instead

The code in MAAS is architecturally split between things that the rack controller will run and things that the region controller will run. Power control is a responsibility of the rack controller, and doesn’t need the extra setup that region controller tests need.

We’re aware that some of our docs are out of date, and are looking to move it onto Discourse in the near future. Keep an eye out for a post coming ‘soon’ with info on how to setup a MAAS development environment and run tests etc.


Thank you, that will help me an awful lot