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