Browse Source

Add recordset scenario test

There is a need to run the recordset tests without using admin credential,
an existing zone, which shall be configured as the precondition in
tempest.conf, will be used to test the creation and deletion of
recordsets.

Change-Id: I3ae09176d410b9ed6437b8e55ace67cad0d5b5b9
Rocky 1 year ago
parent
commit
9e764827c8

+ 3
- 0
designate_tempest_plugin/config.py View File

@@ -49,6 +49,9 @@ DnsGroup = [
49 49
     cfg.IntOpt('query_timeout',
50 50
                default=1,
51 51
                help="The timeout on a single dns query to a nameserver"),
52
+    cfg.StrOpt('zone_id',
53
+               help="The target zone to test the dns recordsets "
54
+                    "If it is not specified, a new zone will be created ")
52 55
 
53 56
 ]
54 57
 

+ 101
- 0
designate_tempest_plugin/tests/scenario/v2/test_recordsets.py View File

@@ -0,0 +1,101 @@
1
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
2
+# not use this file except in compliance with the License. You may obtain
3
+# a copy of the License at
4
+#
5
+#      http://www.apache.org/licenses/LICENSE-2.0
6
+#
7
+# Unless required by applicable law or agreed to in writing, software
8
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+# License for the specific language governing permissions and limitations
11
+# under the License.
12
+from oslo_log import log as logging
13
+from tempest import config
14
+from tempest.lib.common.utils import test_utils
15
+from tempest.lib import decorators
16
+from tempest.lib import exceptions as lib_exc
17
+import ddt
18
+
19
+from designate_tempest_plugin.tests import base
20
+from designate_tempest_plugin.common import waiters
21
+
22
+
23
+LOG = logging.getLogger(__name__)
24
+
25
+CONF = config.CONF
26
+
27
+
28
+@ddt.ddt
29
+class RecordsetsTest(base.BaseDnsV2Test):
30
+    @classmethod
31
+    def setup_clients(cls):
32
+        super(RecordsetsTest, cls).setup_clients()
33
+
34
+        cls.client = cls.os_primary.zones_client
35
+        cls.recordset_client = cls.os_primary.recordset_client
36
+        cls.query_client = cls.os_primary.query_client
37
+
38
+    @classmethod
39
+    def resource_setup(cls):
40
+        super(RecordsetsTest, cls).resource_setup()
41
+
42
+        zone_id = CONF.dns.zone_id
43
+        if zone_id:
44
+            LOG.info('Retrieve info from a zone')
45
+            _, zone = cls.client.show_zone(zone_id)
46
+        else:
47
+            LOG.info('Create a new zone')
48
+            _, zone = cls.client.create_zone()
49
+            cls.addClassResourceCleanup(
50
+                test_utils.call_and_ignore_notfound_exc,
51
+                cls.client.delete_zone, zone['id'])
52
+
53
+        LOG.info('Ensure we respond with ACTIVE')
54
+        waiters.wait_for_zone_status(cls.client, zone['id'], 'ACTIVE')
55
+
56
+        cls.zone = zone
57
+
58
+    @decorators.attr(type='slow')
59
+    @decorators.idempotent_id('4664ed66-9ff1-45f2-9e60-d4913195c505')
60
+    @ddt.file_data("../../api/v2/recordset_data.json")
61
+    def test_create_and_delete_records_on_existing_zone(self, name,
62
+                                                        type, records):
63
+        if name is not None:
64
+            recordset_name = name + "." + self.zone['name']
65
+
66
+        else:
67
+            recordset_name = self.zone['name']
68
+
69
+        recordset_data = {
70
+            'name': recordset_name,
71
+            'type': type,
72
+            'records': records,
73
+        }
74
+
75
+        LOG.info('Create a Recordset on the existing zone')
76
+        _, recordset = self.recordset_client.create_recordset(
77
+            self.zone['id'], recordset_data)
78
+        self.addCleanup(test_utils.call_and_ignore_notfound_exc,
79
+                        self.recordset_client.delete_recordset,
80
+                        self.zone['id'], recordset['id'])
81
+
82
+        LOG.info('Ensure we respond with PENDING')
83
+        self.assertEqual('PENDING', recordset['status'])
84
+
85
+        LOG.info('Wait until the recordset is active')
86
+        waiters.wait_for_recordset_status(self.recordset_client,
87
+                                          self.zone['id'], recordset['id'],
88
+                                          'ACTIVE')
89
+
90
+        LOG.info('Delete the recordset')
91
+        _, body = self.recordset_client.delete_recordset(self.zone['id'],
92
+                                                         recordset['id'])
93
+
94
+        LOG.info('Ensure we respond with DELETE+PENDING')
95
+        self.assertEqual('DELETE', body['action'])
96
+        self.assertEqual('PENDING', body['status'])
97
+
98
+        LOG.info('Ensure successful deletion of Recordset')
99
+        self.assertRaises(lib_exc.NotFound,
100
+                          lambda: self.recordset_client.show_recordset(
101
+                              self.zone['id'], recordset['id']))

Loading…
Cancel
Save