55c3aa121d5a91c81983e96f478a3ac1728ef59c
[functest.git] / functest.rst
1 ===========================
2 OPNFV functional test guide
3 ===========================
4
5 Testing is a key challenge of OPNFV.
6 It shall be possible to run functional tests on any OPNFV solution.
7
8 The goal of this document consists in
9  * a description of functional tests for OPNFV
10  * a description of the tools needed to perform these tests
11  * the procedure to configure the tools and the scenarios associated with these tests
12
13 Functional tests shall be automated (as much as possible) and collected results shall be used to improve the robustness and the reliability of the overall system.
14
15 Function tests may cover any domain that could lead to improve the OPNFV solution and define "Telco Cloud" KPI.
16
17 The last section also describes how to automate these tests within the OPNFV continuous integration project.
18
19 .. _ETSI: http://docbox.etsi.org/ISG/NFV/Open/Published/gs_NFV001v010101p%20-%20Use%20Cases.pdf
20
21 ETSI NFV defined 9 use cases (ref ETSI_):
22  * VNF as a Service
23  * NFV as a service
24  * VNF Forwarding graphs
25  * Virtual Network Platform as a Service
26  * Virtualisation of Mobile Core and IMS
27  * Virtualisation of Mobile station
28  * Fixed Access NFV
29  * Virtualization of CDNs (vCDN)
30  * Virtualization of the Home environment
31
32 .. _`Openstack Telco Working Group`: https://wiki.openstack.org/wiki/TelcoWorkingGroup
33
34 Most of the use cases are also discussed in upstream projects (e.g. `Openstack Telco Working Group`_ )
35
36 For release 1 (Arno), 4 test suites have been selected:
37  * Rally Bench test suite for Openstack
38  * Openstack Tempest test suite
39  * OpenDaylight test suite
40  * vPing
41
42 The 3 first suites are directly inherited from upstream projects.
43 vPing, that is already present in Tempest suite, has been developped to provided a basic "hello world" functional test example.
44
45 .. _`Continuous Integration`: https://build.opnfv.org/ci/view/functest/
46
47 vIMS, vEPC, vPE, vHGW, vCDN use cases are not considered for first release.
48 It does not mean that such use cases cannot be tested on OPNFV Arno.
49 It means that these testcases have not been integrated in the `Continuous Integration`_ and no specific work (integration or developpment) have been done for R1.
50 We may expect that new VNFs and new scenarios will be created and integrated in the future releases.
51
52 .. _prereqs:
53
54 -------------
55 Prerequisites
56 -------------
57 We assume that an OPNFV Arno solution has been installed.
58
59 .. _here: https://wiki.opnfv.org/documentation/Arno
60
61 The installation of the OPNFV solution is out of scope of this document but can be found [here_].
62 In the rest of the document the OPNFV solution would be considered as the System Under Test (SUT).
63
64 The installation and configuration of the tools needed to perform the tests will be described in the following sections.
65
66 For release 1, the tools are not fully automatically installed, more details will be provided in the configuration section.
67
68 .. _pharos: https://wiki.opnfv.org/pharos
69
70 It is recommended to install the different tools on the jump host server as defined in the pharos_ project.
71 The high level architecture can be described as follow::
72
73  CIMC/Lights+out management                  Admin     Private   Public   Storage
74                                               PXE
75                                                                    +
76  +                                             +     IP_PRIV/24    |        |
77  |                                             |         +         +        |
78  |                                             |         |    IP_PUB/24     |
79  |     +-----------------+                     |         |         +        |
80  |     |                 |                     |         |         |        |
81  +-----+  Jumpserver     |                     |         |         |        |
82  |     |                 +---------------------+         |         |        |
83  |     |                 |                     |         |         |        |
84  |     |  +----------+   |                     |         |         |        |
85  |     |  |  Rally   |   +---- --------------------------+         |        |
86  |     |  |          |   |                     |         |         |        |
87  |     |  |  Robot   |   |                     |         |         |        |
88  |     |  |          |   |                     |         |         |        |
89  |     |  |  vPing   |   |                     |         |         |        |
90  |     |  |          |   |                     |         |         |        |
91  |     |  | Tempest  |   |                     |         |         |        |
92  |     |  +----------+   |                     |         |         |        |
93  |     |   FuncTests     +-----------------------------------------+        |
94  |     |                 |                     |         |         |        |
95  |     |                 +--------------------------------------------------+
96  |     |                 |                     |         |         |        |
97  |     +-----------------+                     |         |         |        |
98  |                                             |         |         |        |
99  |    +----------------+                       |         |         |        |
100  |    |             1  |                       |         |         |        |
101  +----+ +--------------+-+                     |         |         |        |
102  |    | |             2  |                     |         |         |        |
103  |    | | +--------------+-+                   |         |         |        |
104  |    | | |             3  |                   |         |         |        |
105  |    | | | +--------------+-+                 |         |         |        |
106  |    | | | |             4  |                 |         |         |        |
107  |    +-+ | | +--------------+-+               |         |         |        |
108  |      | | | |             5  +---------------+         |         |        |
109  |      +-+ | |  nodes for     |               |         |         |        |
110  |        | | |  deploying     +-------------------------+         |        |
111  |        +-+ |  opnfv         |               |         |         |        |
112  |          | |     SUT        +-----------------------------------+        |
113  |          +-+                |               |         |         |        |
114  |            |                +--------------------------------------------+
115  |            +----------------+               |         |         |        |
116  |                                             |         |         |        |
117  |                                             +         +         +        +
118
119 .. _description:
120
121 -----------------------------
122 Description of the test cases
123 -----------------------------
124
125 Rally bench test suite
126 ======================
127
128 .. _Rally: https://wiki.openstack.org/wiki/Rally
129
130 The OPNFV scenarios are based on the collection of Rally_ scenarios:
131  * authenticate
132  * cinder
133  * nova
134  * vm
135  * glance
136  * keystone
137  * neutron
138  * quotas
139
140 The goal of this test suite is to test the different modules of OpenStack and get significant figures that could help us to define telco Cloud KPI.
141
142 This test suite provides performance information on VIM (OpenStack) part.
143
144 No SLA were defined for release 1, we just consider whether the tests are passed or failed.
145
146 In the future SLA shall be considered (e.g. accepting booting time for a given image with a given flavour).
147
148 Through its integration in Continuous Integration, the evolution of the performance of these tests shall also be considered.
149
150 Tempest
151 =======
152
153 .. _Tempest: http://docs.openstack.org/developer/tempest/overview.html
154
155 Tempest_ is the OpenStack Integration Test Suite. We use Rally to run Tempest suite.
156
157 The goal of this test is to check the OpenStack installation (sanity checks).
158
159
160 OpenDaylight
161 ============
162
163 The ODL suite consists in a set of basic tests inherited from ODL project. The list of tests can be described as follow:
164  * Restconf.basic: Get the controller modules via Restconf
165  * Neutron.Networks
166   * Check OpenStack Networks :: Checking OpenStack Neutron for known networks
167   * Check OpenDaylight Networks :: Checking OpenDaylight Neutron API
168   * Create Network :: Create new network in OpenStack
169   * Check Network :: Check Network created in OpenDaylight
170   * Neutron.Networks :: Checking Network created in OpenStack are pushed
171  * Neutron.Subnets
172   * Check OpenStack Subnets :: Checking OpenStack Neutron for known Subnets
173   * Check OpenDaylight subnets :: Checking OpenDaylight Neutron API
174   * Create New subnet :: Create new subnet in OpenStack
175   * Check New subnet :: Check new subnet created in OpenDaylight
176   * Neutron.Subnets :: Checking Subnets created in OpenStack are pushed
177  * Neutron.Ports
178   * Check OpenStack ports :: Checking OpenStack Neutron for known ports
179   * Check OpenDaylight ports :: Checking OpenDaylight Neutron API
180   * Create New Port :: Create new port in OpenStack
181   * Check New Port :: Check new subnet created in OpenDaylight
182   * Neutron.Ports :: Checking Port created in OpenStack are pushed
183
184 vPing
185 =====
186
187 The goal of this test can be described as follow::
188
189  vPing testcase
190  +-------------+                   +-------------+
191  |             |                   |             |
192  |             |                   |             |
193  |             |     Boot VM1      |             |
194  |             +------------------>|             |
195  |             |                   |             |
196  |             |     Get IP VM1    |             |
197  |             +------------------>|             |
198  |   Tester    |                   |   System    |
199  |             |     Boot VM2      |    Under    |
200  |             +------------------>|     Test    |
201  |             | VM2 pings VM1     |             |
202  |             |                   |             |
203  |             | Check console log |             |
204  |             |    If ping:       |             |
205  |             |      exit OK      |             |
206  |             |    else (timeout) |             |
207  |             |      exit KO      |             |
208  |             |                   |             |
209  |             |                   |             |
210  +-------------+                   +-------------+
211
212
213 This example, using OpenStack Python clients can be considered as an "Hello World" example and may be modified for future use.
214
215 .. _tooling_installation:
216
217 ----------------------
218 Tooling installation
219 ----------------------
220
221 2 external tools are needed for the functional tests on Arno:
222  * Rally
223  * Robot
224
225 Rally is used for benchmarking and running Tempest. Robot is used for OpenDaylight.
226
227 A script (config_test.py) has been created to simplify as much as possible the installation of the different suites of tests.
228
229 This script config_test.py_ is hosted in OPNFV repository and uses the configuration file config_functest.yaml_::
230
231  usage: config_functest.py [-h] [-d] [-f] path action
232
233  positional arguments:
234   repo_path    path to the repository
235   action       Possible actions are: 'start|check|clean'
236
237  optional arguments:
238   -h, --help   show this help message and exit
239   -d, --debug  Debug mode
240   -f, --force  used to avoid prompting the user for confirmation when cleaning functest environment.
241
242 Actions
243  * start: will prepare the functional testing environment
244  * check: will check the configuration (scenarios available, environment variables properly set, networks,..)
245  * clean: will clean the functional test environement if existing
246
247 This script will:
248  * Install Rally environment
249  * Install Tempest
250  * Retrieve test scenarios
251  * Setup ODL environment
252  * Create temporary neutron private network
253  * Create router to connect both
254  * Create Glance images
255
256
257 Useful links:
258
259 .. _`OpenRC`: http://docs.openstack.org/user-guide/common/cli_set_environment_variables_using_openstack_rc.html
260
261 .. _`Rally installation procedure`: https://rally.readthedocs.org/en/latest/tutorial/step_0_installation.html
262
263 .. _`config_test.py` : https://git.opnfv.org/cgit/functest/tree/testcases/config_functest.py
264
265 .. _`config_functest.yaml` : https://git.opnfv.org/cgit/functest/tree/testcases/config_functest.yaml
266
267
268 When integrated in CI, the only prerequisite consists in retrieving the OpenStack credentials (rc file).
269 This file shall be saved as $HOME/functest/opnfv-openrc.shn on the jumphost server.
270 In this case, the script will clone the functest repository, execute environment checks and install tools.
271
272
273 The procedure to set up functional testing environment can be described as follow::
274
275     Log on the Jumphost server
276     Be sure you are no root
277     Modify and adapt needed parameters in the config_functest.yaml. Follow the instructions below.
278     Retrieve OpenStack source file (configure your `OpenRC`_ file to let Rally access to your OpenStack, you can either export it from Horizon or build it manually (OpenStack credentials are required)
279     $ source Your_OpenRC_file
280     $ python config_functest.py -d <Your_functest_directory> start
281
282 At the end of the executing, a new directory will be created <functest_repo_directory> with the following structure::
283
284  <functest_repo_directory>/ODL
285  <functest_repo_directory>/Rally_repo
286  <functest_repo_directory>/Rally_test
287  <functest_repo_directory>/vPing
288  <functest_repo_directory>/config_functest.yaml
289  <functest_repo_directory>/functest-img.img
290
291 NOTE: the Rally environment will be installed under ~/.rally/ the default Tempest configuration (automatically generated by Rally based on OpenStack credentials) can be found une .rally/tempest/for-deployment-<deployment_id>/tempest.conf
292
293
294 HOWTO configure config_functest.yaml:
295
296 Do not change the directories structure
297     * image_name:               name of the image that will be created in Glance
298     * image_url:                URL of the image to be downloaded
299     * image_disk_format:        glance image disk format (raw, qcow2, ...)
300
301     * neutron_private_net_name:     name of an OpenStack private network. If not existing, it will be created
302     * neutron_private_subnet_name:  private subnet network to be created if not existing
303     * neutron_private_subnet_cidr:  range of the private subnet.
304     * neutron_private_subnet_start: start IP
305     * neutron_private_subnet_end:   end IP
306     * neutron_router_name:          name of the router between the private and the public networks
307
308     * ping_timeout: time out of the vPing test case
309     * vm_flavor:    name of the flavor used to create the VMs
310     * vm_name_1:    name of the first VM
311     * vm_name_2:    name of the second VM
312
313
314 Please note that you need to install this environment only once. Until the credentials of the System Under Test are not changing, the testing environment shall be fine.
315
316 If you need more details on Rally installation, see `Rally installation procedure`_.
317
318 You can check if the configuration of rally is fine by typing 'rally deployment check', you shall see the list of available services as follow::
319
320     # rally deployment check
321     keystone endpoints are valid and following service are available:
322     +-------------+-----------+------------+
323     | Services  | Type        | Status     |
324     +-----------+-------------+------------+
325     | cinder    | volume      | Available  |
326     | cinderv2  | volumev2    | Available  |
327     | glance    | image       | Available  |
328     | keystone  | identity    | Available  |
329     | neutron   | network     | Available  |
330     | nova      | compute     | Available  |
331     | nova_ec2  | compute_ec2 | Available  |
332     | novav3    | computev3   | Available  |
333     +-----------+-------------+------------+
334
335     # rally show images
336     +--------------------------------------+----------------------------------------------+------------+
337     | UUID                                 | Name                                         | Size (B)   |
338     +--------------------------------------+----------------------------------------------+------------+
339     | 0a15951f-6388-4d5d-8531-79e7205eb140 | cirros_2015_04_10_13_13_18                   | 13167616   |
340     | b1504066-045a-4f8f-8919-8c665ef3f400 | Ubuntu 14.04 64b                             | 253297152  |
341     +--------------------------------------+----------------------------------------------+------------+
342
343     # rally show flavors
344     +--------------------------------------+---------------------+-------+----------+-----------+-----------+
345     | ID                                   | Name                | vCPUs | RAM (MB) | Swap (MB) | Disk (GB) |
346     +--------------------------------------+---------------------+-------+----------+-----------+-----------+
347     | 110e6375-a058-4af6-b21e-b765187904d2 | m1.medium           | 2     | 1024     |           | 20        |
348     | 7084d7e7-415a-455d-a55a-2ad286ddf7c9 | m1.large            | 4     | 4096     |           | 80        |
349     | a0345ba7-c667-4fd2-964f-7e98f8cda279 | m1.xlarge           | 4     | 8192     |           | 200       |
350     | accdc28c-5e20-4859-a5cc-61cf9009e56d | m1.small            | 1     | 512      |           | 10        |
351     +--------------------------------------+---------------------+-------+----------+-----------+-----------+
352
353     # rally show networks
354     Networks for user `admin` in tenant `admin`:
355     +--------------------------------------+------------------------------+------+
356     | ID                                   | Label                        | CIDR |
357     +--------------------------------------+------------------------------+------+
358     | 4f43c349-956f-4073-9ef6-75bf4e62a0e7 | functest-net                 | None |
359     | faefaab1-e503-41fc-875b-5e3112be49ed | provider_network             | None |
360     +--------------------------------------+------------------------------+------+
361
362
363 --------------
364 Manual testing
365 --------------
366
367 Rally bench suite
368 =================
369
370 Several scenarios are available (mainly based on native Rally scenarios):
371  * glance
372  * nova
373  * authenticate
374  * keystone
375  * neutron
376  * quotas
377  * request
378  * tempest
379  * smoke
380  * all (every module except tempest and smoke)
381
382 You can run the script as follow::
383
384     # python run_rally.py keystone
385
386 The script will:
387  * get the json scenario (if not already available) and put it into the scenario folder
388  * run rally
389  * generate the html result page into <result_folder>/<timestamp>/opnfv-[module name].html
390  * generate the json result page into <result_folder>/<timestamp>/opnfv-[module name].json
391  * generate OK or KO
392
393 Tempest suite
394 =============
395
396 It is possible to use Rally to perform Tempest tests (ref: `tempest installation guide using Rally`_)
397 You just need to run::
398
399      # rally verify start
400
401 The different modes available are smoke, baremetal, compute, data_processing, identity, image, network, object_storage, orchestration, telemetry, and volume. By default if you do not precise anything then smoke tests be selected by default. For Arno, it was decided to focus on smoke tests.
402
403 .. _`tempest installation guide using Rally`: https://www.mirantis.com/blog/rally-openstack-tempest-testing-made-simpler/
404
405 OpenDaylight
406 ============
407 ODL wiki page describes system preparation and running tests. See `Integration Group CSIT`_.
408
409 .. _`Integration Group CSIT`: https://wiki.opendaylight.org/view/CrossProject:Integration_Group:CSIT
410
411
412 .. _manualtest:
413
414 --------------
415 Test results
416 --------------
417
418 Rally bench suite
419 =================
420
421 Results are available in the result folder through a html page and a json file.
422
423 Tempest suite
424 =============
425
426 You can get the results of tempest by typing::
427
428     # rally verify list
429
430 You shall see the results as follow::
431
432     Total results of verification:
433
434     +--------------------------------------+--------------------------------------+----------+-------+----------+----------------------------+----------+
435     | UUID                                 | Deployment UUID                      | Set name | Tests | Failures | Created at                 | Status   |
436     +--------------------------------------+--------------------------------------+----------+-------+----------+----------------------------+----------+
437     | 0144c50f-ab03-45fb-9c36-242ad6440b46 | d9e1bb21-8e36-4d89-b137-0c852dbb308e | smoke    | 87    | 32       | 2015-05-05 16:36:00.986003 | finished |
438     +--------------------------------------+--------------------------------------+----------+-------+----------+----------------------------+----------+
439
440 If you run this test several times, you will see as many lines as test attempts.
441
442 You can get more details on the test by typing::
443
444     # rally verify show --uuid <UUID of the test>
445     # rally verify detailed --uuid <UUID of the test>
446
447 "show" will show you all the restults including the time needed to execute the test.
448 "detailed" will display additional elements (errors)
449
450 Example of test result display::
451
452     +------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+--------+
453     | name                                                                                                                                                       | time      | status |
454     +------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+--------+
455     | tempest.api.network.test_routers.RoutersTest.test_create_show_list_update_delete_router[id-f64403e2-8483-4b34-8ccd-b09a87bcc68c,smoke]                     | 0.011466  | FAIL   |
456     | tempest.api.network.test_security_groups.SecGroupIPv6Test.test_create_list_update_show_delete_security_group[id-bfd128e5-3c92-44b6-9d66-7fe29d22c802,smoke]| 1.234566  | OK     |
457     | tempest.api.network.test_security_groups.SecGroupIPv6Test.test_create_show_delete_security_group_rule[id-cfb99e0e-7410-4a3d-8a0c-959a63ee77e9,smoke]       | 1.060221  | OK     |
458     | tempest.api.network.test_security_groups.SecGroupIPv6Test.test_list_security_groups[id-e30abd17-fef9-4739-8617-dc26da88e686,smoke]                         | 0.060797  | OK     |
459     | tempest.api.network.test_security_groups.SecGroupTest.test_create_list_update_show_delete_security_group[id-bfd128e5-3c92-44b6-9d66-7fe29d22c802,smoke]    | 0.685149  | OK     |
460     | tempest.api.network.test_security_groups.SecGroupTest.test_create_show_delete_security_group_rule[id-cfb99e0e-7410-4a3d-8a0c-959a63ee77e9,smoke]           | 0.730561  | OK     |
461     | tempest.api.network.test_security_groups.SecGroupTest.test_list_security_groups[id-e30abd17-fef9-4739-8617-dc26da88e686,smoke]                             | 0.116862  | OK     |
462     | tempest.api.object_storage.test_account_quotas.AccountQuotasTest                                                                                           | 0.0       | SKIP   |
463     | ...                                                                                                                                                        |   ...     |  ...   |
464
465 OpenDaylight
466 ============
467
468 Tests can be executed with script *start_test.sh* from directory *functest/testcases/Controllers/ODL/CI*. For usage example see::
469
470     # bash ~./.functest/ODL/start_test.sh -h
471
472 vPing
473 =====
474 The test can be executed with command::
475
476     #python ~./.functest/vPing.py -d
477
478
479 .. _automatictest:
480
481 ------------------
482 Testing Automation
483 ------------------
484
485 For Arno, the CI job performs the following actions:
486  * clean and prepare functest environment
487  * run Tempest
488  * run vPing
489  * run Rally Bench
490  * run ODL tests
491  * save results
492  * clean functest environment
493
494 Connection of your platform
495 ===========================
496
497 .. _`Octopus procedure`: https://wiki.opnfv.org/octopus/jenkins_slave_connection/
498
499 If you want to add your platform to the community automation, please follow the `Octopus procedure`_.
500
501 Integrating into CI Pipeline
502 ============================
503
504 .. _`pipeline document`: https://wiki.opnfv.org/octopus/pipelines
505
506 Contact Octopus Team (#opnfv-octopus) and see `pipeline document`_ for more details.
507
508 .. _references:
509
510 ----------
511 References
512 ----------
513
514 OPNFV main site: opnfvmain_.
515
516 OPNFV functional test page: opnfvfunctest_.
517
518 IRC support chan: #opnfv-testperf
519
520 .. _opnfvmain: http://www.opnfv.org
521 .. _opnfvfunctest: https://wiki.opnfv.org/opnfv_functional_testing