qa_monitoring.py 1.86 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#
#

# Copyright (C) 2007, 2011, 2012, 2013 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.


"""Monitoring related QA tests.

"""

from ganeti import _autoconf
27
from ganeti import constants
28
29
30
31
32
33
34
35
36
37
38
39
40
41

import qa_config

from qa_utils import AssertCommand
from qa_instance_utils import CreateInstanceByDiskTemplate, \
                              RemoveInstance

MON_COLLECTOR = _autoconf.PKGLIBDIR + "/mon-collector"


def TestInstStatusCollector():
  """Test the Xen instance status collector.

  """
42
43
44
45
46
  enabled_hypervisors = qa_config.GetEnabledHypervisors()
  is_xen = (constants.HT_XEN_PVM in enabled_hypervisors or
            constants.HT_XEN_HVM in enabled_hypervisors)
  fail = not is_xen

47
  # Execute on master on an empty cluster
48
  AssertCommand([MON_COLLECTOR, "inst-status-xen"], fail=fail)
49
50
51
52
53
54
55

  #Execute on cluster with instances
  node1 = qa_config.AcquireNode()
  node2 = qa_config.AcquireNode()
  template = qa_config.GetDefaultDiskTemplate()

  instance = CreateInstanceByDiskTemplate([node1, node2], template)
56
57
  AssertCommand([MON_COLLECTOR, "inst-status-xen"], node=node1, fail=fail)
  AssertCommand([MON_COLLECTOR, "inst-status-xen"], node=node2, fail=fail)
58
59
60
61
  RemoveInstance(instance)

  node1.Release()
  node2.Release()