aboutsummaryrefslogtreecommitdiffstats
path: root/docs/testing/user/userguide/09-api.rst
blob: f227878ae85e557e31274f0df3fd3210014b2f0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
.. This work is licensed under a Creative Commons Attribution 4.0 International
.. License.
.. http://creativecommons.org/licenses/by/4.0
.. (c) OPNFV, Huawei Technologies Co.,Ltd and others.
.. Convention for heading levels in Yardstick documentation:

   =======  Heading 0 (reserved for the title in a document)
   -------  Heading 1
   ^^^^^^^  Heading 2
   +++++++  Heading 3
   '''''''  Heading 4

   Avoid deeper levels because they do not render well.

=====================
Yardstick Restful API
=====================


Abstract
--------

Yardstick support restful API since Danube.


Available API
-------------

/yardstick/env/action
^^^^^^^^^^^^^^^^^^^^^

Description: This API is used to prepare Yardstick test environment.
For Euphrates, it supports:

1. Prepare yardstick test environment, including setting the
   ``EXTERNAL_NETWORK`` environment variable, load Yardstick VM images and
   create flavors;
2. Start an InfluxDB Docker container and config Yardstick output to InfluxDB;
3. Start a Grafana Docker container and config it with the InfluxDB.

Which API to call will depend on the parameters.


Method: POST


Prepare Yardstick test environment
Example::

    {
        'action': 'prepare_env'
    }

This is an asynchronous API. You need to call ``/yardstick/asynctask`` API to
get the task result.


Start and config an InfluxDB docker container
Example::

    {
        'action': 'create_influxdb'
    }

This is an asynchronous API. You need to call ``/yardstick/asynctask`` API to
get the task result.


Start and config a Grafana docker container
Example::

    {
        'action': 'create_grafana'
    }

This is an asynchronous API. You need to call ``/yardstick/asynctask`` API to
get the task result.


/yardstick/asynctask
^^^^^^^^^^^^^^^^^^^^

Description: This API is used to get the status of asynchronous tasks


Method: GET


Get the status of asynchronous tasks
Example::

    http://<SERVER IP>:<PORT>/yardstick/asynctask?task_id=3f3f5e03-972a-4847-a5f8-154f1b31db8c

The returned status will be 0(running), 1(finished) and 2(failed).

NOTE::

    <SERVER IP>: The ip of the host where you start your yardstick container
    <PORT>: The outside port of port mapping which set when you start start yardstick container


/yardstick/testcases
^^^^^^^^^^^^^^^^^^^^

Description: This API is used to list all released Yardstick test cases.


Method: GET


Get a list of released test cases
Example::

    http://<SERVER IP>:<PORT>/yardstick/testcases


/yardstick/testcases/release/action
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API is used to run a Yardstick released test case.


Method: POST


Run a released test case
Example::

    {
        'action': 'run_test_case',
        'args': {
            'opts': {},
            'testcase': 'opnfv_yardstick_tc002'
        }
    }

This is an asynchronous API. You need to call ``/yardstick/results`` to get the
result.


/yardstick/testcases/samples/action
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API is used to run a Yardstick sample test case.


Method: POST


Run a sample test case
Example::

    {
        'action': 'run_test_case',
        'args': {
            'opts': {},
            'testcase': 'ping'
        }
    }

This is an asynchronous API. You need to call ``/yardstick/results`` to get
the result.


/yardstick/testcases/<testcase_name>/docs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API is used to the documentation of a certain released test
case.


Method: GET


Get the documentation of a certain test case
Example::

    http://<SERVER IP>:<PORT>/yardstick/taskcases/opnfv_yardstick_tc002/docs


/yardstick/testsuites/action
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API is used to run a Yardstick test suite.


Method: POST


Run a test suite
Example::

    {
        'action': 'run_test_suite',
        'args': {
            'opts': {},
            'testsuite': 'opnfv_smoke'
        }
    }

This is an asynchronous API. You need to call /yardstick/results to get the
result.


/yardstick/tasks/<task_id>/log
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API is used to get the real time log of test case execution.


Method: GET


Get real time of test case execution
Example::

    http://<SERVER IP>:<PORT>/yardstick/tasks/14795be8-f144-4f54-81ce-43f4e3eab33f/log?index=0


/yardstick/results
^^^^^^^^^^^^^^^^^^

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.


Method: GET


Get test results of one task
Example::

    http://<SERVER IP>:<PORT>/yardstick/results?task_id=3f3f5e03-972a-4847-a5f8-154f1b31db8c

This API will return a list of test case result


/api/v2/yardstick/openrcs
^^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API provides functionality of handling OpenStack credential
file (openrc). For Euphrates, it supports:

1. Upload an openrc file for an OpenStack environment;
2. Update an openrc;
3. Get openrc file information;
4. Delete an openrc file.

Which API to call will depend on the parameters.


METHOD: POST


Upload an openrc file for an OpenStack environment
Example::

    {
        'action': 'upload_openrc',
        'args': {
            'file': file,
            'environment_id': environment_id
        }
    }


METHOD: POST


Update an openrc file
Example::

    {
        'action': 'update_openrc',
        'args': {
            'openrc': {
                "EXTERNAL_NETWORK": "ext-net",
                "OS_AUTH_URL": "http://192.168.23.51:5000/v3",
                "OS_IDENTITY_API_VERSION": "3",
                "OS_IMAGE_API_VERSION": "2",
                "OS_PASSWORD": "console",
                "OS_PROJECT_DOMAIN_NAME": "default",
                "OS_PROJECT_NAME": "admin",
                "OS_USERNAME": "admin",
                "OS_USER_DOMAIN_NAME": "default"
            },
            'environment_id': environment_id
        }
    }


/api/v2/yardstick/openrcs/<openrc_id>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API provides functionality of handling OpenStack credential file (openrc). For Euphrates, it supports:

1. Get openrc file information;
2. Delete an openrc file.


METHOD: GET

Get openrc file information
Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/openrcs/5g6g3e02-155a-4847-a5f8-154f1b31db8c


METHOD: DELETE


Delete openrc file
Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/openrcs/5g6g3e02-155a-4847-a5f8-154f1b31db8c


/api/v2/yardstick/pods
^^^^^^^^^^^^^^^^^^^^^^

Description: This API provides functionality of handling Yardstick pod file
(pod.yaml). For Euphrates, it supports:

1. Upload a pod file;

Which API to call will depend on the parameters.


METHOD: POST


Upload a pod.yaml file
Example::

    {
        'action': 'upload_pod_file',
        'args': {
            'file': file,
            'environment_id': environment_id
        }
    }


/api/v2/yardstick/pods/<pod_id>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API provides functionality of handling Yardstick pod file (pod.yaml). For Euphrates, it supports:

1. Get pod file information;
2. Delete an openrc file.

METHOD: GET

Get pod file information
Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/pods/5g6g3e02-155a-4847-a5f8-154f1b31db8c


METHOD: DELETE

Delete openrc file
Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/pods/5g6g3e02-155a-4847-a5f8-154f1b31db8c


/api/v2/yardstick/images
^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API is used to do some work related to Yardstick VM images.
For Euphrates, it supports:

1. Load Yardstick VM images;

Which API to call will depend on the parameters.


METHOD: POST


Load VM images
Example::

    {
        'action': 'load_image',
        'args': {
            'name': 'yardstick-image'
        }
    }


/api/v2/yardstick/images/<image_id>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API is used to do some work related to Yardstick VM images. For Euphrates, it supports:

1. Get image's information;
2. Delete images

METHOD: GET

Get image information
Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/images/5g6g3e02-155a-4847-a5f8-154f1b31db8c


METHOD: DELETE

Delete images
Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/images/5g6g3e02-155a-4847-a5f8-154f1b31db8c


/api/v2/yardstick/tasks
^^^^^^^^^^^^^^^^^^^^^^^

Description: This API is used to do some work related to yardstick tasks. For
Euphrates, it supports:

1. Create a Yardstick task;

Which API to call will depend on the parameters.


METHOD: POST


Create a Yardstick task
Example::

    {
        'action': 'create_task',
            'args': {
                'name': 'task1',
                'project_id': project_id
            }
    }


/api/v2/yardstick/tasks/<task_id>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API is used to do some work related to yardstick tasks. For Euphrates, it supports:

1. Add a environment to a task
2. Add a test case to a task;
3. Add a test suite to a task;
4. run a Yardstick task;
5. Get a tasks' information;
6. Delete a task.


METHOD: PUT

Add a environment to a task

Example::

    {
        'action': 'add_environment',
        'args': {
            'environment_id': 'e3cadbbb-0419-4fed-96f1-a232daa0422a'
        }
    }


METHOD: PUT

Add a test case to a task
Example::

    {
        'action': 'add_case',
        'args': {
            'case_name': 'opnfv_yardstick_tc002',
            'case_content': case_content
        }
    }



METHOD: PUT

Add a test suite to a task
Example::

    {
        'action': 'add_suite',
        'args': {
            'suite_name': 'opnfv_smoke',
            'suite_content': suite_content
        }
    }


METHOD: PUT

Run a task

Example::

    {
        'action': 'run'
    }



METHOD: GET

Get a task's information
Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/tasks/5g6g3e02-155a-4847-a5f8-154f1b31db8c


METHOD: DELETE

Delete a task

Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/tasks/5g6g3e02-155a-4847-a5f8-154f1b31db8c


/api/v2/yardstick/testcases
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API is used to do some work related to Yardstick testcases.
For Euphrates, it supports:

1. Upload a test case;
2. Get all released test cases' information;

Which API to call will depend on the parameters.


METHOD: POST


Upload a test case
Example::

    {
        'action': 'upload_case',
        'args': {
            'file': file
        }
    }


METHOD: GET


Get all released test cases' information
Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/testcases


/api/v2/yardstick/testcases/<case_name>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API is used to do some work related to yardstick testcases. For Euphrates, it supports:

1. Get certain released test case's information;
2. Delete a test case.

METHOD: GET


Get certain released test case's information
Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/testcases/opnfv_yardstick_tc002


METHOD: DELETE


Delete a certain test case
Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/testcases/opnfv_yardstick_tc002


/api/v2/yardstick/testsuites
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API is used to do some work related to yardstick test suites.
For Euphrates, it supports:

1. Create a test suite;
2. Get all test suites;

Which API to call will depend on the parameters.


METHOD: POST


Create a test suite
Example::

    {
        'action': 'create_suite',
        'args': {
            'name': <suite_name>,
            'testcases': [
                'opnfv_yardstick_tc002'
            ]
        }
    }


METHOD: GET


Get all test suite
Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/testsuites


/api/v2/yardstick/testsuites
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API is used to do some work related to yardstick test suites. For Euphrates, it supports:

1. Get certain test suite's information;
2. Delete a test case.

METHOD: GET


Get certain test suite's information
Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/testsuites/<suite_name>


METHOD: DELETE


Delete a certain test suite
Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/testsuites/<suite_name>


/api/v2/yardstick/projects
^^^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API is used to do some work related to Yardstick test
projects. For Euphrates, it supports:

1. Create a Yardstick project;
2. Get all projects;

Which API to call will depend on the parameters.


METHOD: POST


Create a Yardstick project
Example::

    {
        'action': 'create_project',
        'args': {
            'name': 'project1'
        }
    }


METHOD: GET


Get all projects' information
Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/projects


/api/v2/yardstick/projects
^^^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API is used to do some work related to yardstick test projects. For Euphrates, it supports:

1. Get certain project's information;
2. Delete a project.

METHOD: GET


Get certain project's information
Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/projects/<project_id>


METHOD: DELETE


Delete a certain project
Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/projects/<project_id>


/api/v2/yardstick/containers
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API is used to do some work related to Docker containers.
For Euphrates, it supports:

1. Create a Grafana Docker container;
2. Create an InfluxDB Docker container;

Which API to call will depend on the parameters.


METHOD: POST


Create a Grafana Docker container
Example::

    {
        'action': 'create_grafana',
        'args': {
            'environment_id': <environment_id>
        }
    }


METHOD: POST


Create an InfluxDB Docker container
Example::

    {
        'action': 'create_influxdb',
        'args': {
            'environment_id': <environment_id>
        }
    }


/api/v2/yardstick/containers/<container_id>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Description: This API is used to do some work related to Docker containers. For Euphrates, it supports:

1. Get certain container's information;
2. Delete a container.

METHOD: GET


Get certain container's information
Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/containers/<container_id>


METHOD: DELETE


Delete a certain container
Example::

    http://<SERVER IP>:<PORT>/api/v2/yardstick/containers/<container_id>