root / qa / qa_tags.py @ 625ac113
History | View | Annotate | Download (2.3 kB)
1 | d74c2ca1 | Michael Hanselmann | # Copyright (C) 2007 Google Inc.
|
---|---|---|---|
2 | d74c2ca1 | Michael Hanselmann | #
|
3 | d74c2ca1 | Michael Hanselmann | # This program is free software; you can redistribute it and/or modify
|
4 | d74c2ca1 | Michael Hanselmann | # it under the terms of the GNU General Public License as published by
|
5 | d74c2ca1 | Michael Hanselmann | # the Free Software Foundation; either version 2 of the License, or
|
6 | d74c2ca1 | Michael Hanselmann | # (at your option) any later version.
|
7 | d74c2ca1 | Michael Hanselmann | #
|
8 | d74c2ca1 | Michael Hanselmann | # This program is distributed in the hope that it will be useful, but
|
9 | d74c2ca1 | Michael Hanselmann | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
10 | d74c2ca1 | Michael Hanselmann | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11 | d74c2ca1 | Michael Hanselmann | # General Public License for more details.
|
12 | d74c2ca1 | Michael Hanselmann | #
|
13 | d74c2ca1 | Michael Hanselmann | # You should have received a copy of the GNU General Public License
|
14 | d74c2ca1 | Michael Hanselmann | # along with this program; if not, write to the Free Software
|
15 | d74c2ca1 | Michael Hanselmann | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
16 | d74c2ca1 | Michael Hanselmann | # 02110-1301, USA.
|
17 | d74c2ca1 | Michael Hanselmann | |
18 | d74c2ca1 | Michael Hanselmann | |
19 | d74c2ca1 | Michael Hanselmann | """Tags related QA tests.
|
20 | d74c2ca1 | Michael Hanselmann |
|
21 | d74c2ca1 | Michael Hanselmann | """
|
22 | d74c2ca1 | Michael Hanselmann | |
23 | d74c2ca1 | Michael Hanselmann | from ganeti import utils |
24 | a47f574c | Oleksiy Mishchenko | from ganeti import constants |
25 | d74c2ca1 | Michael Hanselmann | |
26 | d74c2ca1 | Michael Hanselmann | import qa_config |
27 | d74c2ca1 | Michael Hanselmann | import qa_utils |
28 | a47f574c | Oleksiy Mishchenko | import qa_rapi |
29 | d74c2ca1 | Michael Hanselmann | |
30 | d74c2ca1 | Michael Hanselmann | from qa_utils import AssertEqual, StartSSH |
31 | d74c2ca1 | Michael Hanselmann | |
32 | d74c2ca1 | Michael Hanselmann | |
33 | d74c2ca1 | Michael Hanselmann | _TEMP_TAG_NAMES = ["TEMP-Ganeti-QA-Tag%d" % i for i in range(3)] |
34 | d74c2ca1 | Michael Hanselmann | _TEMP_TAG_RE = r'^TEMP-Ganeti-QA-Tag\d+$'
|
35 | d74c2ca1 | Michael Hanselmann | |
36 | a47f574c | Oleksiy Mishchenko | _KIND_TO_COMMAND = { |
37 | a47f574c | Oleksiy Mishchenko | constants.TAG_CLUSTER: "gnt-cluster",
|
38 | a47f574c | Oleksiy Mishchenko | constants.TAG_NODE: "gnt-node",
|
39 | a47f574c | Oleksiy Mishchenko | constants.TAG_INSTANCE: "gnt-instance",
|
40 | a47f574c | Oleksiy Mishchenko | } |
41 | a47f574c | Oleksiy Mishchenko | |
42 | d74c2ca1 | Michael Hanselmann | |
43 | a47f574c | Oleksiy Mishchenko | def _TestTags(kind, name): |
44 | d74c2ca1 | Michael Hanselmann | """Generic function for add-tags.
|
45 | d74c2ca1 | Michael Hanselmann |
|
46 | d74c2ca1 | Michael Hanselmann | """
|
47 | d74c2ca1 | Michael Hanselmann | master = qa_config.GetMasterNode() |
48 | d74c2ca1 | Michael Hanselmann | |
49 | a47f574c | Oleksiy Mishchenko | def cmdfn(subcmd): |
50 | a47f574c | Oleksiy Mishchenko | cmd = [_KIND_TO_COMMAND[kind], subcmd] |
51 | a47f574c | Oleksiy Mishchenko | |
52 | a47f574c | Oleksiy Mishchenko | if kind != constants.TAG_CLUSTER:
|
53 | a47f574c | Oleksiy Mishchenko | cmd.append(name) |
54 | a47f574c | Oleksiy Mishchenko | |
55 | a47f574c | Oleksiy Mishchenko | return cmd
|
56 | a47f574c | Oleksiy Mishchenko | |
57 | d74c2ca1 | Michael Hanselmann | cmd = cmdfn('add-tags') + _TEMP_TAG_NAMES
|
58 | d74c2ca1 | Michael Hanselmann | AssertEqual(StartSSH(master['primary'],
|
59 | d74c2ca1 | Michael Hanselmann | utils.ShellQuoteArgs(cmd)).wait(), 0)
|
60 | d74c2ca1 | Michael Hanselmann | |
61 | d74c2ca1 | Michael Hanselmann | cmd = cmdfn('list-tags')
|
62 | d74c2ca1 | Michael Hanselmann | AssertEqual(StartSSH(master['primary'],
|
63 | d74c2ca1 | Michael Hanselmann | utils.ShellQuoteArgs(cmd)).wait(), 0)
|
64 | d74c2ca1 | Michael Hanselmann | |
65 | d74c2ca1 | Michael Hanselmann | cmd = ['gnt-cluster', 'search-tags', _TEMP_TAG_RE] |
66 | d74c2ca1 | Michael Hanselmann | AssertEqual(StartSSH(master['primary'],
|
67 | d74c2ca1 | Michael Hanselmann | utils.ShellQuoteArgs(cmd)).wait(), 0)
|
68 | d74c2ca1 | Michael Hanselmann | |
69 | a47f574c | Oleksiy Mishchenko | if qa_rapi.Enabled():
|
70 | a47f574c | Oleksiy Mishchenko | qa_rapi.TestTags(kind, name, _TEMP_TAG_NAMES) |
71 | a47f574c | Oleksiy Mishchenko | |
72 | d74c2ca1 | Michael Hanselmann | cmd = cmdfn('remove-tags') + _TEMP_TAG_NAMES
|
73 | d74c2ca1 | Michael Hanselmann | AssertEqual(StartSSH(master['primary'],
|
74 | d74c2ca1 | Michael Hanselmann | utils.ShellQuoteArgs(cmd)).wait(), 0)
|
75 | d74c2ca1 | Michael Hanselmann | |
76 | d74c2ca1 | Michael Hanselmann | |
77 | d74c2ca1 | Michael Hanselmann | def TestClusterTags(): |
78 | d74c2ca1 | Michael Hanselmann | """gnt-cluster tags"""
|
79 | a47f574c | Oleksiy Mishchenko | _TestTags(constants.TAG_CLUSTER, "")
|
80 | d74c2ca1 | Michael Hanselmann | |
81 | d74c2ca1 | Michael Hanselmann | |
82 | d74c2ca1 | Michael Hanselmann | def TestNodeTags(node): |
83 | d74c2ca1 | Michael Hanselmann | """gnt-node tags"""
|
84 | a47f574c | Oleksiy Mishchenko | _TestTags(constants.TAG_NODE, node["primary"])
|
85 | d74c2ca1 | Michael Hanselmann | |
86 | d74c2ca1 | Michael Hanselmann | |
87 | d74c2ca1 | Michael Hanselmann | def TestInstanceTags(instance): |
88 | d74c2ca1 | Michael Hanselmann | """gnt-instance tags"""
|
89 | a47f574c | Oleksiy Mishchenko | _TestTags(constants.TAG_INSTANCE, instance["name"]) |