1 ******************************
2 OPNFV FUNCTEST developer guide
3 ******************************
14 This document describes how feature projects aiming to run functional tests can
15 be integrated into FuncTest framework.
18 ================================
19 Functest High level architecture
20 ================================
22 Functest is project delivering a test container dedicated to OPNFV.
23 It includes the tools, the scripts and the test scenarios.
25 Functest can be described as follow::
27 +----------------------+
29 | +--------------+ | +-------------------+
31 | | Tools | +------------------+ OPNFV |
32 | | Scripts | | | System Under Test |
33 | | Scenarios | +------------------+ |
34 | | | | Management | |
35 | +--------------+ | +-------------------+
39 +----------------------+
41 Functest deals with internal and external test cases.
42 The Internal test cases in Brahmaputra are:
51 The external tescases are:
58 see `[2]`_ for details.
60 Functest can also be considered as a framework that may include external OPNFV
62 This framework will ease the integration of the feature test suite to the CI.
68 The installation and the launch of the Functest docker image is described in
71 The Functest docker directories are::
94 +-----------+-------------------+---------------------------------------------+
95 | Directory | Subdirectory | Comments |
96 +-----------+-------------------+---------------------------------------------+
97 | | <project>/conf | All the useful configuration file(s) for |
98 | | | <project> the openstack creds are put there |
100 | | | It is recommended to push it there when |
101 | | | passing the credentials to container through|
102 | | | the -v option |
103 | +-------------------+---------------------------------------------+
104 | opnfv | <project>/data | Usefull data, images for <projects> |
105 | | | By default we put a cirros image: |
106 | | | cirros-0.3.4-x86_64-disk.img |
107 | | | This image can be used by any projects |
108 | +-------------------+---------------------------------------------+
109 | | <project>/results | Local result directory of project <project> |
110 +-----------+-------------------+---------------------------------------------+
112 | +-------------------+ +
114 | +-------------------+ +
116 | +-------------------+ +
117 | | odl_integration | |
118 | +-------------------+ Clone of the useful repositories +
119 | | onos | These repositories may include: |
120 | +-------------------+ - tooling +
121 | | promise | - scenario |
122 | +-------------------+ - scripts +
124 | +-------------------+ +
126 | +-------------------+ +
128 | +-------------------+ +
129 | | <your project> | |
130 +-----------+-------------------+---------------------------------------------+
132 Before running the test suite, you must prepare the environement by running::
134 $ /home/opnfv/repos/functest/docker/prepare_env.sh
136 By running prepare_env.sh, you build the test environement required by the tests
137 including the retrieval and sourcing of OpenStack credentials.
138 This is an example of the env variables we have in the docker container:
140 * HOSTNAME=373f77816eb0
141 * INSTALLER_TYPE=fuel
142 * repos_dir=/home/opnfv/repos
143 * INSTALLER_IP=10.20.0.2
144 * PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
148 * NODE_NAME=opnfv-jump-2
149 * creds=/home/opnfv/functest/conf/openstack.creds
152 The prepare_env.sh will source the credentials, so once run you should have
153 access to the following env variables::
155 root@373f77816eb0:~# env|grep OS_
156 OS_REGION_NAME=RegionOne
157 OS_PROJECT_NAME=admin
159 OS_AUTH_STRATEGY=keystone
160 OS_AUTH_URL=http://172.30.10.70:5000/v2.0
163 OS_ENDPOINT_TYPE=internalURL
167 Then you may run the test suite by running::
169 $ /home/opnfv/repos/functest/docker/run_tests.sh -t <your project>
171 see `[2]`_ for details.
175 =========================
176 How to integrate Functest
177 =========================
179 The files of the Functest repository you must modify to integrate Functest are:
181 * functest/docker/Dockerfile
182 * functest/docker/common.sh
183 * functest/docker/requirements.pip
184 * functest/docker/run_tests.sh
185 * functest/docker/prepare_env.sh
186 * functest/config_funtest.yaml
192 This file lists the repositories to be cloned in the Functest container.
193 The repositories can be internal or external::
195 RUN git clone https://gerrit.opnfv.org/gerrit/<your porject> ${repos_dir}/<your project>
201 This file can be used to declare the branch and commit variables of your
204 <YOUR_PROJECT>_BRANCH=$(cat $config_file | grep -w <your project>_branch | awk 'END {print $NF}')
205 <YOUR_PROJECT>_COMMIT=$(cat $config_file | grep -w <your project>_commit | awk 'END {print $NF}')
207 echo "<YOUR_PROJECT>_BRANCH=${<YOUR_PROJECT>_BRANCH}"
208 echo "<YOUR_PROJECT>_COMMIT=${<YOUR_PROJECT>_COMMIT}"
214 This file can be used to preloaded all the needed Python libraries (and avoid
215 that each project does it)
216 The current libraries used in Functest container are::
218 # cat requirements.pip
221 python-neutronclient==2.6.0
222 python-novaclient==2.28.1
223 python-glanceclient==1.1.0
224 python-cinderclient==1.4.0
225 python-ceilometerclient==1.5.1
226 python-keystoneclient==1.6.0
230 robotframework==2.9.1
231 robotframework-requests==0.3.8
232 robotframework-sshlibrary==2.1.1
243 This script can be adapted if you need to set up a specific environment before
249 This script is used to run the tests. You must thus complete the cases with your
254 info "Running PROMISE test case..."
258 info "Running Doctor test..."
259 python ${FUNCTEST_REPO_DIR}/testcases/features/doctor.py
262 info "Running <your project> test..."
263 # your script that launchs your tests...
266 And do not forget to update also the help line::
268 -t|--test run specific set of tests
269 <test_name> one or more of the following separated by comma:
270 vping_ssh,vping_userdata,odl,rally,tempest,vims,onos,promise,ovno
276 This file is the main configuration file of Functest. You must add the
277 references to your project::
281 dir_repo_<your project>: /home/opnfv/repos/<your project>
283 # branch and commit ID to which the repos will be reset (HEAD)
284 <your project>_branch: master
285 <your project>_commit: latest
292 The OPNFV testing group created a test collection database to collect the test
294 Any test project running on any lab integrated in CI can push the results to
296 This database can be used afterwards to see the evolution of the tests and
297 compare the results versus the installers, the scenario or the labs.
299 You can find more information about the dashboard from Testing Dashboard wiki
304 The Test result management in Brahmaputra can be summarized as follows::
306 +-------------+ +-------------+ +-------------+
308 | Test | | Test | | Test |
309 | Project #1 | | Project #2 | | Project #N |
311 +-------------+ +-------------+ +-------------+
314 +-----------------------------------------+
316 | Test Rest API front end |
317 | http://testresults.opnfv.org/testapi |
319 +-----------------------------------------+
322 | +-------------------------+
324 | | Test Results DB |
327 | +-------------------------+
330 +----------------------+
334 +----------------------+
336 The Test dashboard URL is: TODO LF
337 A alternate Test dashboard has been realized to provide a view per installer and
338 per scenario for Brahmaputra release::
340 http://testresults.opnfv.org/proto/brahma/
342 This Dashboard consumes the results retrieved thanks to the Test API.
346 The Test API is used to declare pods, projects, test cases and test results. An
347 additional method dashboard has been added to post-process the raw results. The
348 data model is very basic, 4 objects are created:
359 "details": <URL description of the POD>,
360 "creation_date": YYYY-MM-DD HH:MM:SS ,
361 "name": <The POD Name>,
362 "mode": <metal or virtual>
369 "name": <Name of the Project>,
370 "creation_date": "YYYY-MM-DD HH:MM:SS",
371 "description": <Short description>
378 "name":<Name of the test case>,
379 "creation_date": "YYYY-MM-DD HH:MM:SS",
380 "description": <short description>,
381 "url":<URL for longer description>
388 "project_name": <Reference to project>,
389 "pod_name": <Reference to POD where the test was executed>,
390 "version": <Scenario on which the test was executed>,
391 "installer": <Installer Apex or Compass or Fuel or Joid>,
392 "description": <Short description>,
393 "creation_date": "YYYY-MM-DD HH:MM:SS",
394 "case_name": <Reference to the test case>
396 <- the results to be put here ->
400 For Brahmaputra, we got:
406 The projects and the test cases have been frozen in December.
407 But all were not ready for Brahmaputra.
411 The API can described as follows:
415 +--------+--------------------------+-----------------------------------------+
416 | Method | Path | Description |
417 +========+==========================+=========================================+
418 | GET | /version | Get API version |
419 +--------+--------------------------+-----------------------------------------+
424 +--------+--------------------------+-----------------------------------------+
425 | Method | Path | Description |
426 +========+==========================+=========================================+
427 | GET | /pods | Get the list of declared Labs (PODs) |
428 +--------+--------------------------+-----------------------------------------+
429 | POST | /pods | Declare a new POD |
430 | | | Content-Type: application/json |
432 | | | "name": "pod_foo", |
433 | | | "creation_date": "YYYY-MM-DD HH:MM:SS" |
435 +--------+--------------------------+-----------------------------------------+
439 +--------+--------------------------+-----------------------------------------+
440 | Method | Path | Description |
441 +========+==========================+=========================================+
442 | GET | /test_projects | Get the list of test projects |
443 +--------+--------------------------+-----------------------------------------+
444 | GET |/test_projects/{project} | Get details on {project} |
446 +--------+--------------------------+-----------------------------------------+
447 | POST | /test_projects | Add a new test project |
448 | | | Content-Type: application/json |
450 | | | "name": "project_foo", |
451 | | | "description": "whatever you want" |
453 +--------+--------------------------+-----------------------------------------+
454 | PUT | /test_projects/{project} | Update a test project |
456 | | | Content-Type: application/json |
458 | | | <the field(s) you want to modify> |
460 +--------+--------------------------+-----------------------------------------+
461 | DELETE | /test_projects/{project} | Delete a test project |
462 +--------+--------------------------+-----------------------------------------+
467 +--------+--------------------------+-----------------------------------------+
468 | Method | Path | Description |
469 +========+==========================+=========================================+
470 | GET | /test_projects/{project}/| Get the list of test cases of {project} |
472 +--------+--------------------------+-----------------------------------------+
473 | POST | /test_projects/{project}/| Add a new test case to {project} |
474 | | cases | Content-Type: application/json |
476 | | | "name": "case_foo", |
477 | | | "description": "whatever you want" |
478 | | | "creation_date": "YYYY-MM-DD HH:MM:SS" |
479 | | | "url": "whatever you want" |
481 +--------+--------------------------+-----------------------------------------+
482 | PUT | /test_projects/{project}?| Modify a test case of {project} |
483 | | case_name={case} | |
484 | | | Content-Type: application/json |
486 | | | <the field(s) you want to modify> |
488 +--------+--------------------------+-----------------------------------------+
489 | DELETE | /test_projects/{project}/| Delete a test case |
490 | | case_name={case} | |
491 +--------+--------------------------+-----------------------------------------+
495 +--------+--------------------------+-----------------------------------------+
496 | Method | Path | Description |
497 +========+==========================+=========================================+
498 | GET |/results/project={project}| Get the test results of {project} |
499 +--------+--------------------------+-----------------------------------------+
500 | GET |/results/case={case} | Get the test results of {case} |
501 +--------+--------------------------+-----------------------------------------+
502 | GET |/results?pod={pod} | get the results on pod {pod} |
503 +--------+--------------------------+-----------------------------------------+
504 | GET |/results?installer={inst} | Get the test results of installer {inst}|
505 +--------+--------------------------+-----------------------------------------+
506 | GET |/results?version={version}| Get the test results of scenario |
507 | | | {version}. Initially the version param |
508 | | | was reflecting git version, in Functest |
509 | | | it was decided to move to scenario |
510 +--------+--------------------------+-----------------------------------------+
511 | GET |/results?project={project}| Get all the results of the test case |
512 | |&case={case} | {case} of the project {project} with |
513 | |&version={scenario} | version {scenario} installed by |
514 | |&installer={installer} | {installer} on POD {pod} stored since |
515 | |&pod={pod} | {days} days |
516 | | | {project_name} and {case_name} are |
517 | |&period={days} | mandatory, the other parameters are |
519 +--------+--------------------------+-----------------------------------------+
520 | POST | /results | Add a new test results |
521 | | | Content-Type: application/json |
523 | | | "project_name": "project_foo", |
524 | | | "case_name": "case_foo", |
525 | | | "pod_name": "pod_foo", |
526 | | | "installer": "installer_foo", |
527 | | | "version": "scenario_foo", |
528 | | | "details": <your results> |
530 +--------+--------------------------+-----------------------------------------+
535 +--------+--------------------------+-----------------------------------------+
536 | Method | Path | Description |
537 +========+==========================+=========================================+
538 | GET |/dashboard? | Get all the dashboard ready results of |
539 | |&project={project} | {case} of the project {project} |
540 | |&case={case} | version {scenario} installed by |
541 | |&version={scenario} | {installer} on POD {pod} stored since |
542 | |&installer={installer} | {days} days |
544 | |&period={days} | {project_name} and {case_name} are |
545 | | | mandatory, the other parameters are |
547 +--------+--------------------------+-----------------------------------------+
550 The results with dashboard method are post-processed from raw results.
551 Please note that dashboard results are not stored. Only raw results are stored.
554 ===============================================
555 How to push your results into the Test Database
556 ===============================================
558 The test database is used to collect test results. By default it is enabled only
559 in Continuous Integration.
560 The architecture and associated API is described in `[2]`_.
561 If you want to push your results from CI, you just have to use the API at the
564 You can also reuse a python function defined in functest_utils.py::
566 def push_results_to_db(db_url, case_name, logger, pod_name,version, payload):
568 POST results to the Result target DB
570 url = db_url + "/results"
571 installer = get_installer_type(logger)
572 params = {"project_name": "functest", "case_name": case_name,
573 "pod_name": pod_name, "installer": installer,
574 "version": version, "details": payload}
576 headers = {'Content-Type': 'application/json'}
578 r = requests.post(url, data=json.dumps(params), headers=headers)
583 print "Error [push_results_to_db('%s', '%s', '%s', '%s', '%s')]:" \
584 % (db_url, case_name, pod_name, version, payload), e
592 .. _`[1]`: http://artifacts.opnfv.org/functest/docs/configguide/index.html Functest configuration guide URL
593 .. _`[2]`: http://artifacts.opnfv.org/functest/docs/userguide/index.html functest user guide URL
594 .. _`[3]`: https://wiki.opnfv.org/opnfv_test_dashboard
597 OPNFV main site: opnfvmain_.
599 OPNFV functional test page: opnfvfunctest_.
601 IRC support chan: #opnfv-testperf
603 .. _opnfvmain: http://www.opnfv.org
604 .. _opnfvfunctest: https://wiki.opnfv.org/opnfv_functional_testing
605 .. _`OpenRC`: http://docs.openstack.org/user-guide/common/cli_set_environment_variables_using_openstack_rc.html
606 .. _`Rally installation procedure`: https://rally.readthedocs.org/en/latest/tutorial/step_0_installation.html
607 .. _`config_test.py` : https://git.opnfv.org/cgit/functest/tree/testcases/config_functest.py
608 .. _`config_functest.yaml` : https://git.opnfv.org/cgit/functest/tree/testcases/config_functest.yaml