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