qa_monitoring.py 1.84 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
#
#

# 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.

"""

26
from ganeti import _constants
27
from ganeti import constants
28
29
30
31
32
33
34

import qa_config

from qa_utils import AssertCommand
from qa_instance_utils import CreateInstanceByDiskTemplate, \
                              RemoveInstance

35
MON_COLLECTOR = _constants.PKGLIBDIR + "/mon-collector"
36
37
38
39
40
41


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

  """
42
  enabled_hypervisors = qa_config.GetEnabledHypervisors()
43

44
45
  is_xen = (constants.HT_XEN_PVM in enabled_hypervisors or
            constants.HT_XEN_HVM in enabled_hypervisors)
46
47
  if not is_xen:
    return
48

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

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

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

  node1.Release()
  node2.Release()