Merge "Fix numbering and html (generated) alignment"
[yardstick.git] / docs / testing / user / userguide / 08-api.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International
2 .. License.
3 .. http://creativecommons.org/licenses/by/4.0
4 .. (c) OPNFV, Huawei Technologies Co.,Ltd and others.
5
6 Yardstick Restful API
7 ======================
8
9
10 Abstract
11 --------
12
13 Yardstick support restful API since Danube.
14
15
16 Available API
17 -------------
18
19 /yardstick/env/action
20 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21
22 Description: This API is used to prepare Yardstick test environment. For Euphrates, it supports:
23
24 1. Prepare yardstick test environment, including set external network environment variable, load Yardstick VM images and create flavors;
25 2. Start an InfluxDB Docker container and config Yardstick output to InfluxDB;
26 3. Start a Grafana Docker container and config it with the InfluxDB.
27
28 Which API to call will depend on the parameters.
29
30
31 Method: POST
32
33
34 Prepare Yardstick test environment
35 Example::
36
37     {
38         'action': 'prepareYardstickEnv'
39     }
40
41 This is an asynchronous API. You need to call /yardstick/asynctask API to get the task result.
42
43
44 Start and config an InfluxDB docker container
45 Example::
46
47     {
48         'action': 'createInfluxDBContainer'
49     }
50
51 This is an asynchronous API. You need to call /yardstick/asynctask API to get the task result.
52
53
54 Start and config a Grafana docker container
55 Example::
56
57     {
58         'action': 'createGrafanaContainer'
59     }
60
61 This is an asynchronous API. You need to call /yardstick/asynctask API to get the task result.
62
63
64 /yardstick/asynctask
65 ^^^^^^^^^^^^^^^^^^^^
66
67 Description: This API is used to get the status of asynchronous tasks
68
69
70 Method: GET
71
72
73 Get the status of asynchronous tasks
74 Example::
75
76     http://localhost:8888/yardstick/asynctask?task_id=3f3f5e03-972a-4847-a5f8-154f1b31db8c
77
78 The returned status will be 0(running), 1(finished) and 2(failed).
79
80
81 /yardstick/testcases
82 ^^^^^^^^^^^^^^^^^^^^
83
84 Description: This API is used to list all released Yardstick test cases.
85
86
87 Method: GET
88
89
90 Get a list of released test cases
91 Example::
92
93     http://localhost:8888/yardstick/testcases
94
95
96 /yardstick/testcases/release/action
97 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
98
99 Description: This API is used to run a Yardstick released test case.
100
101
102 Method: POST
103
104
105 Run a released test case
106 Example::
107
108     {
109         'action': 'runTestCase',
110         'args': {
111             'opts': {},
112             'testcase': 'tc002'
113         }
114     }
115
116 This is an asynchronous API. You need to call /yardstick/results to get the result.
117
118
119 /yardstick/testcases/samples/action
120 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
121
122 Description: This API is used to run a Yardstick sample test case.
123
124
125 Method: POST
126
127
128 Run a sample test case
129 Example::
130
131     {
132         'action': 'runTestCase',
133         'args': {
134             'opts': {},
135             'testcase': 'ping'
136         }
137     }
138
139 This is an asynchronous API. You need to call /yardstick/results to get the result.
140
141
142 /yardstick/testcases/<testcase_name>/docs
143 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
144
145 Description: This API is used to the documentation of a certain released test case.
146
147
148 Method: GET
149
150
151 Get the documentation of a certain test case
152 Example::
153
154     http://localhost:8888/yardstick/taskcases/opnfv_yardstick_tc002/docs
155
156
157 /yardstick/testsuites/action
158 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
159
160 Description: This API is used to run a Yardstick test suite.
161
162
163 Method: POST
164
165
166 Run a test suite
167 Example::
168
169     {
170         'action': 'runTestSuite',
171         'args': {
172             'opts': {},
173             'testcase': 'smoke'
174         }
175     }
176
177 This is an asynchronous API. You need to call /yardstick/results to get the result.
178
179
180 /yardstick/tasks/<task_id>/log
181
182 Description: This API is used to get the real time log of test case execution.
183
184
185 Method: GET
186
187
188 Get real time of test case execution
189 Example::
190
191     http://localhost:8888/yardstick/tasks/14795be8-f144-4f54-81ce-43f4e3eab33f/log?index=0
192
193
194 /yardstick/results
195 ^^^^^^^^^^^^^^^^^^
196
197 Description: This API is used to get the test results of tasks. If you call /yardstick/testcases/samples/action API, it will return a task id. You can use the returned task id to get the results by using this API.
198
199
200 Method: GET
201
202
203 Get test results of one task
204 Example::
205
206     http://localhost:8888/yardstick/results?task_id=3f3f5e03-972a-4847-a5f8-154f1b31db8c
207
208 This API will return a list of test case result
209
210
211 /api/v2/yardstick/openrcs/action
212
213 Description: This API provides functionality of handling OpenStack credential file (openrc). For Euphrates, it supports:
214
215 1. Upload an openrc file for an OpenStack environment;
216 2. Update an openrc file;
217 3. Get openrc file information;
218 4. Delete an openrc file.
219
220 Which API to call will depend on the parameters.
221
222
223 METHOD: POST
224
225
226 Upload an openrc file for an OpenStack environment
227 Example::
228
229     {
230         'action': 'upload_openrc',
231         'args': {
232             'file': file,
233             'environment_id': environment_id
234         }
235     }
236
237
238 METHOD: POST
239
240
241 Update an openrc file
242 Example::
243
244     {
245         'action': 'update_openrc',
246         'args': {
247             'openrc': {
248                 "EXTERNAL_NETWORK": "ext-net",
249                 "OS_AUTH_URL": "http://192.168.23.51:5000/v3",
250                 "OS_IDENTITY_API_VERSION": "3",
251                 "OS_IMAGE_API_VERSION": "2",
252                 "OS_PASSWORD": "console",
253                 "OS_PROJECT_DOMAIN_NAME": "default",
254                 "OS_PROJECT_NAME": "admin",
255                 "OS_USERNAME": "admin",
256                 "OS_USER_DOMAIN_NAME": "default"
257             },
258             'environment_id': environment_id
259         }
260     }
261
262
263 METHOD: GET
264
265 Get openrc file information
266 Example::
267
268     http://localhost:8888/api/v2/yardstick/openrcs/5g6g3e02-155a-4847-a5f8-154f1b31db8c
269
270
271 METHOD: DELETE
272
273
274 Delete openrc file
275 Example::
276
277     http://localhost:8888/api/v2/yardstick/openrcs/5g6g3e02-155a-4847-a5f8-154f1b31db8c
278
279
280 /api/v2/yardstick/pods/action
281
282 Description: This API provides functionality of handling Yardstick pod file (pod.yaml). For Euphrates, it supports:
283
284 1. Upload a pod file;
285 2. Get pod file information;
286 3. Delete an openrc file.
287
288 Which API to call will depend on the parameters.
289
290
291 METHOD: POST
292
293
294 Upload a pod.yaml file
295 Example::
296
297     {
298         'action': 'upload_pod_file',
299         'args': {
300             'file': file,
301             'environment_id': environment_id
302         }
303     }
304
305
306 METHOD: GET
307
308 Get pod file information
309 Example::
310
311     http://localhost:8888/api/v2/yardstick/pods/5g6g3e02-155a-4847-a5f8-154f1b31db8c
312
313
314 METHOD: DELETE
315
316 Delete openrc file
317 Example::
318
319     http://localhost:8888/api/v2/yardstick/pods/5g6g3e02-155a-4847-a5f8-154f1b31db8c
320
321
322 /api/v2/yardstick/images/action
323
324 Description: This API is used to do some work related to Yardstick VM images. For Euphrates, it supports:
325
326 1. Load Yardstick VM images;
327 2. Get image's information;
328 3. Delete images.
329
330 Which API to call will depend on the parameters.
331
332
333 METHOD: POST
334
335
336 Load VM images
337 Example::
338
339     {
340         'action': 'load_images'
341     }
342
343
344 METHOD: GET
345
346 Get image information
347 Example::
348
349     http://localhost:8888/api/v2/yardstick/images/5g6g3e02-155a-4847-a5f8-154f1b31db8c
350
351
352 METHOD: DELETE
353
354 Delete images
355 Example::
356
357     http://localhost:8888/api/v2/yardstick/images/5g6g3e02-155a-4847-a5f8-154f1b31db8c
358
359
360 /api/v2/yardstick/tasks/action
361
362 Description: This API is used to do some work related to yardstick tasks. For Euphrates, it supports:
363
364 1. Create a Yardstick task;
365 2. run a Yardstick task;
366 3. Add a test case to a task;
367 4. Add a test suite to a task;
368 5. Get a tasks' information;
369 6. Delete a task.
370
371 Which API to call will depend on the parameters.
372
373
374 METHOD: POST
375
376
377 Create a Yardstick task
378 Example::
379
380     {
381         'action': 'create_task',
382             'args': {
383                 'name': 'task1',
384                 'project_id': project_id
385             }
386     }
387
388
389 METHOD: PUT
390
391
392 Run a task
393 Example::
394
395     {
396         'action': 'run'
397     }
398
399
400 METHOD: PUT
401
402
403 Add a test case to a task
404 Example::
405
406     {
407         'action': 'add_case',
408         'args': {
409             'case_name': 'opnfv_yardstick_tc002',
410             'case_content': case_content
411         }
412     }
413
414
415 METHOD: PUT
416
417
418 Add a test suite to a task
419 Example::
420
421     {
422         'action': 'add_suite',
423         'args': {
424             'suite_name': 'opnfv_smoke',
425             'suite_content': suite_content
426         }
427     }
428
429
430 METHOD: GET
431
432 Get a task's information
433 Example::
434
435     http://localhost:8888/api/v2/yardstick/tasks/5g6g3e02-155a-4847-a5f8-154f1b31db8c
436
437
438 METHOD: DELETE
439
440 Delete a task
441 Example::
442     http://localhost:8888/api/v2/yardstick/tasks/5g6g3e02-155a-4847-a5f8-154f1b31db8c
443
444
445 /api/v2/yardstick/testcases/action
446
447 Description: This API is used to do some work related to yardstick testcases. For Euphrates, it supports:
448
449 1. Upload a test case;
450 2. Get all released test cases' information;
451 3. Get a certain released test case's information;
452 4. Delete a test case.
453
454 Which API to call will depend on the parameters.
455
456
457 METHOD: POST
458
459
460 Upload a test case
461 Example::
462
463     {
464         'action': 'upload_case',
465         'args': {
466             'file': file
467         }
468     }
469
470
471 METHOD: GET
472
473
474 Get all released test cases' information
475 Example::
476
477     http://localhost:8888/api/v2/yardstick/testcases
478
479
480 METHOD: GET
481
482
483 Get a certain released test case's information
484 Example::
485
486     http://localhost:8888/api/v2/yardstick/testcases/opnfv_yardstick_tc002
487
488
489 METHOD: DELETE
490
491
492 Delete a certain test case
493 Example::
494     http://localhost:8888/api/v2/yardstick/testcases/opnfv_yardstick_tc002
495
496
497 /api/v2/yardstick/testsuites/action
498
499 Description: This API is used to do some work related to yardstick test suites. For Euphrates, it supports:
500
501 1. Create a test suite;
502 2. Get a certain test suite's information;
503 3. Get all test suites;
504 4. Delete a test case.
505
506 Which API to call will depend on the parameters.
507
508
509 METHOD: POST
510
511
512 Create a test suite
513 Example::
514
515     {
516         'action': 'create_sutie',
517         'args': {
518             'name': <suite_name>,
519             'testcases': [
520                 'opnfv_yardstick_tc002'
521             ]
522         }
523     }
524
525
526 METHOD: GET
527
528
529 Get a certain test suite's information
530 Example::
531
532     http://localhost:8888/api/v2/yardstick/testsuites/<suite_name>
533
534
535 METHOD: GET
536
537
538 Get all test suite
539 Example::
540
541     http://localhost:8888/api/v2/yardstick/testsuites
542
543
544 METHOD: DELETE
545
546
547 Delete a certain test suite
548 Example::
549
550     http://localhost:8888/api/v2/yardstick/testsuites/<suite_name>
551
552
553 /api/v2/yardstick/projects/action
554
555 Description: This API is used to do some work related to yardstick test projects. For Euphrates, it supports:
556
557 1. Create a Yardstick project;
558 2. Get a certain project's information;
559 3. Get all projects;
560 4. Delete a project.
561
562 Which API to call will depend on the parameters.
563
564
565 METHOD: POST
566
567
568 Create a Yardstick project
569 Example::
570
571     {
572         'action': 'create_project',
573         'args': {
574             'name': 'project1'
575         }
576     }
577
578
579 METHOD: GET
580
581
582 Get a certain project's information
583 Example::
584
585     http://localhost:8888/api/v2/yardstick/projects/<project_id>
586
587
588 METHOD: GET
589
590
591 Get all projects' information
592 Example::
593
594     http://localhost:8888/api/v2/yardstick/projects
595
596
597 METHOD: DELETE
598
599
600 Delete a certain project
601 Example::
602
603     http://localhost:8888/api/v2/yardstick/projects/<project_id>
604
605
606 /api/v2/yardstick/containers/action
607
608 Description: This API is used to do some work related to Docker containers. For Euphrates, it supports:
609
610 1. Create a Grafana Docker container;
611 2. Create an InfluxDB Docker container;
612 3. Get a certain container's information;
613 4. Delete a container.
614
615 Which API to call will depend on the parameters.
616
617
618 METHOD: POST
619
620
621 Create a Grafana Docker container
622 Example::
623
624     {
625         'action': 'create_grafana',
626         'args': {
627             'environment_id': <environment_id>
628         }
629     }
630
631
632 METHOD: POST
633
634
635 Create an InfluxDB Docker container
636 Example::
637
638     {
639         'action': 'create_influxdb',
640         'args': {
641             'environment_id': <environment_id>
642         }
643     }
644
645
646 METHOD: GET
647
648
649 Get a certain container's information
650 Example::
651
652     http://localhost:8888/api/v2/yardstick/containers/<container_id>
653
654
655 METHOD: DELETE
656
657
658 Delete a certain container
659 Example::
660
661     http://localhost:8888/api/v2/yardstick/containers/<container_id>