Add Nova server console output as test failure detail
Change-Id: I00ab72b0dbde0c6d34a724d065a94cc0a3bc6f26
This commit is contained in:
parent
c6497a4d1c
commit
f59e2e441f
|
@ -415,9 +415,9 @@ class RequiredFixtureProperty(object):
|
|||
if instance is None:
|
||||
return self
|
||||
else:
|
||||
return self.get_fixture()
|
||||
return self.get_fixture(instance)
|
||||
|
||||
def get_fixture(self):
|
||||
def get_fixture(self, _instance):
|
||||
return get_fixture(self.fixture)
|
||||
|
||||
@property
|
||||
|
@ -427,5 +427,11 @@ class RequiredFixtureProperty(object):
|
|||
|
||||
class RequiredSetupFixtureProperty(RequiredFixtureProperty):
|
||||
|
||||
def get_fixture(self):
|
||||
return setup_fixture(self.fixture)
|
||||
def get_fixture(self, _instance):
|
||||
fixture = setup_fixture(self.fixture)
|
||||
if (hasattr(_instance, 'addCleanup') and
|
||||
hasattr(_instance, 'getDetails')):
|
||||
_instance.addCleanup(testtools.testcase.gather_details,
|
||||
fixture.getDetails(),
|
||||
_instance.getDetails())
|
||||
return fixture
|
||||
|
|
|
@ -18,6 +18,7 @@ from __future__ import absolute_import
|
|||
import os
|
||||
|
||||
import six
|
||||
from testtools import content
|
||||
|
||||
import tobiko
|
||||
from tobiko import config
|
||||
|
@ -175,6 +176,21 @@ class ServerStackFixture(heat.HeatStackFixture):
|
|||
def server_details(self):
|
||||
return nova.get_server(self.server_id)
|
||||
|
||||
max_console_output_length = 64 * 1024
|
||||
|
||||
def getDetails(self):
|
||||
server_id = content.Content(
|
||||
content.UTF8_TEXT, lambda: [self.server_id.encode()])
|
||||
console_output = content.Content(
|
||||
content.UTF8_TEXT, lambda: [self.console_output.encode()])
|
||||
return {self.stack_name + '.server_id': server_id,
|
||||
self.stack_name + '.console_output': console_output}
|
||||
|
||||
@property
|
||||
def console_output(self):
|
||||
return nova.get_console_output(server=self.server_id,
|
||||
length=self.max_console_output_length)
|
||||
|
||||
|
||||
class PeerServerStackFixture(ServerStackFixture):
|
||||
"""Server witch networking access requires passing by a peer Nova server
|
||||
|
|
|
@ -49,3 +49,7 @@ class CirrosServerStackTest(testtools.TestCase):
|
|||
hostname, = sh.execute(
|
||||
'hostname', ssh_client=self.stack.ssh_client).stdout.splitlines()
|
||||
self.assertEqual(hostname, self.stack.server_name)
|
||||
|
||||
def test_console_output(self):
|
||||
output = self.stack.console_output
|
||||
self.assertTrue(output)
|
||||
|
|
Loading…
Reference in New Issue