Merge "Add qtip job to pod zte-virtual6"
[releng.git] / utils / test / testapi / docs / developer / devguide / framework.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3 .. (c) 2017 ZTE Corp.
4
5
6 .. toctree::
7    :maxdepth: 2
8
9 =========
10 Framework
11 =========
12
13 **Test Results Collector of OPNFV Test Projects**:
14
15 This project aims to provide a common way of gathering all the test results for OPNFV
16 testing projects into a single place, and a unified way of getting those results for
17 testing analysis projects, such as Reporting/Bitergia Dashboard/Qtip. It exposes
18 Restful APIs for collecting results and pushing them into a MongoDB database.
19
20 If you are interested in how TestAPI looks like, please visit OPNFV's official `TestAPI Server`__
21
22 .. __: http://testresults.opnfv.org/test
23
24 Pre-requsites
25 =============
26
27 TestAPI leverages MongoDB as the data warehouse, in order to let it work
28 successfully, a MongoDB must be provided, the official MongoDB version in OPNFV
29 TestAPI is 3.2.6. And the database is **test_results_collection**, the five
30 collections are *users/pods/projects/testcases/scenarioes/results*. And thanks to
31 MongoDB's very user-friendly property, they don't need to be created in advance.
32
33 Running locally
34 ===============
35
36 Requirements
37 ^^^^^^^^^^^^
38
39 All requirements are listed in requirements.txt and should be
40 installed by 'pip install':
41
42     *pip install -r requirements.txt*
43
44 Installation
45 ^^^^^^^^^^^^
46
47     *python setup.py install*
48
49 After installation, configuration file etc/config.ini will be put under
50 /etc/opnfv_testapi/. And all the web relevant files under 3rd_party/static
51 will be in /user/local/share/opnfv_testapi as a totality.
52
53 Start Server
54 ^^^^^^^^^^^^
55
56     *opnfv-testapi [--config-file <config.ini>]*
57
58 If --config-file is provided, the specified configuration file will be employed
59 when starting the server, or else /etc/opnfv_testapi/config.ini will be utilized
60 by default.
61
62 After executing the command successfully, a TestAPI server will be started on
63 port 8000, to visit web portal, please access http://hostname:8000
64
65 Regarding swagger-ui website, please visit http://hostname:8000/swagger/spec.html
66
67 Running with container
68 ======================
69
70 TestAPI has already containerized, the docker image is opnfv/testapi:latest.
71
72 **Running the container not behind nginx:**
73
74 .. code-block:: shell
75
76     docker run -dti --name testapi -p expose_port:8000
77         -e "mongodb_url=mongodb://mongodb_ip:27017/"
78         -e "base_url=http://host_name:expose_port"
79         opnfv/testapi:latest
80
81 **Running the container behind nginx:**
82
83 .. code-block:: shell
84
85     docker run -dti --name testapi -p expose_port:8000
86         -e "mongodb_url=mongodb://mongodb_ip:27017/"
87         -e "base_url=http://nginx_url"
88         opnfv/testapi:latest
89
90 Unittest & pep8
91 ===============
92
93 All requirements for unit tests are outlined in test-requirements.txt, and in TestAPI project, tox is leveraged to drive the executing of unit tests and pep8 check
94
95 **Running unit tests**
96
97     *tox -e py27*
98
99 **Running pep8 check**
100
101     *tox -e pep8*