Statistics
| Branch: | Tag: | Revision:

root / qa / qa_tags.py @ 7910e7a5

History | View | Annotate | Download (2.1 kB)

1 c68d1f43 Michael Hanselmann
#
2 c68d1f43 Michael Hanselmann
#
3 c68d1f43 Michael Hanselmann
4 d74c2ca1 Michael Hanselmann
# Copyright (C) 2007 Google Inc.
5 d74c2ca1 Michael Hanselmann
#
6 d74c2ca1 Michael Hanselmann
# This program is free software; you can redistribute it and/or modify
7 d74c2ca1 Michael Hanselmann
# it under the terms of the GNU General Public License as published by
8 d74c2ca1 Michael Hanselmann
# the Free Software Foundation; either version 2 of the License, or
9 d74c2ca1 Michael Hanselmann
# (at your option) any later version.
10 d74c2ca1 Michael Hanselmann
#
11 d74c2ca1 Michael Hanselmann
# This program is distributed in the hope that it will be useful, but
12 d74c2ca1 Michael Hanselmann
# WITHOUT ANY WARRANTY; without even the implied warranty of
13 d74c2ca1 Michael Hanselmann
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 d74c2ca1 Michael Hanselmann
# General Public License for more details.
15 d74c2ca1 Michael Hanselmann
#
16 d74c2ca1 Michael Hanselmann
# You should have received a copy of the GNU General Public License
17 d74c2ca1 Michael Hanselmann
# along with this program; if not, write to the Free Software
18 d74c2ca1 Michael Hanselmann
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 d74c2ca1 Michael Hanselmann
# 02110-1301, USA.
20 d74c2ca1 Michael Hanselmann
21 d74c2ca1 Michael Hanselmann
22 d74c2ca1 Michael Hanselmann
"""Tags related QA tests.
23 d74c2ca1 Michael Hanselmann

24 d74c2ca1 Michael Hanselmann
"""
25 d74c2ca1 Michael Hanselmann
26 d74c2ca1 Michael Hanselmann
from ganeti import utils
27 d74c2ca1 Michael Hanselmann
28 d74c2ca1 Michael Hanselmann
import qa_config
29 d74c2ca1 Michael Hanselmann
import qa_utils
30 d74c2ca1 Michael Hanselmann
31 d74c2ca1 Michael Hanselmann
from qa_utils import AssertEqual, StartSSH
32 d74c2ca1 Michael Hanselmann
33 d74c2ca1 Michael Hanselmann
34 d74c2ca1 Michael Hanselmann
_TEMP_TAG_NAMES = ["TEMP-Ganeti-QA-Tag%d" % i for i in range(3)]
35 d74c2ca1 Michael Hanselmann
_TEMP_TAG_RE = r'^TEMP-Ganeti-QA-Tag\d+$'
36 d74c2ca1 Michael Hanselmann
37 d74c2ca1 Michael Hanselmann
38 d74c2ca1 Michael Hanselmann
def _TestTags(cmdfn):
39 d74c2ca1 Michael Hanselmann
  """Generic function for add-tags.
40 d74c2ca1 Michael Hanselmann

41 d74c2ca1 Michael Hanselmann
  """
42 d74c2ca1 Michael Hanselmann
  master = qa_config.GetMasterNode()
43 d74c2ca1 Michael Hanselmann
44 d74c2ca1 Michael Hanselmann
  cmd = cmdfn('add-tags') + _TEMP_TAG_NAMES
45 d74c2ca1 Michael Hanselmann
  AssertEqual(StartSSH(master['primary'],
46 d74c2ca1 Michael Hanselmann
                       utils.ShellQuoteArgs(cmd)).wait(), 0)
47 d74c2ca1 Michael Hanselmann
48 d74c2ca1 Michael Hanselmann
  cmd = cmdfn('list-tags')
49 d74c2ca1 Michael Hanselmann
  AssertEqual(StartSSH(master['primary'],
50 d74c2ca1 Michael Hanselmann
                       utils.ShellQuoteArgs(cmd)).wait(), 0)
51 d74c2ca1 Michael Hanselmann
52 d74c2ca1 Michael Hanselmann
  cmd = ['gnt-cluster', 'search-tags', _TEMP_TAG_RE]
53 d74c2ca1 Michael Hanselmann
  AssertEqual(StartSSH(master['primary'],
54 d74c2ca1 Michael Hanselmann
                       utils.ShellQuoteArgs(cmd)).wait(), 0)
55 d74c2ca1 Michael Hanselmann
56 d74c2ca1 Michael Hanselmann
  cmd = cmdfn('remove-tags') + _TEMP_TAG_NAMES
57 d74c2ca1 Michael Hanselmann
  AssertEqual(StartSSH(master['primary'],
58 d74c2ca1 Michael Hanselmann
                       utils.ShellQuoteArgs(cmd)).wait(), 0)
59 d74c2ca1 Michael Hanselmann
60 d74c2ca1 Michael Hanselmann
61 9b3939ea Michael Hanselmann
@qa_utils.DefineHook('tags-cluster')
62 d74c2ca1 Michael Hanselmann
def TestClusterTags():
63 d74c2ca1 Michael Hanselmann
  """gnt-cluster tags"""
64 d74c2ca1 Michael Hanselmann
  _TestTags(lambda subcmd: ['gnt-cluster', subcmd])
65 d74c2ca1 Michael Hanselmann
66 d74c2ca1 Michael Hanselmann
67 9b3939ea Michael Hanselmann
@qa_utils.DefineHook('tags-node')
68 d74c2ca1 Michael Hanselmann
def TestNodeTags(node):
69 d74c2ca1 Michael Hanselmann
  """gnt-node tags"""
70 d74c2ca1 Michael Hanselmann
  _TestTags(lambda subcmd: ['gnt-node', subcmd, node['primary']])
71 d74c2ca1 Michael Hanselmann
72 d74c2ca1 Michael Hanselmann
73 9b3939ea Michael Hanselmann
@qa_utils.DefineHook('tags-instance')
74 d74c2ca1 Michael Hanselmann
def TestInstanceTags(instance):
75 d74c2ca1 Michael Hanselmann
  """gnt-instance tags"""
76 d74c2ca1 Michael Hanselmann
  _TestTags(lambda subcmd: ['gnt-instance', subcmd, instance['name']])