Commit f985ecbd authored by Jose A. Lopes's avatar Jose A. Lopes

Instance communication mechanism QA (for cluster only)

Extend QA with tests for the instance communication mechanism.  These
tests cover only the cluster creating the instance communication
network and connecting it to the existing node group, and also if new
groups are added they are also connected to the instance communication
network.
Signed-off-by: default avatarJose A. Lopes <jabolopes@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent 39e27230
...@@ -244,6 +244,7 @@ def RunClusterTests(): ...@@ -244,6 +244,7 @@ def RunClusterTests():
qa_cluster.TestClusterMasterFailoverWithDrainedQueue), qa_cluster.TestClusterMasterFailoverWithDrainedQueue),
(["cluster-oob", qa_config.NoVirtualCluster], (["cluster-oob", qa_config.NoVirtualCluster],
qa_cluster.TestClusterOob), qa_cluster.TestClusterOob),
("cluster-instance-communication", qa_cluster.TestInstanceCommunication),
(qa_rapi.Enabled, qa_rapi.TestVersion), (qa_rapi.Enabled, qa_rapi.TestVersion),
(qa_rapi.Enabled, qa_rapi.TestEmptyCluster), (qa_rapi.Enabled, qa_rapi.TestEmptyCluster),
(qa_rapi.Enabled, qa_rapi.TestRapiQuery), (qa_rapi.Enabled, qa_rapi.TestRapiQuery),
......
...@@ -174,12 +174,13 @@ ...@@ -174,12 +174,13 @@
"cluster-reserved-lvs": true, "cluster-reserved-lvs": true,
"cluster-modify": true, "cluster-modify": true,
"cluster-oob": true, "cluster-oob": true,
"cluster-instance-communication": true,
"cluster-epo": true, "cluster-epo": true,
"cluster-redist-conf": true, "cluster-redist-conf": true,
"cluster-repair-disk-sizes": true, "cluster-repair-disk-sizes": true,
"cluster-exclusive-storage": true, "cluster-exclusive-storage": true,
"cluster-instance-policy": true, "cluster-instance-policy": true,
"cluster-upgrade" : true, "cluster-upgrade": true,
"haskell-confd": true, "haskell-confd": true,
"htools": true, "htools": true,
......
...@@ -1336,3 +1336,124 @@ def TestExclStorSharedPv(node): ...@@ -1336,3 +1336,124 @@ def TestExclStorSharedPv(node):
AssertCommand(["lvremove", "-f", "/".join([vgname, lvname1])], node=node_name) AssertCommand(["lvremove", "-f", "/".join([vgname, lvname1])], node=node_name)
AssertCommand(["lvremove", "-f", "/".join([vgname, lvname2])], node=node_name) AssertCommand(["lvremove", "-f", "/".join([vgname, lvname2])], node=node_name)
AssertClusterVerify() AssertClusterVerify()
def TestInstanceCommunication():
"""Tests instance communication"""
master = qa_config.GetMasterNode()
# Check that the 'default' node group exists
cmd = ["gnt-group", "list", "--no-headers", "-o", "name"]
result_output = GetCommandOutput(master.primary, utils.ShellQuoteArgs(cmd))
AssertEqual(result_output.strip(), "default", msg="Checking 'default' group")
# Check that no networks exist
cmd = ["gnt-network", "list", "--no-headers", "-o", "name"]
result_output = GetCommandOutput(master.primary, utils.ShellQuoteArgs(cmd))
AssertEqual(result_output.strip(), "", msg="Checking networks")
# Modify cluster parameter 'instance-communication-network' and
# check whether the cluster creates the instance communication
# network and connects it to the 'default' node group
network_name = "mynetwork"
cmd = "gnt-cluster modify --instance-communication-network=%s" % network_name
result_output = qa_utils.GetCommandOutput(master.primary, cmd)
print result_output
cmd = ["gnt-network", "list", "--no-headers", "-o", "name", network_name]
result_output = qa_utils.GetCommandOutput(master.primary,
utils.ShellQuoteArgs(cmd))
AssertEqual(result_output.strip(), "mynetwork", msg="Checking 'mynetwork'")
cmd = ["gnt-network", "list", "--no-headers", "-o", "group_list",
network_name]
result_output = qa_utils.GetCommandOutput(master.primary,
utils.ShellQuoteArgs(cmd))
AssertEqual(result_output.strip(), "default (routed, communication_rt)",
msg="Checking network connected groups")
# Check that the network has the parameters necessary for instance
# communication
cmd = ["gnt-network", "list", "--no-headers", "-o", "gateway",
network_name]
result_output = qa_utils.GetCommandOutput(master.primary,
utils.ShellQuoteArgs(cmd))
AssertEqual(result_output.strip(), "-", msg="Checking gateway")
cmd = ["gnt-network", "list", "--no-headers", "-o", "gateway6",
network_name]
result_output = qa_utils.GetCommandOutput(master.primary,
utils.ShellQuoteArgs(cmd))
AssertEqual(result_output.strip(), "-", msg="Checking gateway6")
cmd = ["gnt-network", "list", "--no-headers", "-o", "network",
network_name]
result_output = qa_utils.GetCommandOutput(master.primary,
utils.ShellQuoteArgs(cmd))
AssertEqual(result_output.strip(), constants.INSTANCE_COMMUNICATION_NETWORK4,
msg="Checking network")
cmd = ["gnt-network", "list", "--no-headers", "-o", "network6",
network_name]
result_output = qa_utils.GetCommandOutput(master.primary,
utils.ShellQuoteArgs(cmd))
AssertEqual(result_output.strip(), constants.INSTANCE_COMMUNICATION_NETWORK6,
msg="Checking network6")
# Add a new group and check whether the instance communication
# network connects to this new group
#
# We don't assume any particular group order and allow the output of
# 'gnt-network list' to print the 'default' and 'mygroup' groups in
# any order.
group = "mygroup"
AssertCommand(["gnt-group", "add", group])
cmd = ["gnt-network", "list", "--no-headers", "-o", "group_list",
network_name]
result_output = qa_utils.GetCommandOutput(master.primary,
utils.ShellQuoteArgs(cmd))
try:
r1 = "mygroup (routed, communication_rt)," \
" default (routed, communication_rt)"
AssertEqual(result_output.strip(), r1,
msg="Checking network connected groups")
except qa_error.Error:
r2 = "default (routed, communication_rt)," \
" mygroup (routed, communication_rt)"
AssertEqual(result_output.strip(), r2,
msg="Checking network connected groups")
# Modify cluster parameter 'instance-communication-network' to the
# same value and check that nothing happens.
cmd = "gnt-cluster modify --instance-communication-network=%s" % network_name
result_output = qa_utils.GetCommandOutput(master.primary, cmd)
print result_output
# Disable instance communication network, disconnect the instance
# communication network and remove it, and remove the group
cmd = "gnt-cluster modify --instance-communication-network="
result_output = qa_utils.GetCommandOutput(master.primary, cmd)
print result_output
cmd = ["gnt-network", "disconnect", network_name]
AssertCommand(utils.ShellQuoteArgs(cmd))
cmd = ["gnt-network", "remove", network_name]
AssertCommand(utils.ShellQuoteArgs(cmd))
cmd = ["gnt-group", "remove", group]
AssertCommand(utils.ShellQuoteArgs(cmd))
# Check that the 'default' node group exists
cmd = ["gnt-group", "list", "--no-headers", "-o", "name"]
result_output = GetCommandOutput(master.primary, utils.ShellQuoteArgs(cmd))
AssertEqual(result_output.strip(), "default", msg="Checking 'default' group")
# Check that no networks exist
cmd = ["gnt-network", "list", "--no-headers", "-o", "name"]
result_output = GetCommandOutput(master.primary, utils.ShellQuoteArgs(cmd))
AssertEqual(result_output.strip(), "", msg="Checking networks")
...@@ -123,12 +123,15 @@ def AssertNotIn(item, sequence): ...@@ -123,12 +123,15 @@ def AssertNotIn(item, sequence):
raise qa_error.Error("%r in %r" % (item, sequence)) raise qa_error.Error("%r in %r" % (item, sequence))
def AssertEqual(first, second): def AssertEqual(first, second, msg=""):
"""Raises an error when values aren't equal. """Raises an error when values aren't equal.
""" """
if not first == second: if not first == second:
raise qa_error.Error("%r == %r" % (first, second)) if msg:
raise qa_error.Error("%s: %r == %r" % (msg, first, second))
else:
raise qa_error.Error("%r == %r" % (first, second))
def AssertMatch(string, pattern): def AssertMatch(string, pattern):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment