API tests should be fast, Scenario tests slow

In general, our API tests should aim to be fast - i.e. no waiting around for
zones to become ACTIVE etc.

On the other hand, our scenario tests should cover more real world scenarios,
for example, create a domain, waiting for it to become active, then deleting
it.

Change-Id: Id0779110cebf77db3a36ded1aef81382fbf641e0
diff --git a/designate_tempest_plugin/tests/api/v2/test_zones.py b/designate_tempest_plugin/tests/api/v2/test_zones.py
index 8bdebba..cbcd85f 100644
--- a/designate_tempest_plugin/tests/api/v2/test_zones.py
+++ b/designate_tempest_plugin/tests/api/v2/test_zones.py
@@ -16,8 +16,7 @@
 from tempest import test
 from tempest.lib import exceptions as lib_exc
 
-from designate_tempest_plugin.tests.api.v2 import base
-from designate_tempest_plugin.common import waiters
+from designate_tempest_plugin.tests import base
 
 LOG = logging.getLogger(__name__)
 
@@ -49,9 +48,6 @@
         self.assertEqual('CREATE', zone['action'])
         self.assertEqual('PENDING', zone['status'])
 
-        waiters.wait_for_zone_status(
-            self.client, zone['id'], 'ACTIVE')
-
         LOG.info('Re-Fetch the zone')
         _, body = self.client.show_zone(zone['id'])
 
@@ -62,7 +58,7 @@
     @test.idempotent_id('a4791906-6cd6-4d27-9f15-32273db8bb3d')
     def test_delete_zone(self):
         LOG.info('Create a zone')
-        _, zone = self.client.create_zone(wait_until='ACTIVE')
+        _, zone = self.client.create_zone()
         self.addCleanup(self.client.delete_zone, zone['id'],
                         ignore_errors=lib_exc.NotFound)
 
@@ -73,8 +69,6 @@
         self.assertEqual('DELETE', body['action'])
         self.assertEqual('PENDING', body['status'])
 
-        waiters.wait_for_zone_404(self.client, zone['id'])
-
     @test.attr(type='smoke')
     @test.idempotent_id('5bfa3cfe-5bc8-443b-bf48-cfba44cbb247')
     def test_list_zones(self):
@@ -86,12 +80,11 @@
         self.assertEqual('CREATE', zone['action'])
         self.assertEqual('PENDING', zone['status'])
 
-        waiters.wait_for_zone_status(
-            self.client, zone['id'], 'ACTIVE')
-
         LOG.info('List zones')
         _, body = self.client.list_zones()
 
+        # TODO(kiall): We really want to assert that out newly created zone is
+        #              present in the response.
         self.assertTrue(len(body['zones']) > 0)
 
     @test.attr(type='smoke')
@@ -105,20 +98,13 @@
         self.assertEqual('CREATE', zone['action'])
         self.assertEqual('PENDING', zone['status'])
 
-        waiters.wait_for_zone_status(
-            self.client, zone['id'], 'ACTIVE')
-
         LOG.info('Update the zone')
         resp, body = self.client.update_zone(zone['id'])
 
+        self.assertEqual(202, resp.status)
         self.assertEqual('UPDATE', body['action'])
         self.assertEqual('PENDING', body['status'])
 
-        waiters.wait_for_zone_status(
-            self.client, body['id'], 'ACTIVE')
-
-        self.assertEqual(202, resp.status)
-
 
 class ZonesAdminTest(BaseZonesTest):
     credentials = ['primary', 'admin']
@@ -145,6 +131,7 @@
 
 
 class ZoneOwnershipTest(BaseZonesTest):
+    credentials = ['primary', 'alt']
 
     @classmethod
     def setup_clients(cls):
@@ -164,9 +151,6 @@
         self.assertEqual('CREATE', zone['action'])
         self.assertEqual('PENDING', zone['status'])
 
-        waiters.wait_for_zone_status(
-            self.client, zone['id'], 'ACTIVE')
-
         LOG.info('Create a zone as an alt user with existing domain')
         self.assertRaises(lib_exc.Conflict,
             self.alt_client.create_zone, name=zone['name'])
@@ -182,9 +166,6 @@
         self.assertEqual('CREATE', zone['action'])
         self.assertEqual('PENDING', zone['status'])
 
-        waiters.wait_for_zone_status(
-            self.client, zone['id'], 'ACTIVE')
-
         LOG.info('Create a zone as an alt user with  existing subdomain')
         self.assertRaises(lib_exc.Forbidden,
             self.alt_client.create_zone, name='sub.' + zone['name'])
@@ -202,9 +183,6 @@
         self.assertEqual('CREATE', zone['action'])
         self.assertEqual('PENDING', zone['status'])
 
-        waiters.wait_for_zone_status(
-            self.client, zone['id'], 'ACTIVE')
-
         LOG.info('Create a zone as an alt user with existing superdomain')
         self.assertRaises(lib_exc.Forbidden,
             self.alt_client.create_zone, name='example.com.')
diff --git a/designate_tempest_plugin/tests/api/v2/base.py b/designate_tempest_plugin/tests/base.py
similarity index 86%
rename from designate_tempest_plugin/tests/api/v2/base.py
rename to designate_tempest_plugin/tests/base.py
index f7634c1..5bdd0c7 100644
--- a/designate_tempest_plugin/tests/api/v2/base.py
+++ b/designate_tempest_plugin/tests/base.py
@@ -17,7 +17,7 @@
 
 
 class BaseDnsTest(test.BaseTestCase):
-    """Base class for DNS API v2 tests."""
+    """Base class for DNS tests."""
 
     # Use the Designate Client Manager
     client_manager = clients.Manager
@@ -28,4 +28,6 @@
     # rest the actual roles.
     # NOTE(kiall) primary will result in a manager @ cls.os, alt will have
     # cls.os_alt, and admin will have cls.os_adm.
-    credentials = ['primary', 'alt', 'admin']
+    # NOTE(kiall) We should default to only primary, and request additional
+    # credentials in the tests that require them.
+    credentials = ['primary']
diff --git a/designate_tempest_plugin/tests/scenario/v2/__init__.py b/designate_tempest_plugin/tests/scenario/v2/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/designate_tempest_plugin/tests/scenario/v2/__init__.py
diff --git a/designate_tempest_plugin/tests/scenario/v2/test_zones.py b/designate_tempest_plugin/tests/scenario/v2/test_zones.py
new file mode 100644
index 0000000..507a9ba
--- /dev/null
+++ b/designate_tempest_plugin/tests/scenario/v2/test_zones.py
@@ -0,0 +1,60 @@
+# Copyright 2016 Hewlett Packard Enterprise Development Company, L.P.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+from oslo_log import log as logging
+from tempest import test
+from tempest.lib import exceptions as lib_exc
+
+from designate_tempest_plugin.tests import base
+from designate_tempest_plugin.common import waiters
+
+LOG = logging.getLogger(__name__)
+
+
+class ZonesTest(base.BaseDnsTest):
+    @classmethod
+    def setup_clients(cls):
+        super(ZonesTest, cls).setup_clients()
+
+        cls.client = cls.os.zones_client
+
+    @test.attr(type='slow')
+    @test.idempotent_id('d0648f53-4114-45bd-8792-462a82f69d32')
+    def test_create_and_delete_zone(self):
+        LOG.info('Create a zone')
+        _, zone = self.client.create_zone()
+        self.addCleanup(self.client.delete_zone, zone['id'],
+                        ignore_errors=lib_exc.NotFound)
+
+        LOG.info('Ensure we respond with CREATE+PENDING')
+        self.assertEqual('CREATE', zone['action'])
+        self.assertEqual('PENDING', zone['status'])
+
+        waiters.wait_for_zone_status(
+            self.client, zone['id'], 'ACTIVE')
+
+        LOG.info('Re-Fetch the zone')
+        _, zone = self.client.show_zone(zone['id'])
+
+        LOG.info('Ensure we respond with NONE+PENDING')
+        self.assertEqual('NONE', zone['action'])
+        self.assertEqual('ACTIVE', zone['status'])
+
+        LOG.info('Delete the zone')
+        _, zone = self.client.delete_zone(zone['id'])
+
+        LOG.info('Ensure we respond with DELETE+PENDING')
+        self.assertEqual('DELETE', zone['action'])
+        self.assertEqual('PENDING', zone['status'])
+
+        waiters.wait_for_zone_404(self.client, zone['id'])