Commit 345d395d authored by Bernardo Dal Seno's avatar Bernardo Dal Seno

QA for spindles in creating disks

"gnt-instance add" and "gnt-instance recreate-disks" are tested giving the
number of spindles, when supported. Also, QA for "gnt-instance
recreate-disks" now covers the case where disks are resized.
Signed-off-by: default avatarBernardo Dal Seno <>
Reviewed-by: default avatarThomas Thrainer <>
parent 30448dc7
......@@ -72,13 +72,17 @@
"disks": [
"size": "1G",
"spindles": 2,
"name": "disk0",
"growth": "2G"
"growth": "2G",
"spindles-growth": 1
"size": "512M",
"spindles": 1,
"name": "disk1",
"growth": "768M"
"growth": "768M",
"spindles-growth": 0
......@@ -418,6 +418,12 @@ class _QaConfig(object):
return enabled and (not self.GetExclusiveStorage() or
templ in constants.DTS_EXCL_STORAGE)
def AreSpindlesSupported(self):
"""Are spindles supported by the current configuration?
return self.GetExclusiveStorage()
def GetVclusterSettings(self):
"""Returns settings for virtual cluster.
......@@ -643,6 +649,13 @@ def IsTemplateSupported(templ):
return GetConfig().IsTemplateSupported(templ)
def AreSpindlesSupported():
"""Wrapper for L{_QaConfig.AreSpindlesSupported}.
return GetConfig().AreSpindlesSupported()
def _NodeSortKey(node):
"""Returns sort key for a node.
......@@ -828,6 +828,10 @@ def TestRecreateDisks(instance, inodes, othernodes):
AssertCommand(["gnt-instance", "stop",])
# Disks exist: this should fail
_AssertRecreateDisks([], instance, fail=True, destroy=False)
# Unsupported spindles parameters: fail
if not qa_config.AreSpindlesSupported():
_AssertRecreateDisks(["--disk=0:spindles=2"], instance,
fail=True, destroy=False)
# Recreate disks in place
_AssertRecreateDisks([], instance)
# Move disks away
......@@ -840,12 +844,33 @@ def TestRecreateDisks(instance, inodes, othernodes):
_AssertRecreateDisks(["-n", other_seq], instance)
# Move disks back
_AssertRecreateDisks(["-n", orig_seq], instance)
# Recreate the disks one by one
for idx in range(0, len(qa_config.GetDiskOptions())):
# Recreate resized disks
alldisks = qa_config.GetDiskOptions()
if qa_config.AreSpindlesSupported():
build_disks_opt = (lambda idx, disk:
("--disk=%s:size=%s,spindles=%s" %
(idx, (utils.ParseUnit(disk["size"]) +
disk["spindles"] + disk["spindles-growth"])))
build_disks_opt = (lambda idx, disk:
("--disk=%s:size=%s" %
(idx, (utils.ParseUnit(disk["size"]) +
disk_opts = map(build_disks_opt, range(0, len(alldisks)), (alldisks))
_AssertRecreateDisks(disk_opts, instance)
# Recreate the disks one by one (with the original size)
if qa_config.AreSpindlesSupported():
build_disks_opt = lambda idx, disk: ("--disk=%s:size=%s,spindles=%s" %
(idx, disk["size"], disk["spindles"]))
build_disks_opt = lambda idx, disk: ("--disk=%s:size=%s" %
(idx, disk["size"]))
for (idx, disk) in enumerate(alldisks):
# Only the first call should destroy all the disk
destroy = (idx == 0)
_AssertRecreateDisks(["--disk=%s" % idx], instance, destroy=destroy,
_AssertRecreateDisks([build_disks_opt(idx, disk)], instance,
destroy=destroy, check=False)
# This and InstanceCheck decoration check that the disks are working
AssertCommand(["gnt-instance", "reinstall", "-f",])
AssertCommand(["gnt-instance", "start",])
......@@ -30,6 +30,7 @@ from ganeti import constants
from ganeti import pathutils
import qa_config
import qa_error
import qa_utils
from qa_utils import AssertIn, AssertCommand
......@@ -53,6 +54,12 @@ def GetGenericAddParameters(inst, disk_template, force_mac=None):
diskparams = "%s:size=%s" % (idx, size)
if name:
diskparams += ",name=%s" % name
if qa_config.AreSpindlesSupported():
spindles = disk.get("spindles")
if spindles is None:
qa_error.Error("'spindles' is a required parameter for disks when you"
" enable exclusive storage tests")
diskparams += ",spindles=%s" % spindles
params.extend(["--disk", diskparams])
# Set static MAC address if configured
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment