Skip tests for production environment

Allow tests for production in cases:
- Tests that do CRUD for tlds
    * pre-created testing TLDs

- Tests that use TLDs for creating zones
    * list of TLDs is empty
    * pre-created testing TLDs

Related-Prod: PRODX-29973
Change-Id: Ifcaa5115ad4e279ad70e7feb44b82a34e10d2a71
diff --git a/designate_tempest_plugin/config.py b/designate_tempest_plugin/config.py
index f4ca708..48fd665 100644
--- a/designate_tempest_plugin/config.py
+++ b/designate_tempest_plugin/config.py
@@ -54,7 +54,10 @@
                     "If it is not specified, a new zone will be created "),
     cfg.StrOpt('tld_suffix',
                default='test',
-               help="TLD suffix that used in all tests (if not overridden).")
+               help="TLD suffix that used in all tests (if not overridden)."),
+    cfg.ListOpt('existing_tlds',
+               default=[],
+               help="List of current TLDs created on the environment"),
 ]
 
 dns_feature_group = cfg.OptGroup(name='dns_feature_enabled',
diff --git a/designate_tempest_plugin/tests/api/v2/test_tld.py b/designate_tempest_plugin/tests/api/v2/test_tld.py
index e2894fe..51c654f 100644
--- a/designate_tempest_plugin/tests/api/v2/test_tld.py
+++ b/designate_tempest_plugin/tests/api/v2/test_tld.py
@@ -57,6 +57,14 @@
         return '.'.join([data_utils.rand_name(name=test_name),
                          cls.local_tld_suffix])
 
+    @classmethod
+    def skip_checks(cls):
+        super(TldAdminTest, cls).skip_checks()
+
+        if CONF.production and not CONF.dns.existing_tlds:
+            raise cls.skipException(
+                "Skip on production because tests create/delete TLDs")
+
     @decorators.idempotent_id('52a4bb4b-4eff-4591-9dd3-ad98316806c3')
     def test_create_tld(self):
         tld_name = self._generate_tld_name("test_create_tld")
diff --git a/designate_tempest_plugin/tests/base.py b/designate_tempest_plugin/tests/base.py
index 4f5f8fb..658e7c8 100644
--- a/designate_tempest_plugin/tests/base.py
+++ b/designate_tempest_plugin/tests/base.py
@@ -188,6 +188,18 @@
             skip_msg = ("%s skipped as designate v2 API is not available"
                         % cls.__name__)
             raise cls.skipException(skip_msg)
+        # Allow testing for production env in cases:
+        # Tests that do CRUD for tlds:
+        #    - env has pre-created testing TLDs
+        # Tests that use TLDs for creating zones:
+        #    - env has empty list of TLDs
+        #    - env has pre-created testing TLDs
+        if CONF.production:
+            if CONF.dns.existing_tlds and not set([CONF.dns.tld_suffix,
+                    "arpa", "in-addr.arpa"]).issubset(CONF.dns.existing_tlds):
+                raise cls.skipException(
+                    "Skip on production environment because it doesn't "
+                    "match TLD configuration.")
 
 
 class BaseDnsAdminTest(BaseDnsTest):