def test_list_filter_zones_recordsets(self): recordset_data = data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name'], records=['10.0.1.2']) LOG.info('Create a Recordset') resp, zone_recordset = self.client.create_recordset( self.zone['id'], recordset_data) LOG.info('Create another zone') _, zone2 = self.zone_client.create_zone() self.addCleanup(self.zone_client.delete_zone, zone2['id']) LOG.info('Create another Recordset') recordset_data = data_utils.rand_recordset_data( record_type='A', zone_name=zone2['name'], records=['10.0.1.3']) resp, zone_recordset2 = self.client.create_recordset( zone2['id'], recordset_data) LOG.info('List recordsets') _, body = self.client.list_zones_recordsets(params={"data": "10.0.*"}) recordsets = body['recordsets'] ids = [r['id'] for r in recordsets] self.assertIn(zone_recordset['id'], ids) self.assertIn(zone_recordset2['id'], ids) # Ensure that every rrset has a record with the filtered data for r in recordsets: one_record_has_data = False for record in r['records']: if record.startswith('10.0.'): one_record_has_data = True self.assertTrue(one_record_has_data)
def test_update_recordset(self): recordset_data = dns_data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name']) LOG.info('Create a recordset') record = self.client.create_recordset(self.zone['id'], recordset_data)[1] recordset_id = record['id'] self.addCleanup(self.wait_recordset_delete, self.client, self.zone['id'], recordset_id) recordset_data = dns_data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name'], name=record['name']) LOG.info('Update the recordset') update = self.client.update_recordset(self.zone['id'], recordset_id, recordset_data)[1] self.assertEqual(record['name'], update['name']) self.assertNotEqual(record['records'], update['records']) # Test RBAC expected_allowed = ['os_admin', 'os_primary'] if CONF.dns_feature_enabled.enforce_new_defaults: expected_allowed.append('os_system_admin') self.check_CUD_RBAC_enforcement('RecordsetClient', 'update_recordset', expected_allowed, True, self.zone['id'], recordset_id, recordset_data) # Test RBAC with x-auth-all-projects and x-auth-sudo-project-id header expected_allowed = ['os_admin', 'os_primary'] if CONF.dns_feature_enabled.enforce_new_defaults: expected_allowed.append('os_system_admin') self.check_CUD_RBAC_enforcement('RecordsetClient', 'update_recordset', expected_allowed, False, self.zone['id'], recordset_id, recordset_data, headers=self.all_projects_header) self.check_CUD_RBAC_enforcement( 'RecordsetClient', 'update_recordset', expected_allowed, False, self.zone['id'], recordset_id, recordset_data, headers={'x-auth-sudo-project-id': self.client.project_id})
def test_admin_list_all_recordsets_for_a_project(self): LOG.info('Create a Recordset as Primary tenant') recordset_data_primary_1 = dns_data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name']) body_pr_1 = self.client.create_recordset(self.zone['id'], recordset_data_primary_1)[1] self.addCleanup(self.wait_recordset_delete, self.client, self.zone['id'], body_pr_1['id']) self.assertEqual(const.PENDING, body_pr_1['status'], 'Failed, expected status is PENDING') recordset_data_primary_2 = dns_data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name']) body_pr_2 = self.client.create_recordset(self.zone['id'], recordset_data_primary_2)[1] self.addCleanup(self.wait_recordset_delete, self.client, self.zone['id'], body_pr_2['id']) self.assertEqual(const.PENDING, body_pr_2['status'], 'Failed, expected status is PENDING') LOG.info('Re-Fetch Recordsets as Alt tenant for a Primary project. ' 'Expected: 404') self.assertRaises( lib_exc.NotFound, lambda: self.alt_client.list_recordset(self.zone['id'])) LOG.info('Re-Fetch Recordsets as Alt tenant for a Primary project ' 'using "x-auth-all-projects" HTTP header. Expected: 403') self.assertRaises( lib_exc.Forbidden, lambda: self.alt_client.list_recordset( self.zone['id'], headers=self.all_projects_header)) LOG.info('Re-Fetch Recordsets as Admin tenant for a Primary project ' 'using "x-auth-all-projects" HTTP header.') # Note: This is an all-projects list call, so other tests running # in parallel will impact the list result set. Since the default # pagination limit is only 20, we set a param limit of 1000 here. primary_recordsets_ids = [ item['id'] for item in self.admin_client.list_recordset( self.zone['id'], headers=self.all_projects_header, params={'limit': 1000})[1]['recordsets'] ] for recordset_id in [body_pr_1['id'], body_pr_2['id']]: self.assertIn( recordset_id, primary_recordsets_ids, 'Failed, recordset ID:{} was not found in listed ' 'recordsets: {}'.format(recordset_id, primary_recordsets_ids))
def test_show_recordsets_invalid_ids(self): LOG.info('Create a Recordset') recordset_data = dns_data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name']) resp, body = self.client.create_recordset(self.zone['id'], recordset_data) self.addCleanup(self.wait_recordset_delete, self.client, self.zone['id'], body['id']) self.assertEqual(const.PENDING, body['status'], 'Failed, expected status is PENDING') LOG.info('Wait until the recordset is active') waiters.wait_for_recordset_status(self.client, self.zone['id'], body['id'], const.ACTIVE) LOG.info('Ensure 404 NotFound status code is received if ' 'recordset ID is invalid.') self.assertRaises( lib_exc.NotFound, lambda: self.client.show_recordset( zone_uuid=self.zone['id'], recordset_uuid=data_utils.rand_uuid())) LOG.info('Ensure 404 NotFound status code is received if ' 'zone ID is invalid.') self.assertRaises( lib_exc.NotFound, lambda: self.client.show_recordset( zone_uuid=data_utils.rand_uuid(), recordset_uuid=body['id']))
def test_delete_zone_with_existing_recordset(self): LOG.info('Create a Zone') zone_name = dns_data_utils.rand_zone_name(name="TestZone", suffix=self.tld_name) zone = self.zone_client.create_zone(name=zone_name, wait_until=const.ACTIVE)[1] self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id']) LOG.info('Create a Recordset') recordset_data = dns_data_utils.rand_recordset_data( record_type='A', zone_name=zone['name']) record = self.client.create_recordset(zone['id'], recordset_data, wait_until=const.ACTIVE)[1] LOG.info("Delete a Zone and wait till it's done") body = self.zone_client.delete_zone(zone['id'])[1] LOG.info('Ensure we respond with DELETE+PENDING') self.assertEqual(const.DELETE, body['action']) self.assertEqual(const.PENDING, body['status']) LOG.info('Ensure successful deletion of Zone') waiters.wait_for_zone_404(self.zone_client, zone['id']) LOG.info('Ensure successful deletion of Recordset') self.assertRaises( lib_exc.NotFound, lambda: self.client.show_recordset(zone['id'], record['id']))
def test_update_recordset(self): recordset_data = data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name']) LOG.info('Create a recordset') _, record = self.client.create_recordset(self.zone['id'], recordset_data) recordset_data = data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name'], name=record['name']) LOG.info('Update the recordset') _, update = self.client.update_recordset(self.zone['id'], record['id'], recordset_data) self.assertEqual(record['name'], update['name']) self.assertNotEqual(record['records'], update['records'])
def test_update_nonexistent_recordset_invalid_id(self): recordset_data = dns_data_utils.rand_recordset_data( 'A', self.zone['name']) LOG.info('Attempt to update an invalid Recordset') with self.assertRaisesDns(lib_exc.BadRequest, 'invalid_uuid', 400): self.client.update_recordset(self.zone['id'], 'invalid', recordset_data)
def test_create_recordset_for_other_tenant(self): recordset_data = dns_data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name']) LOG.info('Create a Recordset as Alt tenant for a zone created by ' 'Primary tenant. Expected: 404 NotFound') self.assertRaises( lib_exc.NotFound, lambda: self.alt_client.create_recordset( self.zone['id'], recordset_data))
def test_get_single_zones_recordsets(self): recordset_data = data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name'], records=['10.1.0.2']) LOG.info('Create a Recordset') resp, zone_recordset = self.client.create_recordset( self.zone['id'], recordset_data) self.client.show_zones_recordset(zone_recordset['id'])
def test_no_create_recordset_by_alt_tenant(self): # try with name=A123456.zone.com. recordset_data = data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name']) resp, rrset = self.client.create_recordset(self.zone['id'], recordset_data) self.assertRaises( lib_exc.RestClientException, lambda: self.alt_client. create_recordset(self.zone['id'], recordset_data))
def test_update_nonexistent_recordset_invalid_id(self): LOG.info('Create a zone') _, zone = self.zone_client.create_zone() self.addCleanup(self.zone_client.delete_zone, zone['id']) recordset_data = data_utils.rand_recordset_data('A', zone['name']) LOG.info('Attempt to update an invalid Recordset') with self.assertRaisesDns(lib_exc.BadRequest, 'invalid_uuid', 400): self.client.update_recordset(zone['id'], 'invalid', recordset_data)
def test_update_nonexistent_recordset(self): recordset_data = dns_data_utils.rand_recordset_data( 'A', self.zone['name']) LOG.info('Attempt to update an invalid Recordset') with self.assertRaisesDns(lib_exc.NotFound, 'recordset_not_found', 404): self.client.update_recordset(self.zone['id'], data_utils.rand_uuid(), recordset_data)
def test_create_recordset(self): recordset_data = data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name']) LOG.info('Create a Recordset') resp, body = self.client.create_recordset(self.zone['id'], recordset_data) LOG.info('Ensure we respond with PENDING') self.assertEqual('PENDING', body['status'])
def test_update_recordset(self): LOG.info('Create a zone') _, zone = self.zone_client.create_zone() self.addCleanup(self.zone_client.delete_zone, zone['id']) recordset_data = data_utils.rand_recordset_data( record_type='A', zone_name=zone['name']) LOG.info('Create a recordset') _, record = self.client.create_recordset(zone['id'], recordset_data) recordset_data = data_utils.rand_recordset_data( record_type='A', zone_name=zone['name'], name=record['name']) LOG.info('Update the recordset') _, update = self.client.update_recordset(zone['id'], record['id'], recordset_data) self.assertEqual(record['name'], update['name']) self.assertNotEqual(record['records'], update['records'])
def test_list_recordsets(self): recordset_data = data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name']) LOG.info('Create a Recordset') resp, body = self.client.create_recordset(self.zone['id'], recordset_data) LOG.info('List zone recordsets') _, body = self.client.list_recordset(self.zone['id']) self.assertGreater(len(body), 0)
def test_create_recordset(self): LOG.info('Create a zone') _, zone = self.zone_client.create_zone() self.addCleanup(self.zone_client.delete_zone, zone['id']) recordset_data = data_utils.rand_recordset_data( record_type='A', zone_name=zone['name']) LOG.info('Create a Recordset') resp, body = self.client.create_recordset(zone['id'], recordset_data) LOG.info('Ensure we respond with PENDING') self.assertEqual('PENDING', body['status'])
def test_update_nonexistent_recordset(self): LOG.info('Create a zone') _, zone = self.zone_client.create_zone() self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id']) recordset_data = data_utils.rand_recordset_data('A', zone['name']) LOG.info('Attempt to update an invalid Recordset') with self.assertRaisesDns(lib_exc.NotFound, 'recordset_not_found', 404): self.client.update_recordset(zone['id'], lib_data_utils.rand_uuid(), recordset_data)
def test_no_create_super_recordsets(self): zone_name = data_utils.rand_zone_name() LOG.info('Create a zone as a default user') _, zone = self.zone_client.create_zone(name='a.b.' + zone_name) self.addCleanup(self.zone_client.delete_zone, zone['id']) rrset_data = data_utils.rand_recordset_data(record_type='A', zone_name=zone_name) LOG.info('Create a zone as an alt user with existing superdomain') self.assertRaises(lib_exc.NotFound, self.alt_client.create_recordset, self.zone['id'], rrset_data)
def test_show_recordsets(self): recordset_data = data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name']) LOG.info('Create a Recordset') resp, body = self.client.create_recordset(self.zone['id'], recordset_data) LOG.info('Re-Fetch the Recordset') _, record = self.client.show_recordset(self.zone['id'], body['id']) LOG.info('Ensure the fetched response matches the expected one') self.assertExpected(body, record, self.excluded_keys)
def test_list_recordsets(self): recordset_data = dns_data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name']) LOG.info('Create a Recordset') resp, body = self.client.create_recordset(self.zone['id'], recordset_data) recordset_id = body['id'] self.addCleanup(self.wait_recordset_delete, self.client, self.zone['id'], recordset_id) LOG.info('List zone recordsets') body = self.client.list_recordset(self.zone['id'])[1] self.assertGreater(len(body), 0) # TODO(johnsom) Test reader role once this bug is fixed: # https://bugs.launchpad.net/tempest/+bug/1964509 # Test RBAC expected_allowed = ['os_primary'] self.check_list_show_RBAC_enforcement('RecordsetClient', 'list_recordset', expected_allowed, True, self.zone['id']) # Test that users who should see the zone, can see it. expected_allowed = ['os_primary'] self.check_list_IDs_RBAC_enforcement('RecordsetClient', 'list_recordset', expected_allowed, [recordset_id], self.zone['id']) # Test RBAC with x-auth-all-projects and x-auth-sudo-project-id header if CONF.dns_feature_enabled.enforce_new_defaults: expected_allowed = ['os_system_admin'] else: expected_allowed = ['os_admin'] self.check_list_IDs_RBAC_enforcement('RecordsetClient', 'list_recordset', expected_allowed, [recordset_id], self.zone['id'], headers=self.all_projects_header) self.check_list_IDs_RBAC_enforcement( 'RecordsetClient', 'list_recordset', expected_allowed, [recordset_id], self.zone['id'], headers={'x-auth-sudo-project-id': self.client.project_id})
def test_no_create_recordset_via_alt_domain(self): _, zone = self.zone_client.create_zone() _, alt_zone = self.alt_zone_client.create_zone() # alt attempts to create record with name A12345.{zone} recordset_data = data_utils.rand_recordset_data(record_type='A', zone_name=zone['name']) self.assertRaises( lib_exc.RestClientException, lambda: self.alt_client. create_recordset(zone['id'], recordset_data)) self.assertRaises( lib_exc.RestClientException, lambda: self.alt_client. create_recordset(alt_zone['id'], recordset_data))
def test_delete_recordset(self): recordset_data = dns_data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name']) LOG.info('Create a Recordset') record = self.client.create_recordset(self.zone['id'], recordset_data)[1] recordset_id = record['id'] self.addCleanup(self.wait_recordset_delete, self.client, self.zone['id'], recordset_id) # Test RBAC expected_allowed = ['os_admin', 'os_primary'] if CONF.dns_feature_enabled.enforce_new_defaults: expected_allowed.append('os_system_admin') self.check_CUD_RBAC_enforcement('RecordsetClient', 'delete_recordset', expected_allowed, True, self.zone['id'], recordset_id) # Test RBAC with x-auth-all-projects and x-auth-sudo-project-id header expected_allowed = ['os_admin', 'os_primary'] if CONF.dns_feature_enabled.enforce_new_defaults: expected_allowed.append('os_system_admin') self.check_CUD_RBAC_enforcement('RecordsetClient', 'delete_recordset', expected_allowed, False, self.zone['id'], recordset_id, headers=self.all_projects_header) self.check_CUD_RBAC_enforcement( 'RecordsetClient', 'delete_recordset', expected_allowed, False, self.zone['id'], recordset_id, headers={'x-auth-sudo-project-id': self.client.project_id}) LOG.info('Delete a Recordset') self.client.delete_recordset(self.zone['id'], recordset_id) LOG.info('Ensure successful deletion of Recordset') self.assertRaises( lib_exc.NotFound, lambda: self.client.show_recordset(self.zone['id'], recordset_id))
def test_delete_recordset(self): recordset_data = data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name']) LOG.info('Create a Recordset') _, record = self.client.create_recordset(self.zone['id'], recordset_data) LOG.info('Delete a Recordset') _, body = self.client.delete_recordset(self.zone['id'], record['id']) LOG.info('Ensure successful deletion of Recordset') self.assertRaises( lib_exc.NotFound, lambda: self.client.show_recordset(self.zone['id'], record['id']))
def test_list_recordsets(self): LOG.info('Create a zone') _, zone = self.zone_client.create_zone() self.addCleanup(self.zone_client.delete_zone, zone['id']) recordset_data = data_utils.rand_recordset_data( record_type='A', zone_name=zone['name']) LOG.info('Create a Recordset') resp, body = self.client.create_recordset(zone['id'], recordset_data) LOG.info('List zone recordsets') _, body = self.client.list_recordset(zone['id']) self.assertGreater(len(body), 0)
def test_show_recordsets(self): recordset_data = dns_data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name']) LOG.info('Create a Recordset') resp, body = self.client.create_recordset(self.zone['id'], recordset_data) recordset_id = body['id'] self.addCleanup(self.wait_recordset_delete, self.client, self.zone['id'], recordset_id) LOG.info('Re-Fetch the Recordset') record = self.client.show_recordset(self.zone['id'], recordset_id)[1] LOG.info('Ensure the fetched response matches the expected one') self.assertExpected(body, record, self.excluded_keys) # TODO(johnsom) Test reader role once this bug is fixed: # https://bugs.launchpad.net/tempest/+bug/1964509 # Test RBAC expected_allowed = ['os_primary'] self.check_list_show_RBAC_enforcement('RecordsetClient', 'show_recordset', expected_allowed, True, self.zone['id'], recordset_id) # Test RBAC with x-auth-all-projects and x-auth-sudo-project-id header if CONF.dns_feature_enabled.enforce_new_defaults: expected_allowed = ['os_system_admin'] else: expected_allowed = ['os_admin'] self.check_list_show_RBAC_enforcement('RecordsetClient', 'show_recordset', expected_allowed, True, self.zone['id'], recordset_id, headers=self.all_projects_header) self.check_list_show_RBAC_enforcement( 'RecordsetClient', 'show_recordset', expected_allowed, True, self.zone['id'], recordset_id, headers={'x-auth-sudo-project-id': self.client.project_id})
def test_show_recordsets(self): LOG.info('Create a zone') _, zone = self.zone_client.create_zone() self.addCleanup(self.zone_client.delete_zone, zone['id']) recordset_data = data_utils.rand_recordset_data( record_type='A', zone_name=zone['name']) LOG.info('Create a Recordset') resp, body = self.client.create_recordset(zone['id'], recordset_data) LOG.info('Re-Fetch the Recordset') _, record = self.client.show_recordset(zone['id'], body['id']) LOG.info('Ensure the fetched response matches the expected one') self.assertExpected(body, record, self.excluded_keys)
def test_no_create_recordset_via_alt_domain(self): zone_name = dns_data_utils.rand_zone_name(name="alt-domain", suffix=self.tld_name) alt_zone = self.alt_zone_client.create_zone(name=zone_name)[1] self.addCleanup(self.wait_zone_delete, self.alt_zone_client, alt_zone['id']) # alt attempts to create record with name A12345.{zone} recordset_data = dns_data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name']) self.assertRaises( lib_exc.RestClientException, lambda: self.alt_client. create_recordset(self.zone['id'], recordset_data)) self.assertRaises( lib_exc.RestClientException, lambda: self.alt_client. create_recordset(alt_zone['id'], recordset_data))
def test_delete_recordset(self): LOG.info('Create a zone') _, zone = self.zone_client.create_zone() self.addCleanup(self.zone_client.delete_zone, zone['id']) recordset_data = data_utils.rand_recordset_data( record_type='A', zone_name=zone['name']) LOG.info('Create a Recordset') _, record = self.client.create_recordset(zone['id'], recordset_data) LOG.info('Delete a Recordset') _, body = self.client.delete_recordset(zone['id'], record['id']) LOG.info('Ensure successful deletion of Recordset') self.assertRaises(lib_exc.NotFound, lambda: self.client.show_recordset(zone['id'], record['id']))
def test_update_recordset_one_field(self): recordset_data = data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name']) LOG.info('Create a recordset') _, record = self.client.create_recordset(self.zone['id'], recordset_data) recordset_data = {'ttl': data_utils.rand_ttl(start=record['ttl'] + 1)} LOG.info('Update the recordset') _, update = self.client.update_recordset(self.zone['id'], record['id'], recordset_data) self.assertEqual(record['name'], update['name']) self.assertEqual(record['records'], update['records']) self.assertEqual(record['description'], update['description']) self.assertNotEqual(record['ttl'], update['ttl'])
def test_create_recordset(self): recordset_data = dns_data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name']) # Test RBAC expected_allowed = ['os_admin', 'os_primary', 'os_alt'] if CONF.dns_feature_enabled.enforce_new_defaults: expected_allowed.append('os_system_admin') expected_allowed.append('os_project_member') self.check_CUD_RBAC_enforcement('RecordsetClient', 'create_recordset', expected_allowed, True, self.zone['id'], recordset_data) LOG.info('Create a Recordset') resp, body = self.client.create_recordset(self.zone['id'], recordset_data) self.addCleanup(self.wait_recordset_delete, self.client, self.zone['id'], body['id']) LOG.info('Ensure we respond with PENDING') self.assertEqual(const.PENDING, body['status'])
def test_show_recordsets_impersonate_another_project(self): LOG.info('Create a Recordset') recordset_data = dns_data_utils.rand_recordset_data( record_type='A', zone_name=self.zone['name']) resp, body = self.client.create_recordset(self.zone['id'], recordset_data) self.addCleanup(self.wait_recordset_delete, self.client, self.zone['id'], body['id']) self.assertEqual(const.PENDING, body['status'], 'Failed, expected status is PENDING') LOG.info('Wait until the recordset is active') waiters.wait_for_recordset_status(self.client, self.zone['id'], body['id'], const.ACTIVE) LOG.info('Re-Fetch the Recordset as Alt tenant with ' '"x-auth-sudo-project-id" HTTP header included in request. ' 'Expected: 403') self.assertRaises( lib_exc.Forbidden, lambda: self.alt_client.show_recordset( self.zone['id'], body['id'], headers={'x-auth-sudo-project-id': body['project_id']})) LOG.info('Re-Fetch the Recordset as Admin tenant without ' '"x-auth-sudo-project-id" HTTP header. Expected: 404') self.assertRaises( lib_exc.NotFound, lambda: self.admin_client.show_recordset( self.zone['id'], body['id'])) record = self.admin_client.show_recordset( self.zone['id'], body['id'], headers={'x-auth-sudo-project-id': body['project_id']})[1] LOG.info('Ensure the fetched response matches the expected one') self.assertExpected(body, record, self.excluded_keys + ['action', 'status'])
def _create_client_recordset(self, clients_list): """Create a zone and asoociated recordset using given credentials :param clients_list: supported credentials are: 'primary' and 'alt'. :return: dictionary of created recordsets. """ recordsets_created = {} for client in clients_list: if client == 'primary': # Create a zone and wait till it's ACTIVE zone_name = dns_data_utils.rand_zone_name(name="primary", suffix=self.tld_name) zone = self.zone_client.create_zone(name=zone_name)[1] self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id']) waiters.wait_for_zone_status(self.zone_client, zone['id'], const.ACTIVE) # Create a recordset and wait till it's ACTIVE recordset_data = dns_data_utils.rand_recordset_data( record_type='A', zone_name=zone['name']) resp, body = self.client.create_recordset( zone['id'], recordset_data) self.addCleanup(self.wait_recordset_delete, self.client, self.zone['id'], body['id']) self.assertEqual(const.PENDING, body['status'], 'Failed, expected status is PENDING') LOG.info('Wait until the recordset is active') waiters.wait_for_recordset_status(self.client, zone['id'], body['id'], const.ACTIVE) # Add "project_id" into the recordset_data recordset_data['project_id'] = zone['project_id'] recordsets_created['primary'] = recordset_data if client == 'alt': # Create a zone and wait till it's ACTIVE zone_name = dns_data_utils.rand_zone_name(name="alt", suffix=self.tld_name) alt_zone = self.alt_zone_client.create_zone(name=zone_name)[1] self.addCleanup(self.wait_zone_delete, self.alt_zone_client, alt_zone['id']) waiters.wait_for_zone_status(self.alt_zone_client, alt_zone['id'], const.ACTIVE) # Create a recordset and wait till it's ACTIVE recordset_data = dns_data_utils.rand_recordset_data( record_type='A', zone_name=alt_zone['name']) resp, body = self.alt_client.create_recordset( alt_zone['id'], recordset_data) self.addCleanup(self.wait_recordset_delete, self.client, self.zone['id'], body['id']) self.assertEqual(const.PENDING, body['status'], 'Failed, expected status is PENDING') LOG.info('Wait until the recordset is active') waiters.wait_for_recordset_status(self.alt_client, alt_zone['id'], body['id'], const.ACTIVE) # Add "project_id" into the recordset_data recordset_data['project_id'] = alt_zone['project_id'] recordsets_created['alt'] = recordset_data LOG.info('Created resordsets are {}:'.format(recordsets_created)) return recordsets_created