qa_env.py 2.94 KB
Newer Older
1 2 3
#
#

Iustin Pop's avatar
Iustin Pop committed
4
# Copyright (C) 2007, 2010, 2011, 2012 Google Inc.
Klaus Aehlig's avatar
Klaus Aehlig committed
5
# All rights reserved.
6
#
Klaus Aehlig's avatar
Klaus Aehlig committed
7 8 9
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
10
#
Klaus Aehlig's avatar
Klaus Aehlig committed
11 12
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
13
#
Klaus Aehlig's avatar
Klaus Aehlig committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 30 31 32 33 34 35 36 37 38


"""Cluster environment related QA tests.

"""

from ganeti import utils

import qa_config

Iustin Pop's avatar
Iustin Pop committed
39
from qa_utils import AssertCommand
40 41 42 43 44 45


def TestSshConnection():
  """Test SSH connection.

  """
Iustin Pop's avatar
Iustin Pop committed
46 47
  for node in qa_config.get("nodes"):
    AssertCommand("exit", node=node)
48 49 50 51 52 53


def TestGanetiCommands():
  """Test availibility of Ganeti commands.

  """
Andrea Spadaccini's avatar
Andrea Spadaccini committed
54
  cmds = (["gnt-backup", "--version"],
Iustin Pop's avatar
Iustin Pop committed
55 56 57 58
          ["gnt-cluster", "--version"],
          ["gnt-debug", "--version"],
          ["gnt-instance", "--version"],
          ["gnt-job", "--version"],
59
          ["gnt-network", "--version"],
Iustin Pop's avatar
Iustin Pop committed
60 61
          ["gnt-node", "--version"],
          ["gnt-os", "--version"],
62
          ["gnt-storage", "--version"],
Iustin Pop's avatar
Iustin Pop committed
63 64 65 66
          ["ganeti-noded", "--version"],
          ["ganeti-rapi", "--version"],
          ["ganeti-watcher", "--version"],
          ["ganeti-confd", "--version"],
Thomas Thrainer's avatar
Thomas Thrainer committed
67
          ["ganeti-luxid", "--version"],
Klaus Aehlig's avatar
Klaus Aehlig committed
68
          ["ganeti-wconfd", "--version"],
Iustin Pop's avatar
Iustin Pop committed
69
          )
70

Iustin Pop's avatar
Iustin Pop committed
71
  cmd = " && ".join([utils.ShellQuoteArgs(i) for i in cmds])
72

Iustin Pop's avatar
Iustin Pop committed
73
  for node in qa_config.get("nodes"):
Iustin Pop's avatar
Iustin Pop committed
74
    AssertCommand(cmd, node=node)
75 76 77 78 79 80


def TestIcmpPing():
  """ICMP ping each node.

  """
Iustin Pop's avatar
Iustin Pop committed
81
  nodes = qa_config.get("nodes")
82

Iustin Pop's avatar
Iustin Pop committed
83
  pingprimary = pingsecondary = "fping"
Manuel Franceschini's avatar
Manuel Franceschini committed
84
  if qa_config.get("primary_ip_version") == 6:
Iustin Pop's avatar
Iustin Pop committed
85
    pingprimary = "fping6"
Manuel Franceschini's avatar
Manuel Franceschini committed
86

Iustin Pop's avatar
Iustin Pop committed
87 88
  pricmd = [pingprimary, "-e"]
  seccmd = [pingsecondary, "-e"]
Iustin Pop's avatar
Iustin Pop committed
89
  for i in nodes:
90 91 92
    pricmd.append(i.primary)
    if i.secondary:
      seccmd.append(i.secondary)
Iustin Pop's avatar
Iustin Pop committed
93 94 95 96 97 98

  pristr = utils.ShellQuoteArgs(pricmd)
  if seccmd:
    cmdall = "%s && %s" % (pristr, utils.ShellQuoteArgs(seccmd))
  else:
    cmdall = pristr
99

Iustin Pop's avatar
Iustin Pop committed
100 101
  for node in nodes:
    AssertCommand(cmdall, node=node)