Merge branch 'stable-2.12' into stable-2.13
[ganeti-github.git] / qa / ganeti-qa.py
index cff1ad2..3be0614 100755 (executable)
@@ -46,6 +46,7 @@ import qa_config
 import qa_daemon
 import qa_env
 import qa_error
+import qa_filters
 import qa_group
 import qa_instance
 import qa_iptables
@@ -426,6 +427,23 @@ def RunNetworkTests():
   RunTestIf(["network", "tags"], qa_network.TestNetworkTags)
 
 
+def RunFilterTests():
+  """Run tests for job filter management.
+
+  """
+  RunTestIf("filters", qa_filters.TestFilterList)
+  RunTestIf("filters", qa_filters.TestFilterListFields)
+  RunTestIf("filters", qa_filters.TestFilterAddRemove)
+  RunTestIf("filters", qa_filters.TestFilterReject)
+  RunTestIf("filters", qa_filters.TestFilterOpCode)
+  RunTestIf("filters", qa_filters.TestFilterReasonChain)
+  RunTestIf("filters", qa_filters.TestFilterContinue)
+  RunTestIf("filters", qa_filters.TestFilterAcceptPause)
+  RunTestIf("filters", qa_filters.TestFilterWatermark)
+  RunTestIf("filters", qa_filters.TestFilterRateLimit)
+  RunTestIf("filters", qa_filters.TestAdHocReasonRateLimit)
+
+
 def RunGroupRwTests():
   """Run tests for adding/removing/renaming groups.
 
@@ -626,7 +644,7 @@ def RunCustomSshPortTests():
 
     for node in nodes:
       qa_node.NodeRemove(node)
-    with qa_iptables.RulesContext(nodes) as r:
+    with qa_iptables.RulesContext() as r:
       with qa_group.NewGroupCtx() as group:
         qa_group.ModifyGroupSshPort(r, group, nodes, port)
 
@@ -800,6 +818,9 @@ def IsExclusiveStorageInstanceTestEnabled():
 def RunInstanceTests():
   """Create and exercise instances."""
 
+  requested_conversions = qa_config.get("convert-disk-templates", [])
+  supported_conversions = \
+      set(requested_conversions).difference(constants.DTS_NOT_CONVERTIBLE_TO)
   for (test_name, templ, create_fun, num_nodes) in \
       qa_instance.available_instance_tests:
     if (qa_config.TestEnabled(test_name) and
@@ -823,11 +844,21 @@ def RunInstanceTests():
             RunTestIf("group-rwops", qa_group.TestAssignNodesIncludingSplit,
                       constants.INITIAL_NODE_GROUP_NAME,
                       inodes[0].primary, inodes[1].primary)
+          # This test will run once but it will cover all the supported
+          # user-provided disk template conversions
           if qa_config.TestEnabled("instance-convert-disk"):
-            RunTest(qa_instance.TestInstanceShutdown, instance)
-            RunTest(qa_instance.TestInstanceConvertDiskToPlain,
-                    instance, inodes)
-            RunTest(qa_instance.TestInstanceStartup, instance)
+            if (len(supported_conversions) > 1 and
+                instance.disk_template in supported_conversions):
+              RunTest(qa_instance.TestInstanceShutdown, instance)
+              RunTest(qa_instance.TestInstanceConvertDiskTemplate, instance,
+                      supported_conversions)
+              RunTest(qa_instance.TestInstanceStartup, instance)
+              # At this point we clear the set because the requested conversions
+              # has been tested
+              supported_conversions.clear()
+            else:
+              test_desc = "Converting instance of template %s" % templ
+              ReportTestSkip(test_desc, "conversion feature")
           RunTestIf("instance-modify-disks",
                     qa_instance.TestInstanceModifyDisks, instance)
           RunCommonInstanceTests(instance, inodes)
@@ -928,6 +959,7 @@ def RunQa():
   RunTestBlock(RunGroupListTests)
   RunTestBlock(RunGroupRwTests)
   RunTestBlock(RunNetworkTests)
+  RunTestBlock(RunFilterTests)
 
   # The master shouldn't be readded or put offline; "delay" needs a non-master
   # node to test
@@ -1012,6 +1044,9 @@ def RunQa():
   finally:
     pnode.Release()
 
+  if qa_rapi.Enabled():
+    RunTestIf("filters", qa_rapi.TestFilters)
+
   RunTestIf("cluster-upgrade", qa_cluster.TestUpgrade)
 
   RunTestBlock(RunExclusiveStorageTests)