-# Copyright (C) 2007 Google Inc.
+#
+#
+
+# Copyright (C) 2007, 2010, 2011, 2012 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
from ganeti import utils
import qa_config
-import qa_utils
-from qa_utils import AssertEqual, StartSSH
+from qa_utils import AssertCommand
-@qa_utils.DefineHook('env-ssh-connection')
def TestSshConnection():
"""Test SSH connection.
"""
- for node in qa_config.get('nodes'):
- AssertEqual(StartSSH(node['primary'], 'exit').wait(), 0)
+ for node in qa_config.get("nodes"):
+ AssertCommand("exit", node=node)
-@qa_utils.DefineHook('env-ganeti-commands')
def TestGanetiCommands():
"""Test availibility of Ganeti commands.
"""
- cmds = ( ['gnt-cluster', '--version'],
- ['gnt-os', '--version'],
- ['gnt-node', '--version'],
- ['gnt-instance', '--version'],
- ['gnt-backup', '--version'],
- ['ganeti-noded', '--version'],
- ['ganeti-watcher', '--version'] )
-
- cmd = ' && '.join([utils.ShellQuoteArgs(i) for i in cmds])
+ cmds = (["gnt-backup", "--version"],
+ ["gnt-cluster", "--version"],
+ ["gnt-debug", "--version"],
+ ["gnt-instance", "--version"],
+ ["gnt-job", "--version"],
+ ["gnt-node", "--version"],
+ ["gnt-os", "--version"],
+ ["ganeti-masterd", "--version"],
+ ["ganeti-noded", "--version"],
+ ["ganeti-rapi", "--version"],
+ ["ganeti-watcher", "--version"],
+ ["ganeti-confd", "--version"],
+ )
+
+ cmd = " && ".join([utils.ShellQuoteArgs(i) for i in cmds])
+
+ for node in qa_config.get("nodes"):
+ AssertCommand(cmd, node=node)
- for node in qa_config.get('nodes'):
- AssertEqual(StartSSH(node['primary'], cmd).wait(), 0)
-
-@qa_utils.DefineHook('env-icmp-ping')
def TestIcmpPing():
"""ICMP ping each node.
"""
- nodes = qa_config.get('nodes')
+ nodes = qa_config.get("nodes")
- for node in nodes:
- check = []
- for i in nodes:
- check.append(i['primary'])
- if i.has_key('secondary'):
- check.append(i['secondary'])
+ pingprimary = pingsecondary = "fping"
+ if qa_config.get("primary_ip_version") == 6:
+ pingprimary = "fping6"
- ping = lambda ip: utils.ShellQuoteArgs(['ping', '-w', '3', '-c', '1', ip])
- cmd = ' && '.join([ping(i) for i in check])
+ pricmd = [pingprimary, "-e"]
+ seccmd = [pingsecondary, "-e"]
+ for i in nodes:
+ pricmd.append(i.primary)
+ if i.secondary:
+ seccmd.append(i.secondary)
- AssertEqual(StartSSH(node['primary'], cmd).wait(), 0)
+ pristr = utils.ShellQuoteArgs(pricmd)
+ if seccmd:
+ cmdall = "%s && %s" % (pristr, utils.ShellQuoteArgs(seccmd))
+ else:
+ cmdall = pristr
+
+ for node in nodes:
+ AssertCommand(cmdall, node=node)