Use gabbi inner_fixtures for better error capture

Upgrade to gabbi 1.26.1 to use the new inner_fixtures feature to
capture log and stdout/stderr per individual test request. The
existing nova fixtures are used for the capture.

Depends-On: Ic13dc14f62334aefbcced93872ec564cab157898
Change-Id: Ic6f5a50df37b4680a60c4aa94f7587aec232c367
This commit is contained in:
Chris Dent 2016-09-29 10:20:08 +00:00
parent 1fe03feb49
commit f6b72255a6
3 changed files with 12 additions and 15 deletions

View File

@ -10,7 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
import os
from gabbi import fixture
@ -38,25 +37,15 @@ class APIFixture(fixture.GabbiFixture):
self.conf = None
def start_fixture(self):
# Set up a logger for errors that will display to screen,
# otherwise gabbi failures can be hard to debug while doing
# TDD. Establish here but don't add until after the logging
# fixture is started, because that cares about handler
# ordering.
error_log = logging.StreamHandler()
error_log.setLevel(logging.ERROR)
# Set up stderr and stdout captures by directly driving the
# existing nova fixtures that do that.
# existing nova fixtures that do that. This captures the
# output that happens outside individual tests (for
# example database migrations).
self.standard_logging_fixture = fixtures.StandardLogging()
self.standard_logging_fixture.setUp()
self.output_stream_fixture = fixtures.OutputStreamCapture()
self.output_stream_fixture.setUp()
# add the error handler
# catastrophic error messages in a useful way
logging.getLogger().addHandler(error_log)
self.conf = CONF
self.conf.set_override('auth_strategy', 'noauth2')
# Be explicit about all three database connections to avoid

View File

@ -14,6 +14,7 @@ import os
from gabbi import driver
from nova.tests import fixtures as nova_fixtures
from nova.tests.functional.api.openstack.placement import fixtures
TESTS_DIR = 'gabbits'
@ -22,7 +23,14 @@ TESTS_DIR = 'gabbits'
def load_tests(loader, tests, pattern):
"""Provide a TestSuite to the discovery process."""
test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR)
# These inner fixtures provide per test request output and log
# capture, for cleaner results reporting.
inner_fixtures = [
nova_fixtures.OutputStreamCapture,
nova_fixtures.StandardLogging,
]
return driver.build_tests(test_dir, loader, host=None,
test_loader_name=__name__,
intercept=fixtures.setup_app,
inner_fixtures=inner_fixtures,
fixture_module=fixtures)

View File

@ -24,7 +24,7 @@ testtools>=1.4.0 # MIT
tempest-lib>=0.14.0 # Apache-2.0
bandit>=1.1.0 # Apache-2.0
openstackdocstheme>=1.5.0 # Apache-2.0
gabbi>=1.25.0 # Apache-2.0
gabbi>=1.26.1 # Apache-2.0
# vmwareapi driver specific dependencies
oslo.vmware>=2.11.0 # Apache-2.0