← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/maas/split-tests into lp:maas

 

Raphaël Badin has proposed merging lp:~rvb/maas/split-tests into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~rvb/maas/split-tests/+merge/106896

This cleanup branch splits the tests in maasserver and maastesting.  Previously, the whole lot was run with Django test runner, even the tests in maastesting, most of which don't need the Django environment.  Obviously, it's much faster to run test without the whole Django environment and that's the main reason behind this change.

= Pre-imp =

Had a talk with Gavin about that.  He was ok with the improvement.

= Notes =

I had to split rabbit.py (from maastesting) to put the part that involves Django into maasserver/testing.

I moved the "reconcile" command where it belongs (i.e in src/maasserver).

The only new "code" is in buildout.cfg.

As expected, the total number of tests is unchanged:
previously:
test.maas: 739 tests
test.pserv: 300 tests
now:
test.maas: 717 tests
test.maastesting: 22 tests
test.pserv: 300 tests
-- 
https://code.launchpad.net/~rvb/maas/split-tests/+merge/106896
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/split-tests into lp:maas.
=== modified file 'Makefile'
--- Makefile	2012-05-18 13:11:58 +0000
+++ Makefile	2012-05-22 20:42:20 +0000
@@ -7,7 +7,7 @@
 
 build: \
     bin/buildout \
-    bin/maas bin/test.maas \
+    bin/maas bin/test.maas bin/test.maastesting \
     bin/twistd.pserv bin/test.pserv \
     bin/twistd.txlongpoll \
     bin/py bin/ipy \
@@ -27,6 +27,10 @@
 	bin/buildout install maas-test
 	@touch --no-create $@
 
+bin/test.maastesting: bin/buildout buildout.cfg versions.cfg setup.py
+	bin/buildout install maastesting-test
+	@touch --no-create $@
+
 bin/twistd.pserv: bin/buildout buildout.cfg versions.cfg setup.py
 	bin/buildout install pserv
 	@touch --no-create $@
@@ -54,8 +58,9 @@
 dev-db:
 	utilities/maasdb start ./db/ disposable
 
-test: bin/test.maas bin/test.pserv $(js_enums)
+test: bin/test.maas bin/test.maastesting bin/test.pserv $(js_enums)
 	bin/test.maas
+	bin/test.maastesting
 	bin/test.pserv
 
 lint: sources = contrib setup.py src templates twisted utilities

=== modified file 'buildout.cfg'
--- buildout.cfg	2012-05-21 16:15:19 +0000
+++ buildout.cfg	2012-05-22 20:42:20 +0000
@@ -3,6 +3,7 @@
   flake8
   maas
   maas-test
+  maastesting-test
   pserv
   pserv-test
   repl
@@ -115,11 +116,26 @@
   test.maas=django.core.management:execute_from_command_line
 initialization =
   ${maas:initialization}
-  sys.argv[1:1] = ["test", "--exclude=provisioningserver"]
+  sys.argv[1:1] = ["test", "--exclude=provisioningserver", "--exclude=maastesting"]
 scripts = test.maas
 extra-paths =
   ${maas:extra-paths}
 
+[maastesting-test]
+recipe = zc.recipe.egg
+eggs =
+  ${maas:eggs}
+entry-points =
+  test.maastesting=nose.core:TestProgram
+initialization =
+  sys.argv[1:1] = ["--where=src/maastesting"]
+extra-paths = ${common:extra-paths}
+scripts =
+  test.maastesting
+scripts = test.maastesting
+extra-paths =
+  ${maas:extra-paths}
+
 [pserv]
 recipe = zc.recipe.egg
 eggs =

=== renamed file 'src/maastesting/management/commands/reconcile.py' => 'src/maasserver/management/commands/reconcile.py'
=== renamed file 'src/maastesting/rabbit.py' => 'src/maasserver/testing/rabbit.py'
--- src/maastesting/rabbit.py	2012-04-16 10:00:51 +0000
+++ src/maasserver/testing/rabbit.py	2012-05-22 20:42:20 +0000
@@ -11,10 +11,7 @@
 
 __metaclass__ = type
 __all__ = [
-    "get_rabbit",
     "RabbitServerSettings",
-    "start_rabbit",
-    "stop_rabbit",
     "use_rabbit_fixture",
     "uses_rabbit_fixture",
     ]
@@ -22,7 +19,7 @@
 from functools import wraps
 
 from fixtures import Fixture
-from rabbitfixture.server import RabbitServer
+from maastesting.rabbit import get_rabbit
 from testtools.monkey import MonkeyPatcher
 
 
@@ -51,33 +48,6 @@
         patcher.patch()
 
 
-# See {start,stop,get}_rabbit().
-rabbit = None
-
-
-def start_rabbit():
-    """Start a shared :class:`RabbitServer`."""
-    global rabbit
-    if rabbit is None:
-        rabbit = RabbitServer()
-        rabbit.setUp()
-
-
-def stop_rabbit():
-    """Stop a shared :class:`RabbitServer`, if any."""
-    global rabbit
-    if rabbit is not None:
-        rabbit.cleanUp()
-        rabbit = None
-
-
-def get_rabbit():
-    """Start and return a shared :class:`RabbitServer`."""
-    global rabbit
-    start_rabbit()
-    return rabbit
-
-
 def use_rabbit_fixture(test):
     """Ensure that a :class:`RabbitServer` is started, and Django's setting
     updated to point to it, and that Django's settings are returned to their

=== renamed file 'src/maastesting/tests/test_rabbit.py' => 'src/maasserver/testing/tests/test_rabbit.py'
--- src/maastesting/tests/test_rabbit.py	2012-04-16 10:00:51 +0000
+++ src/maasserver/testing/tests/test_rabbit.py	2012-05-22 20:42:20 +0000
@@ -13,8 +13,8 @@
 __all__ = []
 
 from django.conf import settings
+from maasserver.testing.rabbit import RabbitServerSettings
 from maastesting.factory import factory
-from maastesting.rabbit import RabbitServerSettings
 from maastesting.testcase import TestCase
 from rabbitfixture.server import RabbitServerResources
 

=== renamed file 'src/maastesting/management/commands/tests/test_reconcile.py' => 'src/maasserver/tests/test_commands_reconcile.py'
--- src/maastesting/management/commands/tests/test_reconcile.py	2012-04-16 10:01:50 +0000
+++ src/maasserver/tests/test_commands_reconcile.py	2012-05-22 20:42:20 +0000
@@ -1,7 +1,7 @@
 # Copyright 2012 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
-"""Tests for `maastesting.management.commands.reconcile`."""
+"""Tests for `maasserver.management.commands.reconcile`."""
 
 from __future__ import (
     absolute_import,
@@ -12,7 +12,7 @@
 __metaclass__ = type
 __all__ = []
 
-from maastesting.management.commands.reconcile import (
+from maasserver.management.commands.reconcile import (
     guess_architecture_from_profile,
     )
 from maastesting.testcase import TestCase

=== modified file 'src/maasserver/tests/test_rabbit.py'
--- src/maasserver/tests/test_rabbit.py	2012-04-16 10:00:51 +0000
+++ src/maasserver/tests/test_rabbit.py	2012-05-22 20:42:20 +0000
@@ -27,7 +27,7 @@
     RabbitSession,
     )
 from maasserver.testing.factory import factory
-from maastesting.rabbit import (
+from maasserver.testing.rabbit import (
     get_rabbit,
     uses_rabbit_fixture,
     )

=== modified file 'src/maasserver/tests/test_views_nodes.py'
--- src/maasserver/tests/test_views_nodes.py	2012-05-18 06:14:28 +0000
+++ src/maasserver/tests/test_views_nodes.py	2012-05-22 20:42:20 +0000
@@ -37,6 +37,7 @@
     reload_objects,
     )
 from maasserver.testing.factory import factory
+from maasserver.testing.rabbit import uses_rabbit_fixture
 from maasserver.testing.testcase import (
     AdminLoggedInTestCase,
     LoggedInTestCase,
@@ -46,7 +47,6 @@
 from maasserver.views import nodes as nodes_views
 from maasserver.views.nodes import get_longpoll_context
 from maastesting.matchers import ContainsAll
-from maastesting.rabbit import uses_rabbit_fixture
 from provisioningserver.enum import POWER_TYPE_CHOICES
 
 

=== added file 'src/maastesting/rabbit.py'
--- src/maastesting/rabbit.py	1970-01-01 00:00:00 +0000
+++ src/maastesting/rabbit.py	2012-05-22 20:42:20 +0000
@@ -0,0 +1,46 @@
+# Copyright 2012 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Helpers for testing with RabbitMQ."""
+
+from __future__ import (
+    absolute_import,
+    print_function,
+    unicode_literals,
+    )
+
+__metaclass__ = type
+__all__ = [
+    "get_rabbit",
+    "start_rabbit",
+    "stop_rabbit",
+    ]
+
+from rabbitfixture.server import RabbitServer
+
+
+# See {start,stop,get}_rabbit().
+rabbit = None
+
+
+def start_rabbit():
+    """Start a shared :class:`RabbitServer`."""
+    global rabbit
+    if rabbit is None:
+        rabbit = RabbitServer()
+        rabbit.setUp()
+
+
+def stop_rabbit():
+    """Stop a shared :class:`RabbitServer`, if any."""
+    global rabbit
+    if rabbit is not None:
+        rabbit.cleanUp()
+        rabbit = None
+
+
+def get_rabbit():
+    """Start and return a shared :class:`RabbitServer`."""
+    global rabbit
+    start_rabbit()
+    return rabbit