Fix Doc errors detected in opnfv-docs-verify and add license
[functest.git] / docs / userguide / runfunctest.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3
4 Executing the functest suites
5 =============================
6
7
8 Manual testing
9 --------------
10
11 Once the Functest docker container is running and Functest environment ready
12 (through */home/opnfv/repos/functest/docker/prepare_env.sh* script), the system is
13 ready to run the tests.
14
15 The script *run_tests.sh* launches the test in an automated way.
16 Although it is possible to execute the different tests manually, it is
17 recommended to use the previous shell script which makes the call
18 to the actual scripts with the appropriate parameters.
19
20 It is located in *$repos_dir/functest/docker* and it has
21 several options::
22
23     ./run_tests.sh -h
24     Script to trigger the tests automatically.
25
26     usage:
27         bash run_tests.sh [-h|--help] [-r|--report] [-n|--no-clean] [-t|--test <test_name>]
28
29     where:
30         -h|--help         show this help text
31         -r|--report       push results to database (false by default)
32         -n|--no-clean     do not clean up OpenStack resources after test run
33         -s|--serial       run tests in one thread
34         -t|--test         run specific set of tests
35           <test_name>     one or more of the following separated by comma:
36                              vping_ssh,vping_userdata,odl,rally,tempest,vims,onos,promise,ovno
37
38     examples:
39         run_tests.sh
40         run_tests.sh --test vping,odl
41         run_tests.sh -t tempest,rally --no-clean
42
43 The *-r* option is used by the OPNFV Continuous Integration automation mechanisms
44 in order to push the test results into the NoSQL results collection database.
45 This database is read only for a regular user given that it needs special rights
46 and special conditions to push data.
47
48 The *-t* option can be used to specify the list of a desired test to be launched,
49 by default Functest will launch all the test suites in the following order:
50 vPing, Tempest, vIMS, Rally.
51
52 A single or set of test may be launched at once using *-t <test_name>* specifying
53 the test name or names separated by commas in the following list:
54 *[vping,vping_userdata,odl,rally,tempest,vims,onos,promise]*.
55
56 The *-n* option is used for preserving all the possible OpenStack resources created
57 by the tests after their execution.
58
59 Please note that Functest includes cleaning mechanism in order to remove
60 all the VIM resources except what was present before running any test. The script
61 *$repos_dir/functest/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py*
62 is called once by *prepare_env.sh* when setting up the Functest environment
63 to snapshot all the OpenStack resources (images, networks, volumes, security groups,
64 tenants, users) so that an eventual cleanup does not remove any of this defaults.
65
66 The *-s* option forces execution of test cases in a single thread. Currently this
67 option affects Tempest test cases only and can be used e.g. for troubleshooting
68 concurrency problems.
69
70 The script
71 *$repos_dir/functest/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py*
72 is normally called after a test execution if the *-n* is not specified. It
73 is in charge of cleaning the OpenStack resources that are not specified
74 in the defaults file generated previously which is stored in
75 */home/opnfv/functest/conf/os_defaults.yaml* in the docker
76 container.
77
78 It is important to mention that if there are new OpenStack resources created
79 manually after preparing the Functest environment, they will be removed if this
80 flag is not specified in the *run_tests.sh* command.
81 The reason to include this cleanup meachanism in Functest is because some
82 test suites such as Tempest or Rally create a lot of resources (users,
83 tenants, networks, volumes etc.) that are not always properly cleaned, so this
84 cleaning function has been set to keep the system as clean as it was before a
85 full Functest execution.
86
87 Within the Tempest test suite it is possible to define which test cases to execute
88 by editing *test_list.txt* file before executing *run_tests.sh* script. This file
89 is located in *$repos_dir/functest/testcases/VIM/OpenStack/CI/custom_tests/test_list.txt*
90
91 Although *run_tests.sh* provides an easy way to run any test, it is possible to
92 do a direct call to the desired test script. For example:
93
94     python $repos_dir/functest/testcases/vPing/vPing.py -d
95
96
97 Automated testing
98 -----------------
99
100 As mentioned in `[1]`, the *prepare-env.sh* and *run_test.sh* can be called within
101 the container from Jenkins. There are 2 jobs that automate all the manual steps
102 explained in the previous section. One job runs all the tests and the other one allows testing
103 test suite by test suite specifying the test name. The user might use one or
104 the other job to execute the desired test suites.
105
106 One of the most challenging task in the Brahmaputra release consists
107 in dealing with lots of scenarios and installers. Thus, when the tests are
108 automatically started from CI, a basic algorithm has been created in order to
109 detect whether a given test is runnable or not on the given scenario.
110 Some Functest test suites cannot be systematically run (e.g. ODL suite can not
111 be run on an ONOS scenario).
112
113
114
115 CI provides some useful information passed to the container as environment
116 variables:
117
118  * Installer (apex|compass|fuel|joid), stored in INSTALLER_TYPE
119  * Installer IP of the engine or VM running the actual deployment, stored in INSTALLER_IP
120  * The scenario [controller]-[feature]-[mode], stored in DEPLOY_SCENARIO with
121
122    * controller = (odl|onos|ocl|nosdn)
123    * feature = (ovs(dpdk)|kvm)
124    * mode = (ha|noha)
125
126 The constraints per test case are defined in the Functest configuration file
127 */home/opnfv/functest/config/config_functest.yaml*::
128
129  test-dependencies:
130     functest:
131         vims:
132             scenario: '(ocl)|(odl)|(nosdn)'
133         vping:
134         vping_userdata:
135             scenario: '(ocl)|(odl)|(nosdn)'
136         tempest:
137         rally:
138         odl:
139             scenario: 'odl'
140         onos:
141             scenario: 'onos'
142         ....
143
144 At the end of the Functest environment creation, a file
145 */home/opnfv/functest/conf/testcase-list.txt* is created with the list of
146 all the runnable tests.
147 Functest considers the static constraints as regular expressions and compare them
148 with the given scenario name.
149 For instance, ODL suite can be run only on an scenario including 'odl' in its name.
150
151 The order of execution is also described in the Functest configuration file::
152
153  test_exec_priority:
154
155     1: vping_ssh
156     2: vping_userdata
157     3: tempest
158     4: odl
159     5: onos
160     6: ovno
161     7: doctor
162     8: promise
163     9: odl-vpnservice
164     10: bgpvpn
165     11: openstack-neutron-bgpvpn-api-extension-tests
166     12: vims
167     13: rally
168
169 The tests are executed in the following order:
170
171  * Basic scenario (vPing_ssh, vPing_userdata, Tempest)
172  * Controller suites: ODL or ONOS or OpenContrail
173  * Feature projects (promise, vIMS)
174  * Rally (benchmark scenario)
175
176 As explained before, at the end of an automated execution, the OpenStack resources
177 might be eventually removed.