Merge "Fix the format issue of documentation"
[functest.git] / docs / testing / developer / devguide / index.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. SPDX-License-Identifier: CC-BY-4.0
3
4 ************************
5 Functest Developer Guide
6 ************************
7
8 .. toctree::
9    :numbered:
10    :maxdepth: 2
11
12 Version history
13 ===============
14 +------------+----------+------------------+----------------------------------+
15 | **Date**   | **Ver.** | **Author**       | **Comment**                      |
16 |            |          |                  |                                  |
17 +------------+----------+------------------+----------------------------------+
18 | 2017-01-23 | 1.0.0    | Morgan Richomme  | Creation for Danube              |
19 +------------+----------+------------------+----------------------------------+
20 | 2017-08-16 | 1.0.1    | Morgan Richomme  | Adaptations for Euphrates        |
21 |            |          |                  | - move generic part to Testing   |
22 |            |          |                  | developer guide                  |
23 |            |          |                  | - move reporting part to functest|
24 |            |          |                  | user guide                       |
25 |            |          |                  | - update test case list          |
26 |            |          |                  | - include auto generated core    |
27 |            |          |                  | documentation                    |
28 +------------+----------+------------------+----------------------------------+
29
30 ============
31 Introduction
32 ============
33
34 Functest is a project dealing with functional testing.
35 The project produces its own internal test cases but can also be considered
36 as a framework to support feature and VNF onboarding project testing.
37
38 Therefore there are many ways to contribute to Functest. You can:
39
40  * Develop new internal test cases
41  * Integrate the tests from your feature project
42  * Develop the framework to ease the integration of external test cases
43
44 Additional tasks involving Functest but addressing all the test projects
45 may also be mentioned:
46
47   * The API / Test collection framework
48   * The dashboards
49   * The automatic reporting portals
50   * The testcase catalog
51
52 This document describes how, as a developer, you may interact with the
53 Functest project. The first section details the main working areas of
54 the project. The Second part is a list of "How to" to help you to join
55 the Functest family whatever your field of interest is.
56
57
58 ========================
59 Functest developer areas
60 ========================
61
62
63 Functest High level architecture
64 ================================
65
66 Functest is a project delivering test containers dedicated to OPNFV.
67 It includes the tools, the scripts and the test scenarios.
68 Until Danube, Functest produced 2 docker files based on Ubuntu 14.04:
69
70   * x86 Functest: https://hub.docker.com/r/opnfv/functest/
71   * aarch64 Functest: https://hub.docker.com/r/opnfv/functest_aarch64/
72
73 In Euphrates Alpine containers have been introduced in order to lighten the
74 container and manage testing slicing. The new containers are created according
75 to the different tiers:
76
77   * functest-core: https://hub.docker.com/r/opnfv/functest-core/
78   * functest-healthcheck: https://hub.docker.com/r/opnfv/functest-healthcheck/
79   * functest-smoke: https://hub.docker.com/r/opnfv/functest-smoke/
80   * functest-features: https://hub.docker.com/r/opnfv/functest-features/
81   * functest-components: https://hub.docker.com/r/opnfv/functest-components/
82   * functest-vnf: https://hub.docker.com/r/opnfv/functest-vnf/
83   * functest-parser: https://hub.docker.com/r/opnfv/functest-parser/
84   * functest-restapi: https://hub.docker.com/r/opnfv/functest-restapi/
85
86 Standalone functest dockers are maintained for Euphrates but Alpine containers
87 are recommended.
88
89 Functest can be described as follow:
90
91  +----------------------+
92  |                      |
93  |   +--------------+   |                  +-------------------+
94  |   |              |   |    Public        |                   |
95  |   | Tools        |   +------------------+      OPNFV        |
96  |   | Scripts      |   |                  | System Under Test |
97  |   | Scenarios    |   |                  |                   |
98  |   |              |   |                  |                   |
99  |   +--------------+   |                  +-------------------+
100  |                      |
101  |    Functest Docker   |
102  |                      |
103  +----------------------+
104
105 Functest internal test cases
106 ============================
107 The internal test cases in Euphrates are:
108
109
110  * api_check
111  * connection_check
112  * snaps_health_check
113  * vping_ssh
114  * vping_userdata
115  * odl
116  * odl-netvirt
117  * odl-fds
118  * rally_full
119  * rally_sanity
120  * tempest_smoke_serial
121  * tempest_full_parallel
122  * cloudify_ims
123
124 By internal, we mean that this particular test cases have been developed and/or
125 integrated by functest contributors and the associated code is hosted in the
126 Functest repository.
127 An internal case can be fully developed or a simple integration of
128 upstream suites (e.g. Tempest/Rally developed in OpenStack, or odl suites are
129 just integrated in Functest).
130
131 The structure of this repository is detailed in `[1]`_.
132 The main internal test cases are in the opnfv_tests subfolder of the
133 repository, the internal test cases can be grouped by domain:
134
135  * sdn: odl, odl_netvirt, odl_fds
136  * openstack: api_check, connection_check, snaps_health_check, vping_ssh, vping_userdata, tempest_*, rally_*
137  * vnf: cloudify_ims
138
139 If you want to create a new test case you will have to create a new folder under
140 the testcases directory (See next section for details).
141
142 Functest external test cases
143 ============================
144 The external test cases are inherited from other OPNFV projects, especially the
145 feature projects.
146
147 The external test cases are:
148
149  * barometer
150  * bgpvpn
151  * doctor
152  * domino
153  * fds
154  * parser
155  * promise
156  * refstack_defcore
157  * snaps_smoke
158  * functest-odl-sfc
159  * orchestra_clearwaterims
160  * orchestra_openims
161  * cloudify_vrouter
162  * juju_vepc
163
164 External test cases integrated in previous versions but not released in
165 Euphrates:
166
167  * copper
168  * moon
169  * netready
170  * security_scan
171
172
173 The code to run these test cases is hosted in the repository of the project.
174 Please note that orchestra test cases are hosted in Functest repository and not
175 in orchestra repository. Cloudify_vrouter and juju_vepc code is also hosted in
176 functest as there are no dedicated projects.
177
178
179 Functest framework
180 ==================
181
182 Functest is a framework.
183
184 Historically Functest is released as a docker file, including tools, scripts and
185 a CLI to prepare the environment and run tests.
186 It simplifies the integration of external test suites in CI pipeline and provide
187 commodity tools to collect and display results.
188
189 Since Colorado, test categories also known as **tiers** have been created to
190 group similar tests, provide consistent sub-lists and at the end optimize
191 test duration for CI (see How To section).
192
193 The definition of the tiers has been agreed by the testing working group.
194
195 The tiers are:
196   * healthcheck
197   * smoke
198   * features
199   * components
200   * vnf
201
202 Functest abstraction classes
203 ============================
204
205 In order to harmonize test integration, abstraction classes have been
206 introduced:
207
208  * testcase: base for any test case
209  * unit: run unit tests as test case
210  * feature: abstraction for feature project
211  * vnf: abstraction for vnf onboarding
212
213 The goal is to unify the way to run tests in Functest.
214
215 Feature, unit and vnf_base inherit from testcase::
216
217               +-----------------------------------------+
218               |                                         |
219               |         TestCase                        |
220               |                                         |
221               |         - init()                        |
222               |         - run()                         |
223               |         - push_to_db()                  |
224               |         - is_successful()               |
225               |                                         |
226               +-----------------------------------------+
227                  |               |                   |
228                  V               V                   V
229   +--------------------+   +--------------+   +--------------------------+
230   |                    |   |              |   |                          |
231   |    feature         |   |    unit      |   |      vnf                 |
232   |                    |   |              |   |                          |
233   |                    |   |              |   |  - prepare()             |
234   |  - execute()       |   |              |   |  - deploy_orchestrator() |
235   | BashFeature class  |   |              |   |  - deploy_vnf()          |
236   |                    |   |              |   |  - test_vnf()            |
237   |                    |   |              |   |  - clean()               |
238   +--------------------+   +--------------+   +--------------------------+
239
240
241 Testcase
242 --------
243 .. raw:: html
244    :url: http://artifacts.opnfv.org/functest/docs/apidoc/functest.core.testcase.html
245
246 Feature
247 -------
248 .. raw:: html
249    :url: http://artifacts.opnfv.org/functest/docs/apidoc/functest.core.feature.html
250
251 Unit
252 ----
253 .. raw:: html
254    :url: http://artifacts.opnfv.org/functest/docs/apidoc/functest.core.unit.html
255
256 VNF
257 ---
258 .. raw:: html
259    :url: http://artifacts.opnfv.org/functest/docs/apidoc/functest.core.vnf.html
260
261
262 see `[5]`_ to get code samples
263
264
265 Functest util classes
266 =====================
267
268 In order to simplify the creation of test cases, Functest develops also some
269 functions that are used by internal test cases.
270 Several features are supported such as logger, configuration management and
271 Openstack capabilities (snapshot, clean, tacker,..).
272 These functions can be found under <repo>/functest/utils and can be described as
273 follows::
274
275  functest/utils/
276  |-- config.py
277  |-- constants.py
278  |-- decorators.py
279  |-- env.py
280  |-- functest_utils.py
281  |-- openstack_clean.py
282  |-- openstack_snapshot.py
283  |-- openstack_tacker.py
284  `-- openstack_utils.py
285
286 It is recommended to use the SNAPS-OO library for deploying OpenStack instances.
287 SNAPS `[4]`_ is an OPNFV project providing OpenStack utils.
288
289
290 TestAPI
291 =======
292 Functest is using the Test collection framework and the TestAPI developed by
293 the OPNFV community. See `[6]`_ for details.
294
295
296 Reporting
297 =========
298 A web page is automatically generated every day to display the status based on
299 jinja2 templates `[3]`_.
300
301
302 Dashboard
303 =========
304
305 Additional dashboarding is managed at the testing group level, see `[7]`_ for
306 details.
307
308
309 =======
310 How TOs
311 =======
312
313 See How to section on Functest wiki `[8]`_
314
315
316 ==========
317 References
318 ==========
319
320 _`[1]`: http://artifacts.opnfv.org/functest/docs/configguide/index.html Functest configuration guide
321
322 _`[2]`: http://artifacts.opnfv.org/functest/docs/userguide/index.html functest user guide
323
324 _`[3]`: https://git.opnfv.org/cgit/releng/tree/utils/test/reporting
325
326 _`[4]`: https://git.opnfv.org/snaps/
327
328 _`[5]` : http://testresults.opnfv.org/functest/framework/index.html
329
330 _`[6]`: http://docs.opnfv.org/en/latest/testing/testing-dev.html
331
332 _`[7]`: https://opnfv.biterg.io/goto/283dba93ca18e95964f852c63af1d1ba
333
334 _`[8]`: https://wiki.opnfv.org/pages/viewpage.action?pageId=7768932
335
336 IRC support chan: #opnfv-functest