Revision 9749bd5e qa/rapi-workload.py
b/qa/rapi-workload.py | ||
---|---|---|
215 | 215 |
client.GetGroups(bulk=True) |
216 | 216 |
|
217 | 217 |
|
218 |
def TestQueries(client, resource_name): |
|
219 |
""" Finds out which fields are present for a given resource type, and attempts |
|
220 |
to retrieve their values for all present resources. |
|
221 |
|
|
222 |
@type client C{GanetiRapiClientWrapper} |
|
223 |
@param client A wrapped RAPI client. |
|
224 |
@type resource_name string |
|
225 |
@param resource_name The name of the resource to use. |
|
226 |
|
|
227 |
""" |
|
228 |
|
|
229 |
FIELDS_KEY = "fields" |
|
230 |
|
|
231 |
query_res = client.QueryFields(resource_name) |
|
232 |
|
|
233 |
if query_res is None or FIELDS_KEY not in query_res or \ |
|
234 |
len(query_res[FIELDS_KEY]) == 0: |
|
235 |
return |
|
236 |
|
|
237 |
field_entries = query_res[FIELDS_KEY] |
|
238 |
|
|
239 |
fields = map(lambda e: e["name"], field_entries) |
|
240 |
|
|
241 |
client.Query(resource_name, fields) |
|
242 |
|
|
243 |
|
|
218 | 244 |
def RemoveAllInstances(client): |
219 | 245 |
""" Queries for a list of instances, then removes them all. |
220 | 246 |
|
... | ... | |
276 | 302 |
|
277 | 303 |
Finish(client, client.GetInstanceInfo, instance_name, static=True) |
278 | 304 |
|
305 |
TestQueries(client, "instance") |
|
306 |
|
|
279 | 307 |
TestTags(client, client.GetInstanceTags, client.AddInstanceTags, |
280 | 308 |
client.DeleteInstanceTags, instance_name) |
281 | 309 |
|
... | ... | |
408 | 436 |
MarkUnmarkNode(client, non_master_node, "powered") |
409 | 437 |
MarkUnmarkNode(client, non_master_node, "offline") |
410 | 438 |
|
439 |
TestQueries(client, "node") |
|
440 |
|
|
411 | 441 |
|
412 | 442 |
def TestGroupOperations(client, node, another_node): |
413 | 443 |
""" Tests various operations related to groups only. |
... | ... | |
434 | 464 |
|
435 | 465 |
client.GetGroup(TEST_GROUP_NAME) |
436 | 466 |
|
467 |
TestQueries(client, "group") |
|
468 |
|
|
437 | 469 |
TestTags(client, client.GetGroupTags, client.AddGroupTags, |
438 | 470 |
client.DeleteGroupTags, TEST_GROUP_NAME) |
439 | 471 |
|
... | ... | |
498 | 530 |
instance_one.Release() |
499 | 531 |
qa_config.ReleaseManyNodes(nodes) |
500 | 532 |
|
533 |
# Test all the queries which involve resources that do not have functions |
|
534 |
# of their own |
|
535 |
TestQueries(client, "lock") |
|
536 |
TestQueries(client, "job") |
|
537 |
TestQueries(client, "export") |
|
538 |
|
|
501 | 539 |
node = qa_config.AcquireNode(exclude=qa_config.GetMasterNode()) |
502 | 540 |
TestNodeOperations(client, node.primary) |
503 | 541 |
node.Release() |
Also available in: Unified diff