Statistics
| Branch: | Tag: | Revision:

root / qa / qa_group.py @ 75cf411a

History | View | Annotate | Download (2.2 kB)

1
#
2
#
3

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

    
21

    
22
from ganeti import constants
23

    
24
import qa_config
25
from qa_utils import AssertCommand
26

    
27

    
28
def TestGroupAddRemoveRename():
29
  """gnt-group add/remove/rename"""
30
  groups = qa_config.get("groups", {})
31

    
32
  existing_group_with_nodes = groups.get("group-with-nodes",
33
                                         constants.INITIAL_NODE_GROUP_NAME)
34
  group1, group2, group3 = groups.get("inexistent-groups",
35
                                      ["group1", "group2", "group3"])[:3]
36

    
37
  AssertCommand(["gnt-group", "add", group1])
38
  AssertCommand(["gnt-group", "add", group2])
39
  AssertCommand(["gnt-group", "add", group2], fail=True)
40
  AssertCommand(["gnt-group", "add", existing_group_with_nodes], fail=True)
41

    
42
  AssertCommand(["gnt-group", "rename", group1, group2], fail=True)
43
  AssertCommand(["gnt-group", "rename", group1, group3])
44

    
45
  try:
46
    AssertCommand(["gnt-group", "rename", existing_group_with_nodes, group1])
47

    
48
    AssertCommand(["gnt-group", "remove", group2])
49
    AssertCommand(["gnt-group", "remove", group3])
50
    AssertCommand(["gnt-group", "remove", group1], fail=True)
51
  finally:
52
    # Try to ensure idempotency re groups that already existed.
53
    AssertCommand(["gnt-group", "rename", group1, existing_group_with_nodes])
54

    
55

    
56
def TestGroupListDefaultFields():
57
  """gnt-group list"""
58
  AssertCommand(["gnt-group", "list"])
59

    
60

    
61
def TestGroupListAllFields():
62
  """gnt-group list -o FIELDS"""
63
  AssertCommand(["gnt-group", "list", "-o",
64
                 "name,uuid,node_cnt,node_list,pinst_cnt,pinst_list"])