31 |
31 |
import types
|
32 |
32 |
|
33 |
33 |
import ganeti.constants as constants
|
34 |
|
from ganeti.rapi.client import GanetiApiError
|
|
34 |
from ganeti.rapi.client import GanetiApiError, NODE_EVAC_PRI, NODE_EVAC_SEC
|
35 |
35 |
|
36 |
36 |
import qa_config
|
37 |
37 |
import qa_node
|
... | ... | |
632 |
632 |
Finish(client, client.DeleteNetwork, NETWORK_NAME)
|
633 |
633 |
|
634 |
634 |
|
|
635 |
def CreateDRBDInstance(client, node_one, node_two, instance_name):
|
|
636 |
""" Creates a DRBD-enabled instance on the given nodes.
|
|
637 |
|
|
638 |
"""
|
|
639 |
Finish(client, client.CreateInstance,
|
|
640 |
"create", instance_name, "drbd", [{"size": "1000"}], [{}],
|
|
641 |
os="debian-image", pnode=node_one, snode=node_two)
|
|
642 |
|
|
643 |
|
|
644 |
def TestInstanceMigrations(client, node_one, node_two, node_three,
|
|
645 |
instance_name):
|
|
646 |
""" Test various operations related to migrating instances.
|
|
647 |
|
|
648 |
@type node_one string
|
|
649 |
@param node_one The name of a node in the cluster.
|
|
650 |
@type node_two string
|
|
651 |
@param node_two The name of another node in the cluster.
|
|
652 |
@type node_three string
|
|
653 |
@param node_three The name of yet another node in the cluster.
|
|
654 |
@type instance_name string
|
|
655 |
@param instance_name An instance name that can be used.
|
|
656 |
|
|
657 |
"""
|
|
658 |
|
|
659 |
CreateDRBDInstance(client, node_one, node_two, instance_name)
|
|
660 |
Finish(client, client.FailoverInstance, instance_name)
|
|
661 |
Finish(client, client.DeleteInstance, instance_name)
|
|
662 |
|
|
663 |
CreateDRBDInstance(client, node_one, node_two, instance_name)
|
|
664 |
Finish(client, client.EvacuateNode,
|
|
665 |
node_two, early_release=False, mode=NODE_EVAC_SEC,
|
|
666 |
remote_node=node_three)
|
|
667 |
Finish(client, client.DeleteInstance, instance_name)
|
|
668 |
|
|
669 |
CreateDRBDInstance(client, node_one, node_two, instance_name)
|
|
670 |
Finish(client, client.EvacuateNode,
|
|
671 |
node_one, early_release=False, mode=NODE_EVAC_PRI, iallocator="hail")
|
|
672 |
Finish(client, client.DeleteInstance, instance_name)
|
|
673 |
|
|
674 |
CreateDRBDInstance(client, node_one, node_two, instance_name)
|
|
675 |
Finish(client, client.MigrateInstance,
|
|
676 |
instance_name, cleanup=True, target_node=node_two)
|
|
677 |
Finish(client, client.DeleteInstance, instance_name)
|
|
678 |
|
|
679 |
CreateDRBDInstance(client, node_one, node_two, instance_name)
|
|
680 |
Finish(client, client.MigrateNode,
|
|
681 |
node_one, iallocator="hail", mode="non-live")
|
|
682 |
Finish(client, client.DeleteInstance, instance_name)
|
|
683 |
|
|
684 |
CreateDRBDInstance(client, node_one, node_two, instance_name)
|
|
685 |
Finish(client, client.MigrateNode,
|
|
686 |
node_one, target_node=node_two, mode="non-live")
|
|
687 |
Finish(client, client.DeleteInstance, instance_name)
|
|
688 |
|
|
689 |
|
635 |
690 |
def Workload(client):
|
636 |
691 |
""" The actual RAPI workload used for tests.
|
637 |
692 |
|
... | ... | |
661 |
716 |
RemoveAllInstances(client)
|
662 |
717 |
|
663 |
718 |
nodes = qa_config.AcquireManyNodes(2)
|
664 |
|
instance_one = qa_config.AcquireInstance()
|
665 |
|
instance_two = qa_config.AcquireInstance()
|
666 |
|
TestSingleInstance(client, instance_one.name, instance_two.name,
|
|
719 |
instances = qa_config.AcquireManyInstances(2)
|
|
720 |
TestSingleInstance(client, instances[0].name, instances[1].name,
|
667 |
721 |
nodes[0].primary, nodes[1].primary)
|
668 |
|
instance_two.Release()
|
669 |
|
instance_one.Release()
|
|
722 |
qa_config.ReleaseManyInstances(instances)
|
670 |
723 |
qa_config.ReleaseManyNodes(nodes)
|
671 |
724 |
|
672 |
725 |
# Test all the queries which involve resources that do not have functions
|
... | ... | |
686 |
739 |
|
687 |
740 |
TestNetworks(client)
|
688 |
741 |
|
|
742 |
nodes = qa_config.AcquireManyNodes(3)
|
|
743 |
instance = qa_config.AcquireInstance()
|
|
744 |
TestInstanceMigrations(client, nodes[0].primary, nodes[1].primary,
|
|
745 |
nodes[2].primary, instance.name)
|
|
746 |
instance.Release()
|
|
747 |
qa_config.ReleaseManyNodes(nodes)
|
|
748 |
|
689 |
749 |
|
690 |
750 |
def Usage():
|
691 |
751 |
sys.stderr.write("Usage:\n\trapi-workload.py qa-config-file")
|