Revision d74c2ca1

b/qa/Makefile.am
8 8
	qa_node.py \
9 9
	qa_os.py \
10 10
	qa_other.py \
11
	qa_tags.py \
11 12
	qa_utils.py
12 13
CLEANFILES = *.py[co]
b/qa/ganeti-qa.py
39 39
import qa_node
40 40
import qa_os
41 41
import qa_other
42
import qa_tags
42 43

  
43 44

  
44 45
def RunTest(fn, *args):
......
140 141
    RunTest(qa_instance.TestInstanceReinstall, instance)
141 142
    RunTest(qa_instance.TestInstanceStartup, instance)
142 143

  
144
  if qa_config.TestEnabled('tags'):
145
    RunTest(qa_tags.TestInstanceTags, instance)
146

  
143 147
  if qa_config.TestEnabled('node-volumes'):
144 148
    RunTest(qa_node.TestNodeVolumes)
145 149

  
......
240 244
  RunClusterTests()
241 245
  RunOsTests()
242 246

  
247
  if qa_config.TestEnabled('tags'):
248
    RunTest(qa_tags.TestClusterTags)
249

  
243 250
  pnode = qa_config.AcquireNode()
244 251
  try:
252
    if qa_config.TestEnabled('tags'):
253
      RunTest(qa_tags.TestNodeTags, pnode)
254

  
245 255
    if qa_config.TestEnabled('instance-add-plain-disk'):
246 256
      instance = RunTest(qa_instance.TestInstanceAddWithPlainDisk, pnode)
247 257
      RunCommonInstanceTests(instance)
b/qa/qa-sample.yaml
25 25
# Tests to run
26 26
tests:
27 27
  env: True
28

  
29 28
  os: True
29
  tags: True
30 30

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

  
18

  
19
"""Tags related QA tests.
20

  
21
"""
22

  
23
from ganeti import utils
24

  
25
import qa_config
26
import qa_utils
27

  
28
from qa_utils import AssertEqual, StartSSH
29

  
30

  
31
_TEMP_TAG_NAMES = ["TEMP-Ganeti-QA-Tag%d" % i for i in range(3)]
32
_TEMP_TAG_RE = r'^TEMP-Ganeti-QA-Tag\d+$'
33

  
34

  
35
def _TestTags(cmdfn):
36
  """Generic function for add-tags.
37

  
38
  """
39
  master = qa_config.GetMasterNode()
40

  
41
  cmd = cmdfn('add-tags') + _TEMP_TAG_NAMES
42
  AssertEqual(StartSSH(master['primary'],
43
                       utils.ShellQuoteArgs(cmd)).wait(), 0)
44

  
45
  cmd = cmdfn('list-tags')
46
  AssertEqual(StartSSH(master['primary'],
47
                       utils.ShellQuoteArgs(cmd)).wait(), 0)
48

  
49
  cmd = ['gnt-cluster', 'search-tags', _TEMP_TAG_RE]
50
  AssertEqual(StartSSH(master['primary'],
51
                       utils.ShellQuoteArgs(cmd)).wait(), 0)
52

  
53
  cmd = cmdfn('remove-tags') + _TEMP_TAG_NAMES
54
  AssertEqual(StartSSH(master['primary'],
55
                       utils.ShellQuoteArgs(cmd)).wait(), 0)
56

  
57

  
58
def TestClusterTags():
59
  """gnt-cluster tags"""
60
  _TestTags(lambda subcmd: ['gnt-cluster', subcmd])
61

  
62

  
63
def TestNodeTags(node):
64
  """gnt-node tags"""
65
  _TestTags(lambda subcmd: ['gnt-node', subcmd, node['primary']])
66

  
67

  
68
def TestInstanceTags(instance):
69
  """gnt-instance tags"""
70
  _TestTags(lambda subcmd: ['gnt-instance', subcmd, instance['name']])

Also available in: Unified diff