Merge "config_functest.py : bugfix: removed "sudo" from installing rally command...
[functest.git] / docs / 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  * Delete Ports
184   * Delete previously created subnet in OpenStack
185   * Check subnet deleted in OpenDaylight
186   * Check subnet deleted in OpenStack
187  * Delete network
188   * Delete previously created network in OpenStack
189   * Check network deleted in OpenDaylight
190   * Check network deleted in OpenStack
191
192 vPing
193 =====
194
195 The goal of this test can be described as follow::
196
197  vPing testcase
198  +-------------+                   +-------------+
199  |             |                   |             |
200  |             |                   |             |
201  |             |     Boot VM1      |             |
202  |             +------------------>|             |
203  |             |                   |             |
204  |             |     Get IP VM1    |             |
205  |             +------------------>|             |
206  |   Tester    |                   |   System    |
207  |             |     Boot VM2      |    Under    |
208  |             +------------------>|     Test    |
209  |             | VM2 pings VM1     |             |
210  |             |                   |             |
211  |             | Check console log |             |
212  |             |    If ping:       |             |
213  |             |      exit OK      |             |
214  |             |    else (timeout) |             |
215  |             |      exit KO      |             |
216  |             |                   |             |
217  |             |                   |             |
218  +-------------+                   +-------------+
219
220
221 This example, using OpenStack Python clients can be considered as an "Hello World" example and may be modified for future use.
222
223 .. _tooling_installation:
224
225 ----------------------
226 Tooling installation
227 ----------------------
228
229 2 external tools are needed for the functional tests on Arno:
230  * Rally
231  * Robot
232
233 Rally is used for benchmarking and running Tempest. Robot is used for OpenDaylight.
234
235 A script (config_test.py) has been created to simplify as much as possible the installation of the different suites of tests.
236
237 This script config_test.py_ is hosted in OPNFV repository and uses the configuration file config_functest.yaml_::
238
239  usage: config_functest.py [-h] [-d] [-f] path action
240
241  positional arguments:
242   repo_path    path to the repository
243   action       Possible actions are: 'start|check|clean'
244
245  optional arguments:
246   -h, --help   show this help message and exit
247   -d, --debug  Debug mode
248   -f, --force  used to avoid prompting the user for confirmation when cleaning functest environment.
249
250 Actions
251  * start: will prepare the functional testing environment
252  * check: will check the configuration (scenarios available, environment variables properly set, networks,..)
253  * clean: will clean the functional test environement if existing
254
255 This script will:
256  * Install Rally environment
257  * Install Tempest
258  * Retrieve test scenarios
259  * Setup ODL environment
260  * Create temporary neutron private network
261  * Create router to connect both
262  * Create Glance images
263
264
265 Useful links:
266
267 .. _`OpenRC`: http://docs.openstack.org/user-guide/common/cli_set_environment_variables_using_openstack_rc.html
268
269 .. _`Rally installation procedure`: https://rally.readthedocs.org/en/latest/tutorial/step_0_installation.html
270
271 .. _`config_test.py` : https://git.opnfv.org/cgit/functest/tree/testcases/config_functest.py
272
273 .. _`config_functest.yaml` : https://git.opnfv.org/cgit/functest/tree/testcases/config_functest.yaml
274
275
276 When integrated in CI, the only prerequisite consists in retrieving the OpenStack credentials (rc file).
277 This file shall be saved as $HOME/functest/opnfv-openrc.shn on the jumphost server.
278 In this case, the script will clone the functest repository, execute environment checks and install tools.
279
280
281 The procedure to set up functional testing environment can be described as follow::
282
283     Log on the Jumphost server
284     Be sure you are no root
285     Modify and adapt needed parameters in the config_functest.yaml. Follow the instructions below.
286     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)
287     $ source Your_OpenRC_file
288     $ python <functest_repo_directory>/config_functest.py -d <Your_functest_directory> start
289
290 At the end of the executing, a new directory will be created <functest_repo_directory> with the following structure::
291
292  <functest_repo_directory>/ODL
293  <functest_repo_directory>/Rally_repo
294  <functest_repo_directory>/Rally_test
295  <functest_repo_directory>/vPing
296  <functest_repo_directory>/config_functest.yaml
297  <functest_repo_directory>/functest-img.img
298
299 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
300
301
302 HOWTO configure config_functest.yaml:
303
304 Do not change the directories structure
305     * image_name:               name of the image that will be created in Glance
306     * image_url:                URL of the image to be downloaded
307     * image_disk_format:        glance image disk format (raw, qcow2, ...)
308
309     * neutron_private_net_name:     name of an OpenStack private network. If not existing, it will be created
310     * neutron_private_subnet_name:  private subnet network to be created if not existing
311     * neutron_private_subnet_cidr:  range of the private subnet.
312     * neutron_private_subnet_start: start IP
313     * neutron_private_subnet_end:   end IP
314     * neutron_router_name:          name of the router between the private and the public networks
315
316     * ping_timeout: time out of the vPing test case
317     * vm_flavor:    name of the flavor used to create the VMs
318     * vm_name_1:    name of the first VM
319     * vm_name_2:    name of the second VM
320
321
322 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.
323
324 If you need more details on Rally installation, see `Rally installation procedure`_.
325
326 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::
327
328     # rally deployment check
329     keystone endpoints are valid and following service are available:
330     +-------------+-----------+------------+
331     | Services  | Type        | Status     |
332     +-----------+-------------+------------+
333     | cinder    | volume      | Available  |
334     | cinderv2  | volumev2    | Available  |
335     | glance    | image       | Available  |
336     | keystone  | identity    | Available  |
337     | neutron   | network     | Available  |
338     | nova      | compute     | Available  |
339     | nova_ec2  | compute_ec2 | Available  |
340     | novav3    | computev3   | Available  |
341     +-----------+-------------+------------+
342
343     # rally show images
344     +--------------------------------------+----------------------------------------------+------------+
345     | UUID                                 | Name                                         | Size (B)   |
346     +--------------------------------------+----------------------------------------------+------------+
347     | 0a15951f-6388-4d5d-8531-79e7205eb140 | cirros_2015_04_10_13_13_18                   | 13167616   |
348     | b1504066-045a-4f8f-8919-8c665ef3f400 | Ubuntu 14.04 64b                             | 253297152  |
349     +--------------------------------------+----------------------------------------------+------------+
350
351     # rally show flavors
352     +--------------------------------------+---------------------+-------+----------+-----------+-----------+
353     | ID                                   | Name                | vCPUs | RAM (MB) | Swap (MB) | Disk (GB) |
354     +--------------------------------------+---------------------+-------+----------+-----------+-----------+
355     | 110e6375-a058-4af6-b21e-b765187904d2 | m1.medium           | 2     | 1024     |           | 20        |
356     | 7084d7e7-415a-455d-a55a-2ad286ddf7c9 | m1.large            | 4     | 4096     |           | 80        |
357     | a0345ba7-c667-4fd2-964f-7e98f8cda279 | m1.xlarge           | 4     | 8192     |           | 200       |
358     | accdc28c-5e20-4859-a5cc-61cf9009e56d | m1.small            | 1     | 512      |           | 10        |
359     +--------------------------------------+---------------------+-------+----------+-----------+-----------+
360
361     # rally show networks
362     Networks for user `admin` in tenant `admin`:
363     +--------------------------------------+------------------------------+------+
364     | ID                                   | Label                        | CIDR |
365     +--------------------------------------+------------------------------+------+
366     | 4f43c349-956f-4073-9ef6-75bf4e62a0e7 | functest-net                 | None |
367     | faefaab1-e503-41fc-875b-5e3112be49ed | provider_network             | None |
368     +--------------------------------------+------------------------------+------+
369
370
371 --------------
372 Manual testing
373 --------------
374
375 vPing
376 =====
377
378     $ python <functest_repo_directory>/vPing/vPing.py -d <Your_functest_directory>
379
380
381 OpenDaylight
382 ============
383
384 You can run ODL suite as follow:
385     $ python <functest_repo_directory>testcases/Controllers/ODL/CI/start_tests.sh
386
387 ODL wiki page describes system preparation and running tests. See `Integration Group CSIT`_.
388
389 .. _`Integration Group CSIT`: https://wiki.opendaylight.org/view/CrossProject:Integration_Group:CSIT
390
391
392 Rally bench suite
393 =================
394
395 Several scenarios are available (mainly based on native Rally scenarios):
396  * glance
397  * nova
398  * authenticate
399  * keystone
400  * neutron
401  * quotas
402  * request
403  * tempest
404  * smoke
405  * all (every module except tempest and smoke)
406
407 You can run the script as follow::
408
409     # python <functest_repo_directory>/testcases/VIM/OpenStack/CI/libraries/run_rally.py <functest_repo_directory> keystone
410
411 The script will:
412  * get the json scenario (if not already available) and put it into the scenario folder
413  * run rally
414  * generate the html result page into <result_folder>/<timestamp>/opnfv-[module name].html
415  * generate the json result page into <result_folder>/<timestamp>/opnfv-[module name].json
416  * generate OK or KO
417
418 Tempest suite
419 =============
420
421 It is possible to use Rally to perform Tempest tests (ref: `tempest installation guide using Rally`_)
422 You just need to run::
423
424      # rally verify start
425
426 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.
427
428 .. _`tempest installation guide using Rally`: https://www.mirantis.com/blog/rally-openstack-tempest-testing-made-simpler/
429
430
431 .. _manualtest:
432
433 --------------
434 Test results
435 --------------
436
437 vPing
438 =====
439 vPing results are automatically displayed in the console.
440
441
442 OpenDaylight
443 ============
444 ODL tests are executed in the console, and 3 result files are generated
445
446
447 Rally bench suite
448 =================
449
450 Results are available in the result folder through a html page and a json file.
451
452 Tempest suite
453 =============
454
455 You can get the results of tempest by typing::
456
457     # rally verify list
458
459 You shall see the results as follow::
460
461     Total results of verification:
462
463     +--------------------------------------+--------------------------------------+----------+-------+----------+----------------------------+----------+
464     | UUID                                 | Deployment UUID                      | Set name | Tests | Failures | Created at                 | Status   |
465     +--------------------------------------+--------------------------------------+----------+-------+----------+----------------------------+----------+
466     | 0144c50f-ab03-45fb-9c36-242ad6440b46 | d9e1bb21-8e36-4d89-b137-0c852dbb308e | smoke    | 87    | 32       | 2015-05-05 16:36:00.986003 | finished |
467     +--------------------------------------+--------------------------------------+----------+-------+----------+----------------------------+----------+
468
469 If you run this test several times, you will see as many lines as test attempts.
470
471 You can get more details on the test by typing::
472
473     # rally verify show --uuid <UUID of the test>
474     # rally verify detailed --uuid <UUID of the test>
475
476 "show" will show you all the restults including the time needed to execute the test.
477 "detailed" will display additional elements (errors)
478
479 Example of test result display::
480
481     +------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+--------+
482     | name                                                                                                                                                       | time      | status |
483     +------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+--------+
484     | tempest.api.network.test_routers.RoutersTest.test_create_show_list_update_delete_router[id-f64403e2-8483-4b34-8ccd-b09a87bcc68c,smoke]                     | 0.011466  | FAIL   |
485     | 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     |
486     | tempest.api.network.test_security_groups.SecGroupIPv6Test.test_create_show_delete_security_group_rule[id-cfb99e0e-7410-4a3d-8a0c-959a63ee77e9,smoke]       | 1.060221  | OK     |
487     | tempest.api.network.test_security_groups.SecGroupIPv6Test.test_list_security_groups[id-e30abd17-fef9-4739-8617-dc26da88e686,smoke]                         | 0.060797  | OK     |
488     | 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     |
489     | tempest.api.network.test_security_groups.SecGroupTest.test_create_show_delete_security_group_rule[id-cfb99e0e-7410-4a3d-8a0c-959a63ee77e9,smoke]           | 0.730561  | OK     |
490     | tempest.api.network.test_security_groups.SecGroupTest.test_list_security_groups[id-e30abd17-fef9-4739-8617-dc26da88e686,smoke]                             | 0.116862  | OK     |
491     | tempest.api.object_storage.test_account_quotas.AccountQuotasTest                                                                                           | 0.0       | SKIP   |
492     | ...                                                                                                                                                        |   ...     |  ...   |
493
494
495
496 .. _automatictest:
497
498 ------------------
499 Testing Automation
500 ------------------
501
502 For Arno, the CI job performs the following actions:
503  * clean and prepare functest environment
504  * run Tempest
505  * run vPing
506  * run Rally Bench
507  * run ODL tests
508  * save results
509  * clean functest environment
510
511 Connection of your platform
512 ===========================
513
514 .. _`Octopus procedure`: https://wiki.opnfv.org/octopus/jenkins_slave_connection/
515
516 If you want to add your platform to the community automation, please follow the `Octopus procedure`_.
517
518 Integrating into CI Pipeline
519 ============================
520
521 .. _`pipeline document`: https://wiki.opnfv.org/octopus/pipelines
522
523 Contact Octopus Team (#opnfv-octopus) and see `pipeline document`_ for more details.
524
525 .. _references:
526
527 ----------
528 References
529 ----------
530
531 OPNFV main site: opnfvmain_.
532
533 OPNFV functional test page: opnfvfunctest_.
534
535 IRC support chan: #opnfv-testperf
536
537 .. _opnfvmain: http://www.opnfv.org
538 .. _opnfvfunctest: https://wiki.opnfv.org/opnfv_functional_testing