On Fri, Dec 20, 2013 at 10:09 AM, Hrvoje Ribicic <[email protected]> wrote:
> This patch introduces additional calls adding migration and failover > RAPI operations, moving a DRBD-disk template instance between nodes. > > Signed-off-by: Hrvoje Ribicic <[email protected]> > --- > qa/qa_config.py | 42 +++++++++++++++++++++++++++++++ > qa/rapi-workload.py | 72 > ++++++++++++++++++++++++++++++++++++++++++++++++----- > 2 files changed, 108 insertions(+), 6 deletions(-) > > diff --git a/qa/qa_config.py b/qa/qa_config.py > index bc650ce..d497b16 100644 > --- a/qa/qa_config.py > +++ b/qa/qa_config.py > @@ -702,6 +702,48 @@ def AcquireInstance(_cfg=None): > return instance > > > +def AcquireManyInstances(num, _cfg=None): > + """Return instances that are not in use. > + > + @type num: int > + @param num: Number of nodes; can be 0. > s/nodes/instances ? > + @rtype: list of instances > + @return: C{num} different instances > + > + """ > + > + if _cfg is None: > + cfg = GetConfig() > + else: > + cfg = _cfg > + > + # Filter out unwanted instances > + instances = filter(lambda inst: not inst.used, cfg["instances"]) > + > + if len(instances) < num: > + raise qa_error.OutOfInstancesError( > + "Not enough instances left (%d needed, %d remaining)" % > + (num, len(instances)) > + ) > + > + instances = [] > + > + try: > + for _ in range(0, num): > + n = AcquireInstance(_cfg=cfg) > + instances.append(n) > + except qa_error.OutOfInstancesError: > + ReleaseManyInstances(instances) > + raise > + > + return instances > + > + > +def ReleaseManyInstances(instances): > + for instance in instances: > + instance.Release() > + > + > def SetExclusiveStorage(value): > """Wrapper for L{_QaConfig.SetExclusiveStorage}. > > diff --git a/qa/rapi-workload.py b/qa/rapi-workload.py > index a7a35b3..620e933 100755 > --- a/qa/rapi-workload.py > +++ b/qa/rapi-workload.py > @@ -31,7 +31,7 @@ import sys > import types > > import ganeti.constants as constants > -from ganeti.rapi.client import GanetiApiError > +from ganeti.rapi.client import GanetiApiError, NODE_EVAC_PRI, > NODE_EVAC_SEC > > import qa_config > import qa_node > @@ -628,6 +628,61 @@ def TestNetworks(client): > Finish(client, client.DeleteNetwork, NETWORK_NAME) > > > +def CreateDRBDInstance(client, node_one, node_two, instance_name): > + """ Creates a DRBD-enabled instance on the given nodes. > + > + """ > + Finish(client, client.CreateInstance, > + "create", instance_name, "drbd", [{"size": "1000"}], [{}], > + os="debian-image", pnode=node_one, snode=node_two) > + > + > +def TestInstanceMigrations(client, node_one, node_two, node_three, > + instance_name): > + """ Test various operations related to migrating instances. > + > + @type node_one string > + @param node_one The name of a node in the cluster. > + @type node_two string > + @param node_two The name of a node in the cluster. > + @type node_three string > + @param node_three The name of a node in the cluster. > It might be worth mentioning that the names of the nodes must differ, don't they? > + @type instance_name string > + @param instance_name An instance name that can be used. > + > + """ > + > + CreateDRBDInstance(client, node_one, node_two, instance_name) > + Finish(client, client.FailoverInstance, instance_name) > + Finish(client, client.DeleteInstance, instance_name) > + > + CreateDRBDInstance(client, node_one, node_two, instance_name) > + Finish(client, client.EvacuateNode, > + node_two, early_release=False, mode=NODE_EVAC_SEC, > + remote_node=node_three) > + Finish(client, client.DeleteInstance, instance_name) > + > + CreateDRBDInstance(client, node_one, node_two, instance_name) > + Finish(client, client.EvacuateNode, > + node_one, early_release=False, mode=NODE_EVAC_PRI, > iallocator="hail") > + Finish(client, client.DeleteInstance, instance_name) > + > + CreateDRBDInstance(client, node_one, node_two, instance_name) > + Finish(client, client.MigrateInstance, > + instance_name, cleanup=True, target_node=node_two) > + Finish(client, client.DeleteInstance, instance_name) > + > + CreateDRBDInstance(client, node_one, node_two, instance_name) > + Finish(client, client.MigrateNode, > + node_one, iallocator="hail", mode="non-live") > + Finish(client, client.DeleteInstance, instance_name) > + > + CreateDRBDInstance(client, node_one, node_two, instance_name) > + Finish(client, client.MigrateNode, > + node_one, target_node=node_two, mode="non-live") > + Finish(client, client.DeleteInstance, instance_name) > + > + > def Workload(client): > """ The actual RAPI workload used for tests. > > @@ -657,12 +712,10 @@ def Workload(client): > RemoveAllInstances(client) > > nodes = qa_config.AcquireManyNodes(2) > - instance_one = qa_config.AcquireInstance() > - instance_two = qa_config.AcquireInstance() > - TestSingleInstance(client, instance_one.name, instance_two.name, > + instances = qa_config.AcquireManyInstances(2) > + TestSingleInstance(client, instances[0].name, instances[1].name, > nodes[0].primary, nodes[1].primary) > - instance_two.Release() > - instance_one.Release() > + qa_config.ReleaseManyInstances(instances) > qa_config.ReleaseManyNodes(nodes) > > # Test all the queries which involve resources that do not have > functions > @@ -682,6 +735,13 @@ def Workload(client): > > TestNetworks(client) > > + nodes = qa_config.AcquireManyNodes(3) > + instance = qa_config.AcquireInstance() > + TestInstanceMigrations(client, nodes[0].primary, nodes[1].primary, > + nodes[2].primary, instance.name) > + instance.Release() > + qa_config.ReleaseManyNodes(nodes) > + > > def Usage(): > sys.stderr.write("Usage:\n\trapi-workload.py qa-config-file") > -- > 1.8.5.1 > > LGTM, thanks -- -- Helga Velroyen | 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, Christine Elizabeth Flores
