LGTM, Thanks.
On Mon, May 20, 2013 at 5:11 PM, Bernardo Dal Seno <[email protected]>wrote: > "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: Bernardo Dal Seno <[email protected]> > --- > qa/qa-sample.json | 2 ++ > qa/qa_config.py | 13 +++++++++++++ > qa/qa_instance.py | 29 +++++++++++++++++++++++++---- > qa/qa_instance_utils.py | 7 +++++++ > 4 files changed, 47 insertions(+), 4 deletions(-) > > diff --git a/qa/qa-sample.json b/qa/qa-sample.json > index 2dc1975..55bf1b9 100644 > --- a/qa/qa-sample.json > +++ b/qa/qa-sample.json > @@ -72,11 +72,13 @@ > "disks": [ > { > "size": "1G", > + "spindles": 2, > "name": "disk0", > "growth": "2G" > }, > { > "size": "512M", > + "spindles": 1, > "name": "disk1", > "growth": "768M" > } > diff --git a/qa/qa_config.py b/qa/qa_config.py > index 959a347..d9e5b0e 100644 > --- a/qa/qa_config.py > +++ b/qa/qa_config.py > @@ -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. > > diff --git a/qa/qa_instance.py b/qa/qa_instance.py > index b88b4d6..08e3626 100644 > --- a/qa/qa_instance.py > +++ b/qa/qa_instance.py > @@ -840,12 +840,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"]) + > + utils.ParseUnit(disk["growth"])), > + disk["spindles"] + disk["spindles-growth"]))) > + else: > + build_disks_opt = (lambda idx, disk: > + ("--disk=%s:size=%s" % > + (idx, (utils.ParseUnit(disk["size"]) + > + utils.ParseUnit(disk["growth"]))))) > + 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"])) > + else: > + 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, > - check=False) > + _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", instance.name]) > AssertCommand(["gnt-instance", "start", instance.name]) > diff --git a/qa/qa_instance_utils.py b/qa/qa_instance_utils.py > index 40afde8..02165a9 100644 > --- a/qa/qa_instance_utils.py > +++ b/qa/qa_instance_utils.py > @@ -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 > -- > 1.8.2.1 > > -- Thomas Thrainer | Software Engineer | [email protected] | Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Katherine Stephens
