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