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