Signed-off-by: Dimitris Aragiorgis <[email protected]>
---
Hi,

as I see diskless test is introduced in master. So I check
only for plain and drbd. Is that OK? Including diskless would
make check things more complicated because I should skip
the --disk option in LaunchInstance()..

Thanks,
dimara

 qa/qa_network.py |   43 ++++++++++++++++++++++++++++++-------------
 1 file changed, 30 insertions(+), 13 deletions(-)

diff --git a/qa/qa_network.py b/qa/qa_network.py
index 29dd8dc..cae8b73 100644
--- a/qa/qa_network.py
+++ b/qa/qa_network.py
@@ -27,7 +27,7 @@ import qa_config
 import qa_utils
 
 from qa_utils import AssertCommand
-
+from ganeti import constants
 
 TEST_NET_1 = "192.0.2.0/24"
 TEST_NET_2 = "198.51.100.0/24"
@@ -50,6 +50,7 @@ IP2_IN_NET_1 = "192.0.2.70"
 IP_IN_NET_2 = "198.51.100.82"
 IP_IN_NET_3 = "203.0.113.118"
 
+
 def GetNicParams():
   default_mode = "bridged"
   default_link = "br0"
@@ -89,13 +90,30 @@ def RemoveInstance(instance):
   qa_config.ReleaseInstance(instance)
 
 
+def GetInstance():
+  inst = qa_config.AcquireInstance()
+  cases = [
+    ("instance-add-plain-disk", constants.DT_PLAIN),
+    ("instance-add-drbd-disk", constants.DT_DRBD8),
+    #("instance-add-diskless", constants.DT_DISKLESS),
+    ]
+  for test, templ in cases:
+    if qa_config.TestEnabled(test):
+      qa_config.SetInstanceTemplate(inst, templ)
+      break
+
+  return inst
+
+
 def LaunchInstance(instance, mac=None, ip=None, network=None,
                    mode=None, link=None, fail=False):
 
   name = instance["name"]
+  # assert if no template is set by GetInstance
+  templ = qa_config.GetInstanceTemplate(instance)
   net = GetNetOption(0, None, mac, ip, network, mode, link)
-  AssertCommand(["gnt-instance", "add", "-o", "debootstrap+default",
-                 "-t", "file", "--disk", "0:size=1G", "--net", net,
+  AssertCommand(["gnt-instance", "add", "-o", qa_config.get("os"),
+                 "-t", templ, "--disk", "0:size=1G", "--net", net,
                  "--no-name-check", "--no-ip-check", "--no-install", name],
                  fail=fail)
 
@@ -219,7 +237,7 @@ def TestNetworkConnect():
   # Network still connected
   AssertCommand(["gnt-network", "remove", network1], fail=True)
 
-  instance1 = qa_config.AcquireInstance()
+  instance1 = GetInstance()
   # Add instance inside the network
   LaunchInstance(instance1, ip="pool", network=network1)
   # Conflicting IP, at least one instance belongs to the network
@@ -230,7 +248,7 @@ def TestNetworkConnect():
   # This should only produce a warning.
   AssertCommand(["gnt-network", "disconnect", network1])
 
-  instance1 = qa_config.AcquireInstance()
+  instance1 = GetInstance()
   # TODO: add conflicting image.
   LaunchInstance(instance1, ip=IP_IN_NET_2)
   # Conflicting IPs
@@ -262,7 +280,6 @@ def TestInstanceAddAndNetAdd():
   AssertCommand(["gnt-network", "add", "--network", TEST_NET_2, network2])
   AssertCommand(["gnt-network", "connect", network2, "routed", "rt5000"])
 
-
   # (mac, ip, network, mode, link)
   success_cases = [
     (None, None, None, None, None),  # random mac and default nicparams
@@ -271,11 +288,11 @@ def TestInstanceAddAndNetAdd():
     # TODO: include this use case with --no-conflicts-check
     #       just add an extra field in Launch|ModifyInstance
     #(None, "192.168.1.6", None, None, None), # IP but no net
-    (None, None, network1, None, None) # nicparams/mac  inherited by network
+    (None, None, network1, None, None), # nicparams/mac  inherited by network
     ]
 
   for (mac, ip, network, mode, link) in success_cases:
-    instance1 = qa_config.AcquireInstance()
+    instance1 = GetInstance()
     LaunchInstance(instance1, mac, ip, network, mode, link)
     ModifyInstance(instance1, idx=-1, action="add", mac=mac,
                    ip=ip, network=network, mode=mode, link=link)
@@ -289,11 +306,11 @@ def TestInstanceAddAndNetAdd():
     (None, IP_IN_NET_2, None, None, None), # conflicting IP
     (None, None, None, "routed", None), # routed with no IP
     (None, "pool", network1, "routed", None), # nicparams along with network
-    (None, "pool", network1, None, deflink)
+    (None, "pool", network1, None, deflink),
    ]
 
-  instance1 = qa_config.AcquireInstance()
-  instance2 = qa_config.AcquireInstance()
+  instance1 = GetInstance()
+  instance2 = GetInstance()
   LaunchInstance(instance2)
   for (mac, ip, network, mode, link) in fail_cases:
     LaunchInstance(instance1, mac=mac, ip=ip, network=network,
@@ -329,10 +346,10 @@ def TestInstanceNetMod():
     (None, IP2_IN_NET_1, network1, None, None), # IP inside network
     #TODO: include this use case with --no-conflickts-check
     #(None, IP2_IN_NET_1, None, None, None), # IP but no net
-    (None, None, network1, None, None) # nicparams/mac  inherited by network
+    (None, None, network1, None, None), # nicparams/mac  inherited by network
     ]
 
-  instance1 = qa_config.AcquireInstance()
+  instance1 = GetInstance()
   LaunchInstance(instance1)
   for (mac, ip, network, mode, link) in success_cases:
     ModifyInstance(instance1, idx=0, action="modify", mac=mac,
-- 
1.7.10.4

Attachment: signature.asc
Description: Digital signature

Reply via email to