While working on a branch I noticed that factory.make_Node(with_boot_disk=True) wasn't setting node.boot_disk to the disk created. I patched factory.make_Node() to set node.boot_disk to the created disk. When I tried to land my branch a number of query count unit tests failed on the API. It seems the API isn't prefetching Node.boot_disk which causes the query count to blow up. Since most machines will have the boot_disk set MAAS should either prefetch it or only show the id.
I left my change in and patched the failed tests to run without Node.boot_disk being set.
======================================================================
FAIL: maasserver.api.tests.test_machines.TestMachinesAPI.test_GET_machines_issues_constant_number_of_queries(user=user,client=oauth)
----------------------------------------------------------------------
Traceback (most recent call last):
testtools.testresult.real._StringException: Empty attachments:
Twisted logs
Traceback (most recent call last):
File "/run/build/maas/src/maastesting/runtest.py", line 138, in _run_user
result = function(*args, **kwargs)
File "/home/ubuntu/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/testcase.py", line 719, in _run_test_method
return self._get_test_method()()
File "/run/build/maas/src/maasserver/api/tests/test_machines.py", line 430, in test_GET_machines_issues_constant_number_of_queries
self.assertEqual(DEFAULT_NUM + (10 * 6), num_queries1)
File "/home/ubuntu/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/testcase.py", line 411, in assertEqual
self.assertThat(observed, matcher, message)
File "/home/ubuntu/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/testcase.py", line 498, in assertThat
raise mismatch_error
testtools.matchers._impl.MismatchError: 123 != 303
======================================================================
FAIL: maasserver.api.tests.test_tag.TestTagAPI.test_GET_machines_query_count(user=user,client=oauth)
----------------------------------------------------------------------
Traceback (most recent call last):
testtools.testresult.real._StringException: Empty attachments:
Twisted logs
Traceback (most recent call last):
File "/run/build/maas/src/maastesting/runtest.py", line 138, in _run_user
result = function(*args, **kwargs)
File "/home/ubuntu/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/testcase.py", line 719, in _run_test_method
return self._get_test_method()()
File "/run/build/maas/src/maasserver/api/tests/test_tag.py", line 265, in test_GET_machines_query_count
self.assertEquals(num_queries1, num_queries2 - (3 * 6))
File "/home/ubuntu/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/testcase.py", line 411, in assertEqual
self.assertThat(observed, matcher, message)
File "/home/ubuntu/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/testcase.py", line 498, in assertThat
raise mismatch_error
testtools.matchers._impl.MismatchError: 133 != 187
======================================================================
FAIL: maasserver.api.tests.test_tag.TestTagAPI.test_GET_machines_query_count(user=user,client=user+pass)
----------------------------------------------------------------------
Traceback (most recent call last):
testtools.testresult.real._StringException: Empty attachments:
Twisted logs
Traceback (most recent call last):
File "/run/build/maas/src/maastesting/runtest.py", line 138, in _run_user
result = function(*args, **kwargs)
File "/home/ubuntu/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/testcase.py", line 719, in _run_test_method
return self._get_test_method()()
File "/run/build/maas/src/maasserver/api/tests/test_tag.py", line 265, in test_GET_machines_query_count
self.assertEquals(num_queries1, num_queries2 - (3 * 6))
File "/home/ubuntu/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/testcase.py", line 411, in assertEqual
self.assertThat(observed, matcher, message)
File "/home/ubuntu/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/testcase.py", line 498, in assertThat
raise mismatch_error
testtools.matchers._impl.MismatchError: 127 != 181
======================================================================
FAIL: maasserver.api.tests.test_tag.TestTagAPI.test_GET_nodes_query_count(user=user,client=oauth)
----------------------------------------------------------------------
Traceback (most recent call last):
testtools.testresult.real._StringException: Empty attachments:
Twisted logs
Traceback (most recent call last):
File "/run/build/maas/src/maastesting/runtest.py", line 138, in _run_user
result = function(*args, **kwargs)
File "/home/ubuntu/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/testcase.py", line 719, in _run_test_method
return self._get_test_method()()
File "/run/build/maas/src/maasserver/api/tests/test_tag.py", line 204, in test_GET_nodes_query_count
self.assertEquals(num_queries1, num_queries2 - (3 * 6))
File "/home/ubuntu/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/testcase.py", line 411, in assertEqual
self.assertThat(observed, matcher, message)
File "/home/ubuntu/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/testcase.py", line 498, in assertThat
raise mismatch_error
testtools.matchers._impl.MismatchError: 133 != 187
======================================================================
FAIL: maasserver.websockets.handlers.tests.test_machine.TestMachineHandler.test_get_num_queries_is_the_expected_number
----------------------------------------------------------------------
Traceback (most recent call last):
testtools.testresult.real._StringException: Empty attachments:
Twisted logs
Traceback (most recent call last):
File "/run/build/maas/src/maastesting/runtest.py", line 138, in _run_user
result = function(*args, **kwargs)
File "/home/ubuntu/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/testcase.py", line 719, in _run_test_method
return self._get_test_method()()
File "/run/build/maas/src/maasserver/websockets/handlers/tests/test_machine.py", line 635, in test_get_num_queries_is_the_expected_number
"Number of queries has changed; make sure this is expected.")
File "/home/ubuntu/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/testcase.py", line 411, in assertEqual
self.assertThat(observed, matcher, message)
File "/home/ubuntu/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/testcase.py", line 498, in assertThat
raise mismatch_error
testtools.matchers._impl.MismatchError: 50 != 49: Number of queries has changed; make sure this is expected.
======================================================================
FAIL: maasserver.api.tests.test_tag.TestTagAPI.test_GET_nodes_query_count(user=user,client=user+pass)
----------------------------------------------------------------------
Traceback (most recent call last):
testtools.testresult.real._StringException: Empty attachments:
Twisted logs
Traceback (most recent call last):
File "/run/build/maas/src/maastesting/runtest.py", line 138, in _run_user
result = function(*args, **kwargs)
File "/home/ubuntu/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/testcase.py", line 719, in _run_test_method
return self._get_test_method()()
File "/run/build/maas/src/maasserver/api/tests/test_tag.py", line 204, in test_GET_nodes_query_count
self.assertEquals(num_queries1, num_queries2 - (3 * 6))
File "/home/ubuntu/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/testcase.py", line 411, in assertEqual
self.assertThat(observed, matcher, message)
File "/home/ubuntu/.buildout/eggs/testtools-2.2.0-py3.6.egg/testtools/testcase.py", line 498, in assertThat
raise mismatch_error
testtools.matchers._impl.MismatchError: 127 != 181
could you show the change that makes those tests blow?