qa_env.py 2.87 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 59 60 61 62 63 64
          ["gnt-cluster", "--version"],
          ["gnt-debug", "--version"],
          ["gnt-instance", "--version"],
          ["gnt-job", "--version"],
          ["gnt-node", "--version"],
          ["gnt-os", "--version"],
          ["ganeti-noded", "--version"],
          ["ganeti-rapi", "--version"],
          ["ganeti-watcher", "--version"],
          ["ganeti-confd", "--version"],
Thomas Thrainer's avatar
Thomas Thrainer committed
65
          ["ganeti-luxid", "--version"],
Klaus Aehlig's avatar
Klaus Aehlig committed
66
          ["ganeti-wconfd", "--version"],
Iustin Pop's avatar
Iustin Pop committed
67
          )
68

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

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


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

  """
Iustin Pop's avatar
Iustin Pop committed
79
  nodes = qa_config.get("nodes")
80

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

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

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

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