Merge "Skip the manual cleaning test if software RAID testing is enabled"
diff --git a/doc/source/conf.py b/doc/source/conf.py
index 114d4b0..87b00c8 100755
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -40,7 +40,6 @@
 master_doc = 'index'
 
 # General information about the project.
-project = u'ironic-tempest-plugin'
 copyright = u'2016, OpenStack Foundation'
 
 # If true, '()' will be appended to :func: etc. cross-reference text.
@@ -62,15 +61,15 @@
 html_theme = 'openstackdocs'
 
 # Output file base name for HTML help builder.
-htmlhelp_basename = '%sdoc' % project
+htmlhelp_basename = 'ironic-tempest-plugindoc'
 
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title, author, documentclass
 # [howto/manual]).
 latex_documents = [
     ('index',
-     '%s.tex' % project,
-     u'%s Documentation' % project,
+     'doc-ironic-tempest-plugin.tex',
+     u'Ironic Tempest Plugin Documentation',
      u'OpenStack Foundation', 'manual'),
 ]
 
diff --git a/ironic_tempest_plugin/common/waiters.py b/ironic_tempest_plugin/common/waiters.py
index 08e0941..554e5f8 100644
--- a/ironic_tempest_plugin/common/waiters.py
+++ b/ironic_tempest_plugin/common/waiters.py
@@ -45,7 +45,7 @@
 
 
 def wait_for_bm_node_status(client, node_id, attr, status, timeout=None,
-                            interval=None):
+                            interval=None, abort_on_error_state=False):
     """Waits for a baremetal node attribute to reach given status.
 
     :param client: an instance of tempest plugin BaremetalClient.
@@ -56,6 +56,8 @@
         Defaults to client.build_timeout.
     :param interval: an interval between show_node calls for status check.
         Defaults to client.build_interval.
+    :param abort_on_error_state: whether to abort waiting if the node reaches
+        an error state.
 
     The client should have a show_node(node_id) method to get the node.
     """
@@ -69,6 +71,14 @@
         node = utils.get_node(client, node_id=node_id)
         if node[attr] in status:
             return True
+        elif (abort_on_error_state
+              and node['provision_state'].endswith(' failed')):
+            raise lib_exc.TempestException(
+                'Node %(node)s reached failure state %(state)s while waiting '
+                'for %(attr)s=%(expected)s. Error: %(error)s' %
+                {'node': node_id, 'state': node['provision_state'],
+                 'attr': attr, 'expected': status,
+                 'error': node.get('last_error')})
         return False
 
     if not test_utils.call_until_true(is_attr_in_status, timeout,
diff --git a/ironic_tempest_plugin/tests/scenario/baremetal_manager.py b/ironic_tempest_plugin/tests/scenario/baremetal_manager.py
index 6d7d55b..1788463 100644
--- a/ironic_tempest_plugin/tests/scenario/baremetal_manager.py
+++ b/ironic_tempest_plugin/tests/scenario/baremetal_manager.py
@@ -104,10 +104,12 @@
         cls.baremetal_client.list_nodes()
 
     @classmethod
-    def wait_provisioning_state(cls, node_id, state, timeout=10, interval=1):
+    def wait_provisioning_state(cls, node_id, state, timeout=10, interval=1,
+                                abort_on_error_state=True):
         ironic_waiters.wait_for_bm_node_status(
             cls.baremetal_client, node_id=node_id, attr='provision_state',
-            status=state, timeout=timeout, interval=interval)
+            status=state, timeout=timeout, interval=interval,
+            abort_on_error_state=abort_on_error_state)
 
     @classmethod
     def wait_power_state(cls, node_id, state):
diff --git a/test-requirements.txt b/test-requirements.txt
index b5667d2..fb97fc6 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -6,6 +6,6 @@
 
 sphinx!=1.6.6,!=1.6.7,>=1.6.2,<2.0.0;python_version=='2.7' # BSD
 sphinx!=1.6.6,!=1.6.7,>=1.6.2;python_version>='3.4' # BSD
-openstackdocstheme>=1.18.1 # Apache-2.0
+openstackdocstheme>=1.20.0 # Apache-2.0
 
 reno>=2.5.0 # Apache-2.0
diff --git a/tox.ini b/tox.ini
index 0cc29c7..048d70b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -29,6 +29,12 @@
 basepython = python3
 commands = python setup.py build_sphinx
 
+[testenv:pdf-docs]
+basepython = python3
+whitelist_externals = make
+commands = sphinx-build -b latex doc/source doc/build/pdf
+           make -C doc/build/pdf
+
 [testenv:debug]
 basepython = python3
 commands = oslo_debug_helper {posargs}