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