Merge "Adding sample trex example"
[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_TENANT_NAME": "admin",
256                 "OS_USERNAME": "admin",
257                 "OS_USER_DOMAIN_NAME": "default"
258             },
259             'environment_id': environment_id
260         }
261     }
262
263
264 METHOD: GET
265
266 Get openrc file information
267 Example::
268
269     http://localhost:8888/api/v2/yardstick/openrcs/5g6g3e02-155a-4847-a5f8-154f1b31db8c
270
271
272 METHOD: DELETE
273
274
275 Delete openrc file
276 Example::
277
278     http://localhost:8888/api/v2/yardstick/openrcs/5g6g3e02-155a-4847-a5f8-154f1b31db8c
279
280
281 /api/v2/yardstick/pods/action
282
283 Description: This API provides functionality of handling Yardstick pod file (pod.yaml). For Euphrates, it supports:
284
285 1. Upload a pod file;
286 2. Get pod file information;
287 3. Delete an openrc file.
288
289 Which API to call will depend on the parameters.
290
291
292 METHOD: POST
293
294
295 Upload a pod.yaml file
296 Example::
297
298     {
299         'action': 'upload_pod_file',
300         'args': {
301             'file': file,
302             'environment_id': environment_id
303         }
304     }
305
306
307 METHOD: GET
308
309 Get pod file information
310 Example::
311
312     http://localhost:8888/api/v2/yardstick/pods/5g6g3e02-155a-4847-a5f8-154f1b31db8c
313
314
315 METHOD: DELETE
316
317 Delete openrc file
318 Example::
319
320     http://localhost:8888/api/v2/yardstick/pods/5g6g3e02-155a-4847-a5f8-154f1b31db8c
321
322
323 /api/v2/yardstick/images/action
324
325 Description: This API is used to do some work related to Yardstick VM images. For Euphrates, it supports:
326
327 1. Load Yardstick VM images;
328 2. Get image's information;
329 3. Delete images.
330
331 Which API to call will depend on the parameters.
332
333
334 METHOD: POST
335
336
337 Load VM images
338 Example::
339
340     {
341         'action': 'load_images'
342     }
343
344
345 METHOD: GET
346
347 Get image information
348 Example::
349
350     http://localhost:8888/api/v2/yardstick/images/5g6g3e02-155a-4847-a5f8-154f1b31db8c
351
352
353 METHOD: DELETE
354
355 Delete images
356 Example::
357
358     http://localhost:8888/api/v2/yardstick/images/5g6g3e02-155a-4847-a5f8-154f1b31db8c
359
360
361 /api/v2/yardstick/tasks/action
362
363 Description: This API is used to do some work related to yardstick tasks. For Euphrates, it supports:
364
365 1. Create a Yardstick task;
366 2. run a Yardstick task;
367 3. Add a test case to a task;
368 4. Add a test suite to a task;
369 5. Get a tasks' information;
370 6. Delete a task.
371
372 Which API to call will depend on the parameters.
373
374
375 METHOD: POST
376
377
378 Create a Yardstick task
379 Example::
380
381     {
382         'action': 'create_task',
383             'args': {
384                 'name': 'task1',
385                 'project_id': project_id
386             }
387     }
388
389
390 METHOD: PUT
391
392
393 Run a task
394 Example::
395
396     {
397         'action': 'run'
398     }
399
400
401 METHOD: PUT
402
403
404 Add a test case to a task
405 Example::
406
407     {
408         'action': 'add_case',
409         'args': {
410             'case_name': 'opnfv_yardstick_tc002',
411             'case_content': case_content
412         }
413     }
414
415
416 METHOD: PUT
417
418
419 Add a test suite to a task
420 Example::
421
422     {
423         'action': 'add_suite',
424         'args': {
425             'suite_name': 'opnfv_smoke',
426             'suite_content': suite_content
427         }
428     }
429
430
431 METHOD: GET
432
433 Get a task's information
434 Example::
435
436     http://localhost:8888/api/v2/yardstick/tasks/5g6g3e02-155a-4847-a5f8-154f1b31db8c
437
438
439 METHOD: DELETE
440
441 Delete a task
442 Example::
443     http://localhost:8888/api/v2/yardstick/tasks/5g6g3e02-155a-4847-a5f8-154f1b31db8c
444
445
446 /api/v2/yardstick/testcases/action
447
448 Description: This API is used to do some work related to yardstick testcases. For Euphrates, it supports:
449
450 1. Upload a test case;
451 2. Get all released test cases' information;
452 3. Get a certain released test case's information;
453 4. Delete a test case.
454
455 Which API to call will depend on the parameters.
456
457
458 METHOD: POST
459
460
461 Upload a test case
462 Example::
463
464     {
465         'action': 'upload_case',
466         'args': {
467             'file': file
468         }
469     }
470
471
472 METHOD: GET
473
474
475 Get all released test cases' information
476 Example::
477
478     http://localhost:8888/api/v2/yardstick/testcases
479
480
481 METHOD: GET
482
483
484 Get a certain released test case's information
485 Example::
486
487     http://localhost:8888/api/v2/yardstick/testcases/opnfv_yardstick_tc002
488
489
490 METHOD: DELETE
491
492
493 Delete a certain test case
494 Example::
495     http://localhost:8888/api/v2/yardstick/testcases/opnfv_yardstick_tc002
496
497
498 /api/v2/yardstick/testsuites/action
499
500 Description: This API is used to do some work related to yardstick test suites. For Euphrates, it supports:
501
502 1. Create a test suite;
503 2. Get a certain test suite's information;
504 3. Get all test suites;
505 4. Delete a test case.
506
507 Which API to call will depend on the parameters.
508
509
510 METHOD: POST
511
512
513 Create a test suite
514 Example::
515
516     {
517         'action': 'create_sutie',
518         'args': {
519             'name': <suite_name>,
520             'testcases': [
521                 'opnfv_yardstick_tc002'
522             ]
523         }
524     }
525
526
527 METHOD: GET
528
529
530 Get a certain test suite's information
531 Example::
532
533     http://localhost:8888/api/v2/yardstick/testsuites/<suite_name>
534
535
536 METHOD: GET
537
538
539 Get all test suite
540 Example::
541
542     http://localhost:8888/api/v2/yardstick/testsuites
543
544
545 METHOD: DELETE
546
547
548 Delete a certain test suite
549 Example::
550
551     http://localhost:8888/api/v2/yardstick/testsuites/<suite_name>
552
553
554 /api/v2/yardstick/projects/action
555
556 Description: This API is used to do some work related to yardstick test projects. For Euphrates, it supports:
557
558 1. Create a Yardstick project;
559 2. Get a certain project's information;
560 3. Get all projects;
561 4. Delete a project.
562
563 Which API to call will depend on the parameters.
564
565
566 METHOD: POST
567
568
569 Create a Yardstick project
570 Example::
571
572     {
573         'action': 'create_project',
574         'args': {
575             'name': 'project1'
576         }
577     }
578
579
580 METHOD: GET
581
582
583 Get a certain project's information
584 Example::
585
586     http://localhost:8888/api/v2/yardstick/projects/<project_id>
587
588
589 METHOD: GET
590
591
592 Get all projects' information
593 Example::
594
595     http://localhost:8888/api/v2/yardstick/projects
596
597
598 METHOD: DELETE
599
600
601 Delete a certain project
602 Example::
603
604     http://localhost:8888/api/v2/yardstick/projects/<project_id>
605
606
607 /api/v2/yardstick/containers/action
608
609 Description: This API is used to do some work related to Docker containers. For Euphrates, it supports:
610
611 1. Create a Grafana Docker container;
612 2. Create an InfluxDB Docker container;
613 3. Get a certain container's information;
614 4. Delete a container.
615
616 Which API to call will depend on the parameters.
617
618
619 METHOD: POST
620
621
622 Create a Grafana Docker container
623 Example::
624
625     {
626         'action': 'create_grafana',
627         'args': {
628             'environment_id': <environment_id>
629         }
630     }
631
632
633 METHOD: POST
634
635
636 Create an InfluxDB Docker container
637 Example::
638
639     {
640         'action': 'create_influxdb',
641         'args': {
642             'environment_id': <environment_id>
643         }
644     }
645
646
647 METHOD: GET
648
649
650 Get a certain container's information
651 Example::
652
653     http://localhost:8888/api/v2/yardstick/containers/<container_id>
654
655
656 METHOD: DELETE
657
658
659 Delete a certain container
660 Example::
661
662     http://localhost:8888/api/v2/yardstick/containers/<container_id>