Revision 8e1db003 qa/qa_node.py

b/qa/qa_node.py
20 20

  
21 21

  
22 22
from ganeti import utils
23
from ganeti import constants
23 24

  
24 25
import qa_config
25 26
import qa_error
26 27
import qa_utils
27 28

  
28
from qa_utils import AssertEqual, StartSSH
29
from qa_utils import AssertEqual, AssertNotEqual, StartSSH
29 30

  
30 31

  
31 32
def _NodeAdd(node, readd=False):
......
96 97
                       utils.ShellQuoteArgs(cmd)).wait(), 0)
97 98

  
98 99

  
100
def TestNodeStorage():
101
  """gnt-node storage"""
102
  master = qa_config.GetMasterNode()
103

  
104
  for storage_type in constants.VALID_STORAGE_TYPES:
105
    # Test simple list
106
    cmd = ["gnt-node", "list-storage", "--storage-type", storage_type]
107
    AssertEqual(StartSSH(master["primary"],
108
                         utils.ShellQuoteArgs(cmd)).wait(), 0)
109

  
110
    # Test all storage fields
111
    cmd = ["gnt-node", "list-storage", "--storage-type", storage_type,
112
           "--output=%s" % ",".join(list(constants.VALID_STORAGE_FIELDS) +
113
                                    [constants.SF_NODE, constants.SF_TYPE])]
114
    AssertEqual(StartSSH(master["primary"],
115
                         utils.ShellQuoteArgs(cmd)).wait(), 0)
116

  
117
    # Get list of valid storage devices
118
    cmd = ["gnt-node", "list-storage", "--storage-type", storage_type,
119
           "--output=node,name,allocatable", "--separator=|",
120
           "--no-headers"]
121
    output = qa_utils.GetCommandOutput(master["primary"],
122
                                       utils.ShellQuoteArgs(cmd))
123

  
124
    # Test with up to two devices
125
    testdevcount = 2
126

  
127
    for line in output.splitlines()[:testdevcount]:
128
      (node_name, st_name, st_allocatable) = line.split("|")
129

  
130
      # Dummy modification without any changes
131
      cmd = ["gnt-node", "modify-storage", node_name, storage_type, st_name]
132
      AssertEqual(StartSSH(master["primary"],
133
                           utils.ShellQuoteArgs(cmd)).wait(), 0)
134

  
135
      # Make sure we end up with the same value as before
136
      if st_allocatable.lower() == "y":
137
        test_allocatable = ["no", "yes"]
138
      else:
139
        test_allocatable = ["yes", "no"]
140

  
141
      if (constants.SF_ALLOCATABLE in
142
          constants.MODIFIABLE_STORAGE_FIELDS.get(storage_type, [])):
143
        assert_fn = AssertEqual
144
      else:
145
        assert_fn = AssertNotEqual
146

  
147
      for i in test_allocatable:
148
        cmd = ["gnt-node", "modify-storage", "--allocatable", i,
149
               node_name, storage_type, st_name]
150
        assert_fn(StartSSH(master["primary"],
151
                  utils.ShellQuoteArgs(cmd)).wait(), 0)
152

  
153
      # Test repair functionality
154
      cmd = ["gnt-node", "repair-storage", node_name, storage_type, st_name]
155

  
156
      if (constants.SO_FIX_CONSISTENCY in
157
          constants.VALID_STORAGE_OPERATIONS.get(storage_type, [])):
158
        assert_fn = AssertEqual
159
      else:
160
        assert_fn = AssertNotEqual
161

  
162
      assert_fn(StartSSH(master["primary"],
163
                         utils.ShellQuoteArgs(cmd)).wait(), 0)
164

  
165

  
99 166
def TestNodeFailover(node, node2):
100 167
  """gnt-node failover"""
101 168
  master = qa_config.GetMasterNode()

Also available in: Unified diff