Revision a9e3e04d

b/qa/rapi-workload.py
190 190
  get_fn(*args)
191 191

  
192 192

  
193
def Workload(client):
194
  """ The actual RAPI workload used for tests.
193
def TestGetters(client):
194
  """ Tests the various get functions which only retrieve information about the
195
  cluster.
195 196

  
196 197
  @type client C{GanetiRapiClientWrapper}
197
  @param client A wrapped RAPI client.
198 198

  
199 199
  """
200

  
201
  # First just the simple information retrievals
202 200
  client.GetVersion()
203 201
  client.GetFeatures()
204 202
  client.GetOperatingSystems()
......
215 213
  client.GetGroups()
216 214
  client.GetGroups(bulk=True)
217 215

  
216

  
217
def RemoveAllInstances(client):
218
  """ Queries for a list of instances, then removes them all.
219

  
220
  @type client C{GanetiRapiClientWrapper}
221
  @param client A wrapped RAPI client.
222

  
223
  """
224
  instances = client.GetInstances()
225
  for inst in instances:
226
    Finish(client, client.DeleteInstance, inst)
227

  
228
  instances = client.GetInstances()
229
  assert len(instances) == 0
230

  
231

  
232
def TestSingleInstance(client, instance_name, alternate_name, node_one,
233
                       node_two):
234
  """ Creates an instance, performs operations involving it, and then deletes
235
  it.
236

  
237
  @type client C{GanetiRapiClientWrapper}
238
  @param client A wrapped RAPI client.
239
  @type instance_name string
240
  @param instance_name The hostname to use.
241
  @type instance_name string
242
  @param instance_name Another valid hostname to use.
243
  @type node_one string
244
  @param node_one A node on which an instance can be added.
245
  @type node_two string
246
  @param node_two A node on which an instance can be added.
247

  
248
  """
249

  
250
  # Check that a dry run works, use string with size and unit
251
  Finish(client, client.CreateInstance,
252
         "create", instance_name, "plain", [{"size":"1gb"}], [], dry_run=True,
253
          os="debian-image", pnode=node_one)
254

  
255
  # Another dry run, numeric size, should work, but still a dry run
256
  Finish(client, client.CreateInstance,
257
         "create", instance_name, "plain", [{"size": "1000"}], [{}],
258
         dry_run=True, os="debian-image", pnode=node_one)
259

  
260
  # Create a smaller instance, and delete it immediately
261
  Finish(client, client.CreateInstance,
262
         "create", instance_name, "plain", [{"size":800}], [{}],
263
         os="debian-image", pnode=node_one)
264

  
265
  Finish(client, client.DeleteInstance, instance_name)
266

  
267
  # Create one instance to use in further tests
268
  Finish(client, client.CreateInstance,
269
         "create", instance_name, "plain", [{"size":1200}], [{}],
270
         os="debian-image", pnode=node_one)
271

  
272
  client.GetInstance(instance_name)
273

  
274
  Finish(client, client.GetInstanceInfo, instance_name)
275

  
276
  Finish(client, client.GetInstanceInfo, instance_name, static=True)
277

  
278
  TestTags(client, client.GetInstanceTags, client.AddInstanceTags,
279
           client.DeleteInstanceTags, instance_name)
280

  
281
  Finish(client, client.GrowInstanceDisk,
282
         instance_name, 0, 100, wait_for_sync=True)
283

  
284
  Finish(client, client.RebootInstance,
285
         instance_name, "soft", ignore_secondaries=True, dry_run=True,
286
         reason="Hulk smash gently!")
287

  
288
  Finish(client, client.ShutdownInstance,
289
         instance_name, dry_run=True, no_remember=False,
290
         reason="Hulk smash hard!")
291

  
292
  Finish(client, client.StartupInstance,
293
         instance_name, dry_run=True, no_remember=False,
294
         reason="Not hard enough!")
295

  
296
  Finish(client, client.RebootInstance,
297
         instance_name, "soft", ignore_secondaries=True, dry_run=False)
298

  
299
  Finish(client, client.ShutdownInstance,
300
         instance_name, dry_run=False, no_remember=False)
301

  
302
  Finish(client, client.ModifyInstance,
303
         instance_name, disk_template="drbd", remote_node=node_two)
304

  
305
  Finish(client, client.ModifyInstance,
306
         instance_name, disk_template="plain")
307

  
308
  Finish(client, client.RenameInstance,
309
         instance_name, alternate_name, ip_check=True, name_check=True)
310

  
311
  Finish(client, client.RenameInstance, alternate_name, instance_name)
312

  
313
  Finish(client, client.DeactivateInstanceDisks, instance_name)
314

  
315
  Finish(client, client.ActivateInstanceDisks, instance_name)
316

  
317
  Finish(client, client.RecreateInstanceDisks,
318
         instance_name, [0], [node_one])
319

  
320
  Finish(client, client.StartupInstance,
321
         instance_name, dry_run=False, no_remember=False)
322

  
323
  client.GetInstanceConsole(instance_name)
324

  
325
  Finish(client, client.ReinstallInstance,
326
         instance_name, os=None, no_startup=False, osparams={})
327

  
328
  Finish(client, client.DeleteInstance, instance_name, dry_run=True)
329

  
330
  Finish(client, client.DeleteInstance, instance_name)
331

  
332

  
333
def Workload(client):
334
  """ The actual RAPI workload used for tests.
335

  
336
  @type client C{GanetiRapiClientWrapper}
337
  @param client A wrapped RAPI client.
338

  
339
  """
340

  
341
  # First just the simple information retrievals
342
  TestGetters(client)
343

  
344
  # Then the only remaining function which is parameter-free
218 345
  Finish(client, client.RedistributeConfig)
219 346

  
220 347
  TestTags(client, client.GetClusterTags, client.AddClusterTags,
......
226 353
           client.DeleteNodeTags, node.primary)
227 354
  node.Release()
228 355

  
356
  # Instance tests
357

  
358
  # First remove all instances the QA might have created
359
  RemoveAllInstances(client)
360

  
361
  nodes = qa_config.AcquireManyNodes(2)
362
  instance_one = qa_config.AcquireInstance()
363
  instance_two = qa_config.AcquireInstance()
364
  TestSingleInstance(client, instance_one.name, instance_two.name,
365
                     nodes[0].primary, nodes[1].primary)
366
  instance_two.Release()
367
  instance_one.Release()
368
  qa_config.ReleaseManyNodes(nodes)
369

  
229 370

  
230 371
def Usage():
231 372
  sys.stderr.write("Usage:\n\trapi-workload.py qa-config-file")

Also available in: Unified diff