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 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/test |
319 +-----------------------------------------+
322 | +-------------------------+
324 | | Test Results DB |
327 | +-------------------------+
330 +----------------------+
334 +----------------------+
338 The Test API is used to declare pods, projects, test cases and test results. An
339 additional method dashboard has been added to post-process the raw results in release Brahmaputra.
340 The data model is very basic, 4 objects are created:
351 "details": <URL description of the POD>,
352 "creation_date": "YYYY-MM-DD HH:MM:SS",
353 "name": <The POD Name>,
354 "mode": <metal or virtual>,
355 "role": <ci-pod or community-pod or single-node>
362 "name": <Name of the Project>,
363 "creation_date": "YYYY-MM-DD HH:MM:SS",
364 "description": <Short description>
371 "name":<Name of the test case>,
372 "project_name":<Name of belonged project>,
373 "creation_date": "YYYY-MM-DD HH:MM:SS",
374 "description": <short description>,
375 "url":<URL for longer description>
382 "case_name": <Reference to the test case>,
383 "project_name": <Reference to project>,
384 "pod_name": <Reference to POD where the test was executed>,
385 "installer": <Installer Apex or Compass or Fuel or Joid>,
386 "version": <master or Colorado or Brahmaputra>,
387 "start_date": "YYYY-MM-DD HH:MM:SS",
388 "stop_date": "YYYY-MM-DD HH:MM:SS",
389 "build_tag": <such as "jenkins-functest-fuel-baremetal-daily-master-108">,
390 "scenario": <Scenario on which the test was executed>,
391 "criteria": <PASS or FAILED>,
392 "trust_indicator": <0~1>
395 The API can described as follows. For detailed information, please go to
396 http://testresults.opnfv.org/test/swagger/spec.html
398 Authentication: opnfv/api@opnfv
400 Please notes that POST/DELETE/PUT operations for test or study purpose via
401 swagger website is not allowed, because it will change the real data in
406 +--------+--------------------------+-----------------------------------------+
407 | Method | Path | Description |
408 +========+==========================+=========================================+
409 | GET | /versions | Get all supported API versions |
410 +--------+--------------------------+-----------------------------------------+
415 +--------+----------------------------+-----------------------------------------+
416 | Method | Path | Description |
417 +========+============================+=========================================+
418 | GET | /api/v1/pods | Get the list of declared Labs (PODs) |
419 +--------+----------------------------+-----------------------------------------+
420 | POST | /api/v1/pods | Declare a new POD |
421 | | | Content-Type: application/json |
423 | | | "name": "pod_foo", |
424 | | | "mode": "metal", |
425 | | | "role": "ci-pod", |
426 | | | "details": "it is a ci pod" |
428 +--------+----------------------------+-----------------------------------------+
429 | GET | /api/v1/pods/{pod_name} | Get a declared POD |
430 +--------+----------------------------+-----------------------------------------+
434 +--------+----------------------------+-----------------------------------------+
435 | Method | Path | Description |
436 +========+============================+=========================================+
437 | GET | /api/v1/projects | Get the list of declared projects |
438 +--------+----------------------------+-----------------------------------------+
439 | POST | /api/v1/projects | Declare a new test project |
440 | | | Content-Type: application/json |
442 | | | "name": "project_foo", |
443 | | | "description": "whatever you want" |
445 +--------+----------------------------+-----------------------------------------+
446 | DELETE | /api/v1/projects/{project} | Delete a test project |
447 +--------+----------------------------+-----------------------------------------+
448 | GET | /api/v1/projects/{project} | Get details on a {project} |
450 +--------+----------------------------+-----------------------------------------+
451 | PUT | /api/v1/projects/{project} | Update a test project |
453 | | | Content-Type: application/json |
455 | | | <the field(s) you want to modify> |
457 +--------+----------------------------+-----------------------------------------+
462 +--------+----------------------------+-----------------------------------------+
463 | Method | Path | Description |
464 +========+============================+=========================================+
465 | GET | /api/v1/projects/{project}/| Get the list of testcases of {project} |
467 +--------+----------------------------+-----------------------------------------+
468 | POST | /api/v1/projects/{project}/| Add a new test case to {project} |
469 | | cases | Content-Type: application/json |
471 | | | "name": "case_foo", |
472 | | | "description": "whatever you want" |
473 | | | "url": "whatever you want" |
475 +--------+----------------------------+-----------------------------------------+
476 | DELETE | /api/v1/projects/{project}/| Delete a test case |
478 +--------+----------------------------+-----------------------------------------+
479 | GET | /api/v1/projects/{project}/| Get a declared test case |
481 +--------+----------------------------+-----------------------------------------+
482 | PUT | /api/v1/projects/{project}?| Modify a test case of {project} |
484 | | | Content-Type: application/json |
486 | | | <the field(s) you want to modify> |
488 +--------+----------------------------+-----------------------------------------+
492 +--------+----------------------------+------------------------------------------+
493 | Method | Path | Description |
494 +========+============================+==========================================+
495 | GET | /api/v1/results | Get all the test results |
496 +--------+----------------------------+------------------------------------------+
497 | POST | /api/v1/results | Add a new test results |
498 | | | Content-Type: application/json |
500 | | | "project_name": "project_foo", |
501 | | | "scenario": "odl-l2", |
502 | | | "stop_date": "2016-05-28T14:42:58.384Z", |
503 | | | "trust_indicator": 0.5, |
504 | | | "case_name": "vPing", |
505 | | | "build_tag": "", |
506 | | | "version": "Colorado", |
507 | | | "pod_name": "pod_foo", |
508 | | | "criteria": "PASS", |
509 | | | "installer": "fuel", |
510 | | | "start_date": "2016-05-28T14:41:58.384Z",|
511 | | | "details": <your results> |
513 +--------+----------------------------+------------------------------------------+
514 | GET | /api/v1/results? | Get the test results of {case} |
516 +--------+----------------------------+------------------------------------------+
517 | GET | /api/v1/results? | Get the test results of build_tag |
518 | | build_tag={tag} | {tag}. |
519 +--------+----------------------------+------------------------------------------+
520 | GET | /api/v1/results? | Get last {N} records of test results |
522 +--------+----------------------------+------------------------------------------+
523 | GET | /api/v1/results? | Get the test results of scenario |
524 | | scenario={scenario} | {scenario}. |
525 +--------+----------------------------+------------------------------------------+
526 | GET | /api/v1/results? | Get the test results of trust_indicator |
527 | | trust_indicator={ind} | {ind}. |
528 +--------+----------------------------+------------------------------------------+
529 | GET | /api/v1/results? | Get the test results of last days |
530 | | period={period} | {period}. |
531 +--------+----------------------------+------------------------------------------+
532 | GET | /api/v1/results? | Get the test results of {project} |
533 | | project={project} | |
534 +--------+----------------------------+------------------------------------------+
535 | GET | /api/v1/results? | Get the test results of version |
536 | | version={version} | {version}. |
537 +--------+----------------------------+------------------------------------------+
538 | GET | /api/v1/results? | Get the test results of criteria |
539 | | criteria={criteria} | {criteria}. |
540 +--------+----------------------------+------------------------------------------+
541 | GET | /api/v1/results? | get the results on pod {pod} |
543 +--------+----------------------------+------------------------------------------+
544 | GET | /api/v1/results? | Get the test results of installer {inst} |
545 | | installer={inst} | |
546 +--------+----------------------------+------------------------------------------+
547 | GET | /api/v1/results? | Get the results according to combined |
548 | | <query conditions> | query conditions supported above |
549 +--------+----------------------------+------------------------------------------+
550 | GET | /api/v1/results/{result_id}| Get the test result by result_id |
551 +--------+----------------------------+------------------------------------------+
556 +--------+----------------------------+-----------------------------------------+
557 | Method | Path | Description |
558 +========+============================+=========================================+
559 | GET |/dashboard/v1/results? | Get all the dashboard ready results of |
560 | |&project={project} | {case} of the project {project} |
562 +--------+----------------------------+-----------------------------------------+
563 | GET |/dashboard/v1/results? | Get all the dashboard ready results of |
564 | |&project={project} | {case} of the project {project} |
565 | |&case={case} | version {version} |
566 | |&version={version} | |
567 +--------+----------------------------+-----------------------------------------+
568 | GET |/dashboard/v1/results? | Get all the dashboard ready results of |
569 | |&project={project} | {case} of the project {project} |
570 | |&case={case} | since {days} days |
571 | |&period={days} | |
572 +--------+----------------------------+-----------------------------------------+
573 | GET |/dashboard/v1/results? | Get all the dashboard ready results of |
574 | |&project={project} | {case} of the project {project} |
575 | |&case={case} | installed by {installer} |
576 | |&installer={installer} | |
577 +--------+----------------------------+-----------------------------------------+
578 | GET |/dashboard/v1/results? | Get all the dashboard ready results of |
579 | |&project={project} | {case} of the project {project} |
580 | |&case={case} | on POD {pod} |
582 +--------+----------------------------+-----------------------------------------+
583 | GET |/dashboard/v1/results? | Get all the dashboard ready results of |
584 | |&project={project} | {case} of the project {project} |
585 | |&case={case} | and combined by other query conditions |
586 | |&<query conditions> | supported above. |
587 +--------+----------------------------+-----------------------------------------+
588 | GET |/dashboard/v1/projects? | Get all the dashboard ready projects |
589 +--------+----------------------------+-----------------------------------------+
591 Dashboard description
592 =====================
594 The results with dashboard method are post-processed from raw results.
595 Please note that dashboard results are not stored. Only raw results are stored.
600 Dashboard url: http://testresults.opnfv.org/dashboard/
605 Dashboard url: http://testresults.opnfv.org/kibana_dashboards/
607 Credentials for a guest account: opnfvuser/kibana
609 ===============================================
610 How to push your results into the Test Database
611 ===============================================
613 The test database is used to collect test results. By default it is enabled only
614 in Continuous Integration.
615 The architecture and associated API is described in `[2]`_.
616 If you want to push your results from CI, you just have to use the API at the
619 You can also reuse a python function defined in functest_utils.py::
621 def push_results_to_db(db_url, case_name, logger, pod_name,version, payload):
623 POST results to the Result target DB
625 url = db_url + "/results"
626 installer = get_installer_type(logger)
627 params = {"project_name": "functest", "case_name": case_name,
628 "pod_name": pod_name, "installer": installer,
629 "version": version, "details": payload}
631 headers = {'Content-Type': 'application/json'}
633 r = requests.post(url, data=json.dumps(params), headers=headers)
638 print "Error [push_results_to_db('%s', '%s', '%s', '%s', '%s')]:" \
639 % (db_url, case_name, pod_name, version, payload), e
647 .. _`[1]`: http://artifacts.opnfv.org/functest/docs/configguide/index.html Functest configuration guide URL
648 .. _`[2]`: http://artifacts.opnfv.org/functest/docs/userguide/index.html functest user guide URL
649 .. _`[3]`: https://wiki.opnfv.org/opnfv_test_dashboard
652 OPNFV main site: opnfvmain_.
654 OPNFV functional test page: opnfvfunctest_.
656 IRC support chan: #opnfv-testperf
658 .. _opnfvmain: http://www.opnfv.org
659 .. _opnfvfunctest: https://wiki.opnfv.org/opnfv_functional_testing
660 .. _`OpenRC`: http://docs.openstack.org/user-guide/common/cli_set_environment_variables_using_openstack_rc.html
661 .. _`Rally installation procedure`: https://rally.readthedocs.org/en/latest/tutorial/step_0_installation.html
662 .. _`config_test.py` : https://git.opnfv.org/cgit/functest/tree/testcases/config_functest.py
663 .. _`config_functest.yaml` : https://git.opnfv.org/cgit/functest/tree/testcases/config_functest.yaml