Revision 4c1a464b

b/qa/ganeti-qa.py
245 245
  RunTestIf(["instance-console", "rapi"],
246 246
            qa_rapi.TestRapiInstanceConsole, instance)
247 247

  
248
  RunTestIf("instance-reinstall", qa_instance.TestInstanceShutdown, instance)
248
  DOWN_TESTS = ["instance-reinstall", "instance-rename"]
249
  # shutdown instance for any 'down' tests
250
  RunTestIf(DOWN_TESTS, qa_instance.TestInstanceShutdown, instance)
251

  
252
  # now run the 'down' state tests
249 253
  RunTestIf("instance-reinstall", qa_instance.TestInstanceReinstall, instance)
250 254
  RunTestIf(["instance-reinstall", "rapi"],
251 255
            qa_rapi.TestRapiInstanceReinstall, instance)
252
  RunTestIf("instance-reinstall", qa_instance.TestInstanceStartup, instance)
253

  
254
  RunTestIf("instance-reboot", qa_instance.TestInstanceReboot, instance)
256
  # RAPI reinstall will leave the instance up by default, so we have
257
  # to stop it again
258
  RunTestIf(["instance-reinstall", "rapi"],
259
            qa_rapi.TestRapiInstanceShutdown, instance)
255 260

  
256 261
  if qa_config.TestEnabled("instance-rename"):
257 262
    rename_source = instance["name"]
258 263
    rename_target = qa_config.get("rename", None)
259
    RunTest(qa_instance.TestInstanceShutdown, instance)
260 264
    # perform instance rename to the same name
261
    RunTest(qa_instance.TestInstanceRename, rename_source, rename_source)
262
    RunTestIf("rapi", qa_rapi.TestRapiInstanceRename,
265
    RunTest(qa_instance.TestInstanceRenameAndBack,
266
            rename_source, rename_source)
267
    RunTestIf("rapi", qa_rapi.TestRapiInstanceRenameAndBack,
263 268
              rename_source, rename_source)
264 269
    if rename_target is not None:
265 270
      # perform instance rename to a different name, if we have one configured
266
      RunTest(qa_instance.TestInstanceRename, rename_source, rename_target)
267
      RunTest(qa_instance.TestInstanceRename, rename_target, rename_source)
268
      RunTestIf("rapi", qa_rapi.TestRapiInstanceRename,
271
      RunTest(qa_instance.TestInstanceRenameAndBack,
272
              rename_source, rename_target)
273
      RunTestIf("rapi", qa_rapi.TestRapiInstanceRenameAndBack,
269 274
                rename_source, rename_target)
270
      RunTestIf("rapi", qa_rapi.TestRapiInstanceRename,
271
                rename_target, rename_source)
272
    RunTest(qa_instance.TestInstanceStartup, instance)
275

  
276
  # and now start the instance again
277
  RunTestIf(DOWN_TESTS, qa_instance.TestInstanceStartup, instance)
278

  
279
  RunTestIf("instance-reboot", qa_instance.TestInstanceReboot, instance)
273 280

  
274 281
  RunTestIf("tags", qa_tags.TestInstanceTags, instance)
275 282

  
b/qa/qa_instance.py
1 1
#
2 2
#
3 3

  
4
# Copyright (C) 2007, 2011 Google Inc.
4
# Copyright (C) 2007, 2011, 2012 Google Inc.
5 5
#
6 6
# This program is free software; you can redistribute it and/or modify
7 7
# it under the terms of the GNU General Public License as published by
......
147 147
           _ReadSsconfInstanceList())
148 148

  
149 149

  
150
def TestInstanceRename(rename_source, rename_target):
151
  """gnt-instance rename"""
152
  _CheckSsconfInstanceList(rename_source)
153
  AssertCommand(["gnt-instance", "rename", rename_source, rename_target])
154
  _CheckSsconfInstanceList(rename_target)
155
  AssertCommand(["gnt-instance", "rename", rename_target, rename_source])
150
def TestInstanceRenameAndBack(rename_source, rename_target):
151
  """gnt-instance rename
152

  
153
  This must leave the instance with the original name, not the target
154
  name.
155

  
156
  """
156 157
  _CheckSsconfInstanceList(rename_source)
158
  # first do a rename to a different actual name, expecting it to fail
157 159
  qa_utils.AddToEtcHosts(["meeeeh-not-exists", rename_target])
158 160
  try:
159 161
    AssertCommand(["gnt-instance", "rename", rename_source, rename_target],
......
161 163
    _CheckSsconfInstanceList(rename_source)
162 164
  finally:
163 165
    qa_utils.RemoveFromEtcHosts(["meeeeh-not-exists", rename_target])
166
  # and now rename instance to rename_target...
164 167
  AssertCommand(["gnt-instance", "rename", rename_source, rename_target])
165 168
  _CheckSsconfInstanceList(rename_target)
169
  # and back
170
  AssertCommand(["gnt-instance", "rename", rename_target, rename_source])
171
  _CheckSsconfInstanceList(rename_source)
166 172

  
167 173

  
168 174
def TestInstanceFailover(instance):
b/qa/qa_rapi.py
1 1
#
2 2
#
3 3

  
4
# Copyright (C) 2007, 2008, 2009, 2010, 2011 Google Inc.
4
# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Google Inc.
5 5
#
6 6
# This program is free software; you can redistribute it and/or modify
7 7
# it under the terms of the GNU General Public License as published by
......
609 609
  _WaitForRapiJob(_rapi_client.StartupInstance(instance["name"]))
610 610

  
611 611

  
612
def TestRapiInstanceRename(rename_source, rename_target):
613
  """Test renaming instance via RAPI"""
612
def TestRapiInstanceRenameAndBack(rename_source, rename_target):
613
  """Test renaming instance via RAPI
614

  
615
  This must leave the instance with the original name (in the
616
  non-failure case).
617

  
618
  """
614 619
  _WaitForRapiJob(_rapi_client.RenameInstance(rename_source, rename_target))
620
  _WaitForRapiJob(_rapi_client.RenameInstance(rename_target, rename_source))
615 621

  
616 622

  
617 623
def TestRapiInstanceReinstall(instance):

Also available in: Unified diff