Fix tempest test failing with segments extension

This patchset fixes tempest test case test_filtering_shared_subnets that
fails when executed with the segments extension enabled, due to the fact
that the 'segment_id' attribute is returned in subnets listed with an
admin client but not in subnets listed with a non admin client.

Patchset https://review.openstack.org/#/c/459439/ proposes to enable the
segments extension in the gate.

Change-Id: I6b9bd6fe944c9485c21d25b37c943f3bd53fd7c9
Closes-Bug: #1690598
This commit is contained in:
Miguel Lavalle 2017-05-13 19:28:09 -05:00
parent dfcfbc0aac
commit b244fa5f6e
1 changed files with 8 additions and 3 deletions

View File

@ -50,6 +50,10 @@ class SharedNetworksTest(base.BaseAdminNetworkTest):
self.assertNotEmpty(items)
self.assertTrue(all(n['shared'] == shared for n in items))
def _list_subnets_ids(self, client, shared):
body = client.list_subnets(shared=shared)
return [subnet['id'] for subnet in body['subnets']]
@decorators.idempotent_id('6661d219-b96d-4597-ad10-51672353421a')
def test_filtering_shared_subnets(self):
# shared subnets need to be tested because their shared status isn't
@ -59,7 +63,8 @@ class SharedNetworksTest(base.BaseAdminNetworkTest):
priv = self.create_subnet(reg, client=self.client)
shared = self.create_subnet(self.shared_network,
client=self.admin_client)
self.assertIn(shared, self.client.list_subnets(shared=True)['subnets'])
self.assertIn(shared['id'],
self._list_subnets_ids(self.client, shared=True))
self.assertIn(shared,
self.admin_client.list_subnets(shared=True)['subnets'])
self.assertNotIn(priv,
@ -67,8 +72,8 @@ class SharedNetworksTest(base.BaseAdminNetworkTest):
self.assertNotIn(priv,
self.admin_client.list_subnets(shared=True)['subnets'])
self.assertIn(priv, self.client.list_subnets(shared=False)['subnets'])
self.assertIn(priv,
self.admin_client.list_subnets(shared=False)['subnets'])
self.assertIn(priv['id'],
self._list_subnets_ids(self.admin_client, shared=False))
self.assertNotIn(shared,
self.client.list_subnets(shared=False)['subnets'])
self.assertNotIn(shared,