← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~allenap/maas/more-test-rabbits into lp:maas

 

Gavin Panella has proposed merging lp:~allenap/maas/more-test-rabbits into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~allenap/maas/more-test-rabbits/+merge/98740

This disables publishing events to Rabbit by default during
tests. Tests that need to exercise the message queue code must request
Rabbit explicitly with uses_rabbit_fixture() or use_rabbit_fixture() -
the former is a decorator.

This has highlighted that there's only *one* test in the whole of MAAS
that actually /needs/ to exercise the message queue. I'd gamble
there's a hole in our test coverage there.

-- 
https://code.launchpad.net/~allenap/maas/more-test-rabbits/+merge/98740
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/maas/more-test-rabbits into lp:maas.
=== modified file 'src/maas/demo.py'
--- src/maas/demo.py	2012-03-21 13:03:25 +0000
+++ src/maas/demo.py	2012-03-21 21:45:23 +0000
@@ -44,6 +44,8 @@
 
 MAAS_CLI = os.path.join(os.getcwd(), 'bin', 'maas')
 
+RABBITMQ_PUBLISH = True
+
 LOGGING = {
     'version': 1,
     'disable_existing_loggers': False,

=== modified file 'src/maas/development.py'
--- src/maas/development.py	2012-03-21 05:38:18 +0000
+++ src/maas/development.py	2012-03-21 21:45:23 +0000
@@ -45,6 +45,8 @@
 YUI_DEBUG = DEBUG
 STATIC_LOCAL_SERVE = True
 
+RABBITMQ_PUBLISH = False
+
 DATABASES = {
     'default': {
         # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' etc.

=== modified file 'src/metadataserver/tests/test_api.py'
--- src/metadataserver/tests/test_api.py	2012-03-21 05:56:36 +0000
+++ src/metadataserver/tests/test_api.py	2012-03-21 21:45:23 +0000
@@ -17,7 +17,6 @@
 from maasserver.exceptions import Unauthorized
 from maasserver.testing.factory import factory
 from maasserver.testing.oauthclient import OAuthAuthenticatedClient
-from maastesting.rabbit import uses_rabbit_fixture
 from maastesting.testcase import TestCase
 from metadataserver.api import (
     check_version,
@@ -63,7 +62,6 @@
     def test_check_version_reports_unknown_version(self):
         self.assertRaises(UnknownMetadataVersion, check_version, '1.0')
 
-    @uses_rabbit_fixture
     def test_get_node_for_request_finds_node(self):
         node = factory.make_node()
         token = NodeKey.objects.get_token_for_node(node)
@@ -108,12 +106,10 @@
     def test_no_anonymous_access(self):
         self.assertEqual(httplib.UNAUTHORIZED, self.get('/').status_code)
 
-    @uses_rabbit_fixture
     def test_metadata_index_shows_latest(self):
         client = self.make_node_client()
         self.assertIn('latest', self.get('/', client).content)
 
-    @uses_rabbit_fixture
     def test_metadata_index_shows_only_known_versions(self):
         client = self.make_node_client()
         for item in self.get('/', client).content.splitlines():
@@ -121,19 +117,16 @@
         # The test is that we get here without exception.
         pass
 
-    @uses_rabbit_fixture
     def test_version_index_shows_meta_data(self):
         client = self.make_node_client()
         items = self.get('/latest/', client).content.splitlines()
         self.assertIn('meta-data', items)
 
-    @uses_rabbit_fixture
     def test_version_index_does_not_show_user_data_if_not_available(self):
         client = self.make_node_client()
         items = self.get('/latest/', client).content.splitlines()
         self.assertNotIn('user-data', items)
 
-    @uses_rabbit_fixture
     def test_version_index_shows_user_data_if_available(self):
         node = factory.make_node()
         NodeUserData.objects.set_user_data(node, b"User data for node")
@@ -141,7 +134,6 @@
         items = self.get('/latest/', client).content.splitlines()
         self.assertIn('user-data', items)
 
-    @uses_rabbit_fixture
     def test_meta_data_view_lists_fields(self):
         client = self.make_node_client()
         response = self.get('/latest/meta-data/', client)
@@ -149,14 +141,12 @@
         self.assertItemsEqual(
             MetaDataHandler.fields, response.content.split())
 
-    @uses_rabbit_fixture
     def test_meta_data_view_is_sorted(self):
         client = self.make_node_client()
         response = self.get('/latest/meta-data/', client)
         attributes = response.content.split()
         self.assertEqual(sorted(attributes), attributes)
 
-    @uses_rabbit_fixture
     def test_meta_data_unknown_item_is_not_found(self):
         client = self.make_node_client()
         response = self.get('/latest/meta-data/UNKNOWN-ITEM-HA-HA-HA', client)
@@ -167,7 +157,6 @@
         producers = map(handler.get_attribute_producer, handler.fields)
         self.assertNotIn(None, producers)
 
-    @uses_rabbit_fixture
     def test_meta_data_local_hostname_returns_hostname(self):
         hostname = factory.getRandomString()
         client = self.make_node_client(factory.make_node(hostname=hostname))
@@ -177,7 +166,6 @@
             (response.status_code, response.content.decode('ascii')))
         self.assertIn('text/plain', response['Content-Type'])
 
-    @uses_rabbit_fixture
     def test_meta_data_instance_id_returns_system_id(self):
         node = factory.make_node()
         client = self.make_node_client(node)
@@ -187,7 +175,6 @@
             (response.status_code, response.content.decode('ascii')))
         self.assertIn('text/plain', response['Content-Type'])
 
-    @uses_rabbit_fixture
     def test_user_data_view_returns_binary_data(self):
         data = b"\x00\xff\xff\xfe\xff"
         node = factory.make_node()
@@ -199,7 +186,6 @@
         self.assertEqual(
             (httplib.OK, data), (response.status_code, response.content))
 
-    @uses_rabbit_fixture
     def test_user_data_for_node_without_user_data_returns_not_found(self):
         response = self.get('/latest/user-data', self.make_node_client())
         self.assertEqual(httplib.NOT_FOUND, response.status_code)

=== modified file 'src/metadataserver/tests/test_models.py'
--- src/metadataserver/tests/test_models.py	2012-03-17 12:24:08 +0000
+++ src/metadataserver/tests/test_models.py	2012-03-21 21:45:23 +0000
@@ -12,7 +12,6 @@
 __all__ = []
 
 from maasserver.testing.factory import factory
-from maastesting.rabbit import use_rabbit_fixture
 from maastesting.testcase import TestCase
 from metadataserver.models import (
     NodeKey,
@@ -25,7 +24,6 @@
 
     def setUp(self):
         super(TestNodeKeyManager, self).setUp()
-        use_rabbit_fixture(self)
 
     def test_get_token_for_node_registers_node_key(self):
         node = factory.make_node()
@@ -75,7 +73,6 @@
 
     def setUp(self):
         super(TestNodeUserDataManager, self).setUp()
-        use_rabbit_fixture(self)
 
     def test_set_user_data_creates_new_nodeuserdata_if_needed(self):
         node = factory.make_node()