qa_env.py 2.98 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"],
Niklas Hambuechen's avatar
Niklas Hambuechen committed
63
          ["gnt-filter", "--version"],
Iustin Pop's avatar
Iustin Pop committed
64 65 66 67
          ["ganeti-noded", "--version"],
          ["ganeti-rapi", "--version"],
          ["ganeti-watcher", "--version"],
          ["ganeti-confd", "--version"],
Thomas Thrainer's avatar
Thomas Thrainer committed
68
          ["ganeti-luxid", "--version"],
Klaus Aehlig's avatar
Klaus Aehlig committed
69
          ["ganeti-wconfd", "--version"],
Iustin Pop's avatar
Iustin Pop committed
70
          )
71

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

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


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

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

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

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

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

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