API does not prefetch boot_disk

Bug #1840491 reported by Lee Trager
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
High
Alberto Donato

Bug Description

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

Related branches

Revision history for this message
Alberto Donato (ack) wrote :

could you show the change that makes those tests blow?

Revision history for this message
Lee Trager (ltrager) wrote :

I marked the changes in the source code with LP:1840491 to work around the issue. The attached patch should show the issues as well.

Changed in maas:
milestone: 2.7.0b1 → 2.7.0b2
Changed in maas:
milestone: 2.7.0b2 → none
Alberto Donato (ack)
Changed in maas:
assignee: nobody → Alberto Donato (ack)
milestone: none → next
status: Triaged → In Progress
Changed in maas:
status: In Progress → Fix Committed
Changed in maas:
milestone: next → 3.2.0-beta1
Changed in maas:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.