Ensure test_list_show_tenant_networks is isolated

This test can randomly fail when Neutron is enabled because
it assumes there is always at least a tenant (owned) network.

Unfortunately this is not true in Neutron because during concurrent
test runs other tests can create or delete shared/external networks
which are visible to all tenants.

This patch ensures that a network is always available.

Related-Bug: #1468523
Closes-Bug: #1491965

Change-Id: I90f8fce0733012b109e03bfe92755d0ba364bcae
Co-authored-by: Armando Migliaccio <armamig@gmail.com>
diff --git a/tempest/api/compute/test_tenant_networks.py b/tempest/api/compute/test_tenant_networks.py
index 80691a8..96b7ef6 100644
--- a/tempest/api/compute/test_tenant_networks.py
+++ b/tempest/api/compute/test_tenant_networks.py
@@ -22,13 +22,23 @@
     def resource_setup(cls):
         super(ComputeTenantNetworksTest, cls).resource_setup()
         cls.client = cls.os.tenant_networks_client
+        cls.network = cls.get_tenant_network()
+
+    @classmethod
+    def setup_credentials(cls):
+        cls.set_network_resources(network=True)
+        super(ComputeTenantNetworksTest, cls).setup_credentials()
 
     @test.idempotent_id('edfea98e-bbe3-4c7a-9739-87b986baff26')
+    @test.services('network')
     def test_list_show_tenant_networks(self):
-        tenant_networks = self.client.list_tenant_networks()['networks']
-        self.assertNotEmpty(tenant_networks, "No tenant networks found.")
+        # Fetch all networks that are visible to the tenant: this may include
+        # shared and external networks
+        tenant_networks = [
+            n['id'] for n in self.client.list_tenant_networks()['networks']
+        ]
+        self.assertIn(self.network['id'], tenant_networks,
+                      "No tenant networks found.")
 
-        for net in tenant_networks:
-            tenant_network = (self.client.show_tenant_network(net['id'])
-                              ['network'])
-            self.assertEqual(net['id'], tenant_network['id'])
+        net = self.client.show_tenant_network(self.network['id'])
+        self.assertEqual(self.network['id'], net['network']['id'])