Merge "Handle the case when tempest fails"
diff --git a/.zuul.yaml b/.zuul.yaml
index e5d692d..1068175 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -5,18 +5,20 @@
     check:
       jobs:
         - cinder-tempest-plugin-lvm-lio-barbican
+        - cinder-tempest-plugin-lvm-tgt-barbican
         - cinder-tempest-plugin-cbak-ceph
     gate:
       jobs:
         - cinder-tempest-plugin-lvm-lio-barbican
+        - cinder-tempest-plugin-lvm-tgt-barbican
         - cinder-tempest-plugin-cbak-ceph
 
 - job:
-    name: cinder-tempest-plugin-lvm-lio-barbican
+    name: cinder-tempest-plugin-lvm-barbican-base
     description: |
-      This jobs configures Cinder with LVM, LIO, barbican and
-      runs tempest tests and cinderlib tests.
+      This is a base job for lvm with lio & tgt targets
     parent: devstack-tempest
+    timeout: 10800
     roles:
       - zuul: opendev.org/openstack/cinderlib
     required-projects:
@@ -37,9 +39,13 @@
       tempest_test_blacklist: '{{ ansible_user_dir }}/{{ zuul.projects["opendev.org/openstack/tempest"].src_dir }}/tools/tempest-integrated-gate-storage-blacklist.txt'
       tox_envlist: all
       devstack_localrc:
-        CINDER_ISCSI_HELPER: lioadm
         CINDER_LVM_TYPE: thin
         CINDER_COORDINATION_URL: 'file://\$state_path'
+      devstack_local_conf:
+        test-config:
+          $TEMPEST_CONFIG:
+            volume-feature-enabled:
+              volume_revert: True
       devstack_services:
         barbican: true
       tempest_plugins:
@@ -58,5 +64,39 @@
       Integration tests that runs with the ceph devstack plugin, py3
       and enable the backup service.
     vars:
+      devstack_local_conf:
+        test-config:
+          $TEMPEST_CONFIG:
+            volume-feature-enabled:
+              volume_revert: True
       devstack_services:
         c-bak: true
+
+# variant for pre-Ussuri branches (no volume revert for Ceph),
+# should this job be used on those branches
+- job:
+    name: cinder-tempest-plugin-cbak-ceph
+    branches: ^(?=stable/(ocata|pike|queens|rocky|stein|train)).*$
+    vars:
+      devstack_local_conf:
+        test-config:
+          $TEMPEST_CONFIG:
+            volume-feature-enabled:
+              volume_revert: False
+
+- job:
+    name: cinder-tempest-plugin-lvm-lio-barbican
+    description: |
+      This jobs configures Cinder with LVM, LIO, barbican and
+      runs tempest tests and cinderlib tests.
+    parent: cinder-tempest-plugin-lvm-barbican-base
+    vars:
+      devstack_localrc:
+        CINDER_ISCSI_HELPER: lioadm
+
+- job:
+    name: cinder-tempest-plugin-lvm-tgt-barbican
+    description: |
+      This jobs configures Cinder with LVM, tgt, barbican and
+      runs tempest tests and cinderlib tests.
+    parent: cinder-tempest-plugin-lvm-barbican-base
diff --git a/cinder_tempest_plugin/api/volume/test_volume_backup.py b/cinder_tempest_plugin/api/volume/test_volume_backup.py
index 3547d71..7982a83 100644
--- a/cinder_tempest_plugin/api/volume/test_volume_backup.py
+++ b/cinder_tempest_plugin/api/volume/test_volume_backup.py
@@ -67,6 +67,29 @@
         self.assertEqual(src_vol['id'], restore['volume_id'])
         self.assertEqual(backup['id'], restore['backup_id'])
 
+    @decorators.idempotent_id('b5d837b0-7066-455d-88fc-4a721a899306')
+    def test_incr_backup_create_and_restore_to_an_existing_volume(self):
+        """Test incr backup create and restore to an existing volume."""
+        # Create volume
+        src_vol = self.create_volume()
+        # Create a full backup
+        self.create_backup(volume_id=src_vol['id'])
+        # Create an inc backup
+        backup = self.create_backup(volume_id=src_vol['id'],
+                                    incremental=True)
+        # Restore to existing volume
+        restore = self.backups_client.restore_backup(
+            backup_id=backup['id'],
+            volume_id=src_vol['id'])['restore']
+        waiters.wait_for_volume_resource_status(
+            self.backups_client,
+            backup['id'], 'available')
+        waiters.wait_for_volume_resource_status(
+            self.volumes_client,
+            src_vol['id'], 'available')
+        self.assertEqual(src_vol['id'], restore['volume_id'])
+        self.assertEqual(backup['id'], restore['backup_id'])
+
     @decorators.idempotent_id('c810fe2c-cb40-43ab-96aa-471b74516a98')
     def test_incremental_backup(self):
         """Test create incremental backup."""
diff --git a/setup.cfg b/setup.cfg
index 3ee7468..9b05085 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -21,29 +21,6 @@
 packages =
     cinder_tempest_plugin
 
-[build_sphinx]
-all-files = 1
-warning-is-error = 1
-source-dir = doc/source
-build-dir = doc/build
-
-[upload_sphinx]
-upload-dir = doc/build/html
-
-[compile_catalog]
-directory = cinder_tempest_plugin/locale
-domain = cinder_tempest_plugin
-
-[update_catalog]
-domain = cinder_tempest_plugin
-output_dir = cinder_tempest_plugin/locale
-input_file = cinder_tempest_plugin/locale/cinder_tempest_plugin.pot
-
-[extract_messages]
-keywords = _ gettext ngettext l_ lazy_gettext
-mapping_file = babel.cfg
-output_file = cinder_tempest_plugin/locale/cinder_tempest_plugin.pot
-
 [entry_points]
 tempest.test_plugins =
     cinder_tests = cinder_tempest_plugin.plugin:CinderTempestPlugin
diff --git a/setup.py b/setup.py
index 566d844..cd35c3c 100644
--- a/setup.py
+++ b/setup.py
@@ -13,17 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
 import setuptools
 
-# In python < 2.7.4, a lazy loading of package `pbr` will break
-# setuptools if some other modules registered functions in `atexit`.
-# solution from: http://bugs.python.org/issue15881#msg170215
-try:
-    import multiprocessing  # noqa
-except ImportError:
-    pass
-
 setuptools.setup(
     setup_requires=['pbr>=2.0.0'],
     pbr=True)
diff --git a/test-requirements.txt b/test-requirements.txt
index af89592..bd50458 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -2,7 +2,7 @@
 # of appearance. Changing the order has an impact on the overall integration
 # process, which may cause wedges in the gate later.
 
-hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
+hacking>=3.0,<3.1 # Apache-2.0
 
 coverage!=4.4,>=4.0 # Apache-2.0
 python-subunit>=1.0.0 # Apache-2.0/BSD
diff --git a/tox.ini b/tox.ini
index 4c2edbc..be122b4 100644
--- a/tox.ini
+++ b/tox.ini
@@ -9,11 +9,10 @@
 [testenv]
 basepython = python3
 usedevelop = True
-install_command = pip install {opts} {packages}
 setenv =
    VIRTUAL_ENV={envdir}
    PYTHONWARNINGS=default::DeprecationWarning
-deps = -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
+deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
        -r{toxinidir}/test-requirements.txt
 commands = python setup.py test --slowest --testr-args='{posargs}'
 
@@ -25,8 +24,9 @@
 
 [flake8]
 # E123, E125 skipped as they are invalid PEP-8.
-
+# W503 line break before binary operator
+# W504 line break after binary operator
 show-source = True
-ignore = E123,E125
+ignore = E123,E125,W503,W504
 builtins = _
 exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build