Merge "Add dummy driver"
diff --git a/manila_tempest_tests/config.py b/manila_tempest_tests/config.py
index 7a7ee6f..4b394c6 100644
--- a/manila_tempest_tests/config.py
+++ b/manila_tempest_tests/config.py
@@ -56,6 +56,15 @@
                 help="This option used to determine backend driver type, "
                      "multitenant driver uses share-networks, but "
                      "single-tenant doesn't."),
+    cfg.BoolOpt("create_networks_when_multitenancy_enabled",
+                default=True,
+                help="This option is used only when other "
+                     "'multitenancy_enabled' option is set to 'True'. "
+                     "If this one is set to True, then tempest will create "
+                     "neutron networks for each new manila share-network "
+                     "it creates. Else it will use manila share-networks with "
+                     "empty values (case of StandAloneNetworkPlugin and "
+                     "NeutronSingleNetworkPlugin)."),
     cfg.ListOpt("enable_protocols",
                 default=["nfs", "cifs"],
                 help="First value of list is protocol by default, "
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index a599196..79c8673 100644
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -203,7 +203,8 @@
 
         # Provide share network
         if CONF.share.multitenancy_enabled:
-            if not CONF.service_available.neutron:
+            if (not CONF.service_available.neutron and
+                    CONF.share.create_networks_when_multitenancy_enabled):
                 raise cls.skipException("Neutron support is required")
             nc = os.networks_client
             share_network_id = cls.provide_share_network(client, nc, ic)
@@ -235,7 +236,8 @@
             os.auth_provider)
         cls.shares_v2_client = os.shares_v2_client
         if CONF.share.multitenancy_enabled:
-            if not CONF.service_available.neutron:
+            if (not CONF.service_available.neutron and
+                    CONF.share.create_networks_when_multitenancy_enabled):
                 raise cls.skipException("Neutron support is required")
             share_network_id = cls.provide_share_network(
                 cls.shares_v2_client, os.networks_client)
@@ -282,6 +284,8 @@
         """
 
         sc = shares_client
+        search_word = "reusable"
+        sn_name = "autogenerated_by_tempest_%s" % search_word
 
         if not CONF.share.multitenancy_enabled:
             # Assumed usage of a single-tenant driver
@@ -289,13 +293,28 @@
         elif sc.share_network_id:
             # Share-network already exists, use it
             share_network_id = sc.share_network_id
+        elif not CONF.share.create_networks_when_multitenancy_enabled:
+            share_network_id = None
+
+            # Try get suitable share-network
+            share_networks = sc.list_share_networks_with_detail()
+            for sn in share_networks:
+                if (sn["neutron_net_id"] is None and
+                        sn["neutron_subnet_id"] is None and
+                        sn["name"] and search_word in sn["name"]):
+                    share_network_id = sn["id"]
+                    break
+
+            # Create new share-network if one was not found
+            if share_network_id is None:
+                sn_desc = "This share-network was created by tempest"
+                sn = sc.create_share_network(name=sn_name, description=sn_desc)
+                share_network_id = sn["id"]
         else:
             net_id = subnet_id = share_network_id = None
 
             if not isolated_creds_client:
                 # Search for networks, created in previous runs
-                search_word = "reusable"
-                sn_name = "autogenerated_by_tempest_%s" % search_word
                 service_net_name = "share-service"
                 networks = networks_client.list_networks()
                 if "networks" in networks.keys():
diff --git a/manila_tempest_tests/tests/api/test_shares.py b/manila_tempest_tests/tests/api/test_shares.py
index 2acd81a..f7ff194 100644
--- a/manila_tempest_tests/tests/api/test_shares.py
+++ b/manila_tempest_tests/tests/api/test_shares.py
@@ -146,8 +146,10 @@
             self.protocol, snapshot_id=snap["id"], cleanup_in_class=False)
 
         # The 'status' of the share returned by the create API must be
-        # the default value - 'creating'.
-        self.assertEqual('creating', s2['status'])
+        # set and have value either 'creating' or
+        # 'available' (if share creation is really fast as in
+        # case of Dummy driver).
+        self.assertIn(s2['status'], ('creating', 'available'))
 
         # verify share, created from snapshot
         get = self.shares_client.get_share(s2["id"])