Merge "Rename test_pytest_suite_runner.py to test_unit.py"
[functest.git] / docs / testing / user / configguide / configguide.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 Pulling the Docker image
6 ------------------------
7 Pull the Functest Docker image ('opnfv/functest') from the public
8 dockerhub registry under the OPNFV account: [dockerhub_], with the
9 following docker command::
10
11   docker pull opnfv/functest:<TagIdentifier>
12
13 where <TagIdentifier> identifies a release of the Functest docker
14 container image in the public dockerhub registry. There are many tags
15 created automatically by the CI mechanisms, and you must ensure you
16 pull an image with the **correct tag** to match the OPNFV software
17 release installed in your environment. All available tagged images can
18 be seen from location [FunctestDockerTags_]. For example, when running
19 on the first official release of the OPNFV Danube system platform,
20 tag "danube.1.0" is needed. Pulling other tags might cause some
21 problems while running the tests.
22 Docker images pulled without a tag specifier bear the implicitly
23 assigned label "latest". If you need to specifically pull the latest
24 Functest docker image, then omit the tag argument::
25
26   docker pull opnfv/functest
27
28 After pulling the Docker image, check that it is available with the
29 following docker command::
30
31   [functester@jumphost ~]$ docker images
32   REPOSITORY     TAG             IMAGE ID      CREATED      SIZE
33   opnfv/functest latest          8cd6683c32ae  2 weeks ago  1.321 GB
34   opnfv/functest danube.1.0    13fa54a1b238  4 weeks ago  1.29 GB
35   opnfv/functest colorado.1.0    94b78faa94f7  9 weeks ago  968 MB
36
37 The Functest docker container environment can -in principle- be also
38 used with non-OPNFV official installers (e.g. 'devstack'), with the
39 **disclaimer** that support for such environments is outside of the
40 scope and responsibility of the OPNFV project.
41
42 Accessing the Openstack credentials
43 -----------------------------------
44 OpenStack credentials are mandatory and can be retrieved in different
45 ways. From inside the running Functest docker container the
46 "functest env prepare" command will automatically look for the
47 Openstack credentials file "/home/opnfv/functest/conf/openstack.creds"
48 and retrieve it unless the file already exists. This Functest
49 environment preparation step is described later in this document.
50
51 WARNING: When the installer type is "joid" you have to have the
52 credentials file inside the running container **before** initiating the
53 functest environment preparation. For that reason you have to choose
54 either one of the options below, since the automated copying does not
55 work for "joid".
56
57 You can also specifically pass in the needed file prior to running the
58 environment preparation either:
59
60   * by using the -v option when creating the Docker container. This is
61     referred to in docker documentation as "Bind Mounting". See the
62     usage of this parameter in the following chapter.
63   * or creating a local file '/home/opnfv/functest/conf/openstack.creds'
64     inside the running container with the credentials in it. Consult
65     your installer guide for further details. This is however not
66     instructed in this document.
67
68 NOTE: When the installer type is "fuel" and virtualized deployment
69 is used, there you have to explicitly fetch the credentials file
70 executing the following sequence
71
72   #. Create a container as described in next chapter but do not
73      "Bind Mount" the credentials
74   #. Log in to container and execute the following command. Replace
75      the IP with installer address after the "-a" parameter::
76
77        fetch_os_creds.sh \
78        -d /home/opnfv/functest/conf/openstack.creds \
79        -i fuel \
80        -a 10.20.0.2 \
81        -v
82        ( -d specifies the full path to the Openstack credential file
83        -i specifies the INSTALLER_TYPE
84        -a specifies the INSTALLER_IP
85        -v indicates a virtualized environment and takes no arguments )
86
87   #. Continue with your testing, initiate functest environment
88      preparation, run tests etc.
89
90 In proxified environment you may need to change the credentials file.
91 There are some tips in chapter: `Proxy support`_
92
93 Functest Docker parameters
94 --------------------------
95 This chapter explains how to run a container for executing functest
96 test suites. Numbered list below explains some details of the
97 recommended parameters for invoking docker container
98
99   #. It is a good practice to assign a precise container name through
100      the **--name** option.
101
102   #. Assign parameter for installer type::
103
104        -e "INSTALLER_TYPE=<type>"
105        # Use one of following apex, compass, fuel or joid
106
107   #. Functest needs to know the IP of some installers::
108
109        -e "INSTALLER_IP=<Specific IP Address>"
110
111        This IP is needed to fetch RC file from deployment, fetch logs, ...
112        If not provided, there is no way to fetch the RC file. It must be
113        provided manually as a volume
114
115   #. Credentials for accessing the Openstack.
116      Most convenient way of passing them to container is by having a
117      local copy of the credentials file in Jumphost and then using the
118      **-v** option. In the example we have local file by the name of
119      "overcloudrc" and we are using that as an argument::
120
121        -v ~/overcloudrc:/home/opnfv/functest/conf/openstack.creds
122
123        The credentials file needs to exist in the Docker container
124        under the path: '/home/opnfv/functest/conf/openstack.creds'.
125
126      **WARNING:** If you are using the Joid installer, you must pass the
127      credentials using the **-v** option:
128      -v /var/lib/jenkins/admin-openrc:/home/opnfv/functest/conf/openstack.creds.
129      See the section `Accessing the Openstack credentials`_ above.
130
131   #. Passing deployment scenario
132      When running Functest against any of the supported OPNFV scenarios,
133      it is recommended to include also the environment variable
134      **DEPLOY_SCENARIO**. The **DEPLOY_SCENARIO** environment variable
135      is passed with the format::
136
137        -e "DEPLOY_SCENARIO=os-<controller>-<nfv_feature>-<ha_mode>"
138        where:
139        os = OpenStack (No other VIM choices currently available)
140        controller is one of ( nosdn | odl_l2 | odl_l3 | onos | ocl)
141        nfv_feature is one or more of ( ovs | kvm | sfc | bgpvpn | nofeature )
142                 If several features are pertinent then use the underscore
143                 character '_' to separate each feature (e.g. ovs_kvm)
144                 'nofeature' indicates no NFV feature is deployed
145        ha_mode (high availability) is one of ( ha | noha )
146
147      **NOTE:** Not all possible combinations of "DEPLOY_SCENARIO" are
148      supported. The name passed in to the Functest Docker container
149      must match the scenario used when the actual OPNFV platform was
150      deployed. See release note to see the list of supported scenarios.
151
152      **NOTE:** The scenario name is mainly used to automatically detect
153      if a test suite is runnable or not (e.g. it will prevent ONOS test suite
154      to be run on ODL scenarios). If not set, Functest will try to run the
155      default test cases that might not include SDN controller or a specific
156      feature
157
158      **NOTE:** A HA scenario means that 3 OpenStack controller nodes are
159      deployed. It does not necessarily mean that the whole system is HA. See
160      installer release notes for details.
161
162
163 Putting all above together, when using installer 'fuel' and an invented
164 INSTALLER_IP of '10.20.0.2', the recommended command to create the
165 Functest Docker container is as follows::
166
167   docker run --name "FunctestContainer" -it \
168   -e "INSTALLER_IP=10.20.0.2" \
169   -e "INSTALLER_TYPE=fuel" \
170   -e "DEPLOY_SCENARIO=os-odl_l2-ovs_kvm-ha" \
171   -v ~/overcloudrc:/home/opnfv/functest/conf/openstack.creds \
172   opnfv/functest /bin/bash
173
174 After the *run* command, a new prompt appears which means that we are inside
175 the container and ready to move to the next step.
176
177 For tips on how to set up container with installer Apex, see chapter
178 `Apex Installer Tips`_.
179
180 Finally, three additional environment variables can also be passed in
181 to the Functest Docker Container, using the -e
182 "<EnvironmentVariable>=<Value>" mechanism. The first two of these are
183 only relevant to Jenkins CI invoked testing and **should not be used**
184 when performing manual test scenarios::
185
186   -e "NODE_NAME=<Test POD Name>" \
187   -e "BUILD_TAG=<Jenkins Build Tag>" \
188   -e "CI_DEBUG=<DebugTraceValue>"
189   where:
190   <Test POD Name> = Symbolic name of the POD where the tests are run.
191                     Visible in test results files, which are stored
192                     to the database. This option is only used when
193                     tests are activated under Jenkins CI control.
194                     It indicates the POD/hardware where the test has
195                     been run. If not specified, then the POD name is
196                     defined as "Unknown" by default.
197                     DO NOT USE THIS OPTION IN MANUAL TEST SCENARIOS.
198   <Jenkins Build tag> = Symbolic name of the Jenkins Build Job.
199                         Visible in test results files, which are stored
200                         to the database. This option is only set when
201                         tests are activated under Jenkins CI control.
202                         It enables the correlation of test results,
203                         which
204                         are independently pushed to the results database
205                         from different Jenkins jobs.
206                         DO NOT USE THIS OPTION IN MANUAL TEST SCENARIOS.
207   <DebugTraceValue> = "true" or "false"
208                       Default = "false", if not specified
209                       If "true" is specified, then additional debug trace
210                       text can be sent to the test results file / log files
211                       and also to the standard console output.
212
213 Apex Installer Tips
214 -------------------
215 Some specific tips are useful for the Apex Installer case. If not using
216 Apex Installer; ignore this section.
217
218 In case of Triple-O based installer (like Apex) the docker container
219 needs to connect to the installer VM, so it is then required that some
220 known SSH keys are present in docker container. Since the Jumphost root
221 SSH keys are already known, easiest way is to use those using the
222 'Bind mount' method. See below for sample parameter::
223
224   -v /root/.ssh/id_rsa:/root/.ssh/id_rsa
225
226   NOTE: You need the "sudo" when creating the container to access root
227   users ssh credentials even the docker command itself might not
228   require that.
229
230 HINT! In case of Triple-O installers you can find value for the
231 INSTALLER_IP parameter by executing command and note the returned IP
232 address::
233
234   inst=$(sudo virsh list | grep -iEo "undercloud|instack")
235   sudo virsh domifaddr ${inst}
236
237   NOTE: In releases prior to Colorado, the name 'instack' was
238   used. Currently the name 'undercloud' is used.
239
240 You can copy the credentials file from the "stack" users home directory
241 in installer VM to Jumphost. Please check the correct IP from the
242 command above. In the example below we are using invented IP address
243 "192.168.122.89"::
244
245     scp stack@192.168.122.89:overcloudrc .
246
247 Here is an example of the full docker command invocation for an Apex
248 installed system, using latest Functest docker container, for
249 illustration purposes::
250
251   sudo docker run -it --name "ApexFuncTestODL" \
252   -e "INSTALLER_IP=192.168.122.89" \
253   -e "INSTALLER_TYPE=apex" \
254   -e "DEPLOY_SCENARIO=os-odl_l2-nofeature-ha" \
255   -v /root/.ssh/id_rsa:/root/.ssh/id_rsa \
256   -v ~/overcloudrc:/home/opnfv/functest/conf/openstack.creds \
257   opnfv/functest /bin/bash
258
259 Compass installer local development env usage Tips
260 --------------------------------------------------
261 In the compass-functest local test case check and development environment,
262 in order to get openstack service inside the functest container, some
263 parameters should be configured during container creation, which are
264 hard to guess for freshman. This section will provide the guideline, the
265 parameters values are defaults here, which should be adjusted according
266 to the settings, the complete steps are given here so as not to appear
267 too abruptly.
268
269 1, Pull Functest docker image from public dockerhub::
270
271     docker pull opnfv/functest:<Tag>
272
273 <Tag> here can be "brahmaputra.1.0", "colorado.1.0", etc.
274 Tag omitted means the latest docker image::
275
276     docker pull opnfv/functest
277
278 2, Functest Docker container creation
279
280 To make a file used for the environment, such as 'functest-docker-env'::
281
282     OS_AUTH_URL=http://172.16.1.222:35357/v2.0
283     OS_USERNAME=admin
284     OS_PASSWORD=console
285     OS_TENANT_NAME=admin
286     OS_VOLUME_API_VERSION=2
287     OS_PROJECT_NAME=admin
288     INSTALLER_TYPE=compass
289     INSTALLER_IP=192.168.200.2
290     EXTERNAL_NETWORK=ext-net
291
292 Note: please adjust the content according to the environment, such as
293 'TENANT_ID' maybe used for some special cases.
294
295 Then to create the Functest docker::
296
297     docker run --privileged=true --rm -t \
298     --env-file functest-docker-env \
299     --name <Functest_Container_Name> \
300     opnfv/functest:<Tag> /bin/bash
301
302 3, To attach Functest container
303
304 Before trying to attach the Functest container, the status can be checked by::
305
306    docker ps -a
307
308 to attach the 'Up' status Functest container and start bash mode::
309
310    docker exec -it <Functest_Container_Name> bash
311
312 4, Functest environemnt preparation and check
313
314 To see the Section below `Preparing the Functest environment`_.
315
316 Functest docker container directory structure
317 ---------------------------------------------
318 Inside the Functest docker container, the following directory structure
319 should now be in place::
320
321   `-- home
322       `-- opnfv
323         |-- functest
324         |   |-- conf
325         |   |-- data
326         |   `-- results
327         `-- repos
328             |-- bgpvpn
329             |-- copper
330             |-- doctor
331             |-- domino
332             |-- functest
333             |-- kingbird
334             |-- odl_test
335             |-- onos
336             |-- parser
337             |-- promise
338             |-- rally
339             |-- refstack-client
340             |-- releng
341             |-- sdnvpn
342             |-- securityscanning
343             |-- sfc
344             |-- tempest
345             |-- vims_test
346             `-- vnfs
347
348 Underneath the '/home/opnfv/' directory, the Functest docker container
349 includes two main directories:
350
351   * The **functest** directory stores configuration files (e.g. the
352     OpenStack creds are stored in path '/home/opnfv/functest/conf/openstack.creds'),
353     the **data** directory stores a 'cirros' test image used in some
354     functional tests and the **results** directory stores some temporary
355     result log files
356   * The **repos** directory holds various repositories. The directory
357     '/home/opnfv/repos/functest' is used to prepare the needed Functest
358     environment and to run the tests. The other repository directories
359     are used for the installation of the needed tooling (e.g. rally) or
360     for the retrieval of feature projects scenarios (e.g. promise)
361
362 The structure under the **functest** repository can be described as
363 follows::
364
365   . |-- INFO
366     |-- LICENSE
367     |-- requirements.txt
368     |-- run_unit_tests.sh
369     |-- setup.py
370     |-- test-requirements.txt
371     |-- commons
372     |   |-- ims
373     |   |-- mobile
374     |   `--traffic-profile-guidelines.rst
375     |-- docker
376     |   |-- Dockerfile
377     |   |-- config_install_env.sh
378     |   `-- docker_remote_api
379     |-- docs
380     |   |-- com
381     |   |-- configguide
382     |   |-- devguide
383     |   |-- images
384     |   |-- internship
385     |   |-- release-notes
386     |   |-- results
387     |   `--userguide
388     |-- functest
389         |-- __init__.py
390         |-- ci
391         |   |-- __init__.py
392         |   |-- check_os.sh
393         |   |-- config_functest.yaml
394         |   |-- config_patch.yaml
395         |   |-- generate_report.py
396         |   |-- prepare_env.py
397         |   |-- run_tests.py
398         |   |-- testcases.yaml
399         |   |-- tier_builder.py
400         |   `-- tier_handler.py
401         |-- cli
402         |   |-- __init__.py
403         |   |-- cli_base.py
404         |   |-- commands
405         |   |-- functest-complete.sh
406         |   `-- setup.py
407         |-- core
408         |   |-- __init__.py
409         |   |-- feature.py
410         |   |-- pytest_suite_runner.py
411         |   |-- testcase.py
412         |   |-- vnf_base.py
413         |-- opnfv_tests
414         |   |-- __init__.py
415         |   |-- features
416         |   |-- mano
417         |   |-- openstack
418         |   |-- sdn
419         |   |-- security_scan
420         |   `-- vnf
421         |-- tests
422         |   |-- __init__.py
423         |   `-- unit
424         `-- utils
425             |-- __init__.py
426             |-- config.py
427             |-- constants.py
428             |-- env.py
429             |-- functest_logger.py
430             |-- functest_utils.py
431             |-- openstack
432             |-- openstack_clean.py
433             |-- openstack_snapshot.py
434             |-- openstack_tacker.py
435             `-- openstack_utils.py
436
437
438     (Note: All *.pyc files removed from above list for brevity...)
439
440 We may distinguish several directories, the first level has 4 directories:
441
442 * **commons**: This directory is dedicated for storage of traffic
443   profile or any other test inputs that could be reused by any test
444   project.
445 * **docker**: This directory includes the needed files and tools to
446   build the Funtest Docker image.
447 * **docs**: This directory includes documentation: Release Notes,
448   User Guide, Configuration Guide and Developer Guide.
449 * **functest**: This directory contains all the code needed to run
450   functest internal cases and OPNFV onboarded feature or VNF test cases.
451
452 Functest directory has 6 directories:
453   * **ci**: This directory contains test structure definition files
454     (e.g <filename>.yaml) and bash shell/python scripts used to
455     configure and execute Functional tests. The test execution script
456     can be executed under the control of Jenkins CI jobs.
457   * **cli**: This directory holds the python based Functest CLI utility
458     source code, which is based on the Python 'click' framework.
459   * **core**: This directory holds the python based Functest core
460       source code. Three abstraction classes have been created to ease
461       the integration of internal, feature or vnf cases.
462   * **opnfv_tests**: This directory includes the scripts required by
463     Functest internal test cases and other feature projects test cases.
464   * **tests**: This directory includes the functest unit tests
465   * **utils**: this directory holds Python source code for some general
466     purpose helper utilities, which testers can also re-use in their
467     own test code. See for an example the Openstack helper utility:
468     'openstack_utils.py'.
469
470 Useful Docker commands
471 ----------------------
472 When typing **exit** in the container prompt, this will cause exiting
473 the container and probably stopping it. When stopping a running Docker
474 container all the changes will be lost, there is a keyboard shortcut
475 to quit the container without stopping it: <CTRL>-P + <CTRL>-Q. To
476 reconnect to the running container **DO NOT** use the *run* command
477 again (since it will create a new container), use the *exec* or *attach*
478 command instead::
479
480   docker ps  # <check the container ID from the output>
481   docker exec -ti <CONTAINER_ID> /bin/bash
482
483 There are other useful Docker commands that might be needed to manage possible
484 issues with the containers.
485
486 List the running containers::
487
488   docker ps
489
490 List all the containers including the stopped ones::
491
492   docker ps -a
493
494 Start a stopped container named "FunTest"::
495
496   docker start FunTest
497
498 Attach to a running container named "StrikeTwo"::
499
500   docker attach StrikeTwo
501
502 It is useful sometimes to remove a container if there are some problems::
503
504   docker rm <CONTAINER_ID>
505
506 Use the *-f* option if the container is still running, it will force to
507 destroy it::
508
509   docker rm -f <CONTAINER_ID>
510
511 Check the Docker documentation dockerdocs_ for more information.
512
513 Preparing the Functest environment
514 ----------------------------------
515 Once the Functest docker container is up and running, the required
516 Functest environment needs to be prepared. A custom built **functest**
517 CLI utility is available to perform the needed environment preparation
518 action. Once the environment is prepared, the **functest** CLI utility
519 can be used to run different functional tests. The usage of the
520 **functest** CLI utility to run tests is described further in the
521 Functest User Guide `OPNFV_FuncTestUserGuide`_
522
523 Prior to commencing the Functest environment preparation, we can check
524 the initial status of the environment. Issue the **functest env status**
525 command at the prompt::
526
527   functest env status
528   Functest environment is not installed.
529
530   Note: When the Functest environment is prepared, the command will
531   return the status: "Functest environment ready to run tests."
532
533 To prepare the Functest docker container for test case execution, issue
534 the **functest env prepare** command at the prompt::
535
536   functest env prepare
537
538 This script will make sure that the requirements to run the tests are
539 met and will install the needed libraries and tools by all Functest
540 test cases. It should be run only once every time the Functest docker
541 container is started from scratch. If you try to run this command, on
542 an already prepared enviroment, you will be prompted whether you really
543 want to continue or not::
544
545   functest env prepare
546   It seems that the environment has been already prepared.
547   Do you want to do it again? [y|n]
548
549   (Type 'n' to abort the request, or 'y' to repeat the
550    environment preparation)
551
552
553 To list some basic information about an already prepared Functest
554 docker container environment, issue the **functest env show** at the
555 prompt::
556
557   functest env show
558   +======================================================+
559   | Functest Environment info                            |
560   +======================================================+
561   |  INSTALLER: apex, 192.168.122.89                     |
562   |   SCENARIO: os-odl_l2-nofeature-ha                   |
563   |        POD: localhost                                |
564   | GIT BRANCH: master                                   |
565   |   GIT HASH: 5bf1647dec6860464eeb082b2875798f0759aa91 |
566   | DEBUG FLAG: false                                    |
567   +------------------------------------------------------+
568   |     STATUS: ready                                    |
569   +------------------------------------------------------+
570
571   Where:
572
573   INSTALLER:  Displays the INSTALLER_TYPE value
574               - here = "apex"
575               and the INSTALLER_IP value
576               - here = "192.168.122.89"
577   SCENARIO:   Displays the DEPLOY_SCENARIO value
578               - here = "os-odl_l2-nofeature-ha"
579   POD:        Displays the value passed in NODE_NAME
580               - here = "localhost"
581   GIT BRANCH: Displays the git branch of the OPNFV Functest
582               project repository included in the Functest
583               Docker Container.
584               - here = "master"
585                        (In first official colorado release
586                         would be "colorado.1.0")
587   GIT HASH:   Displays the git hash of the OPNFV Functest
588               project repository included in the Functest
589               Docker Container.
590               - here = "5bf1647dec6860464eeb082b2875798f0759aa91"
591   DEBUG FLAG: Displays the CI_DEBUG value
592               - here = "false"
593
594   NOTE: In Jenkins CI runs, an additional item "BUILD TAG"
595         would also be listed. The value is set by Jenkins CI.
596
597 Finally, the **functest** CLI has a **--help** options:
598
599 Some examples::
600
601   functest --help Usage: functest [OPTIONS] COMMAND [ARGS]...
602
603   Options:
604     --version  Show the version and exit.
605     -h, --help Show this message and exit.
606
607   Commands:
608     env
609     openstack
610     testcase
611     tier
612
613   functest env --help
614   Usage: functest env [OPTIONS] COMMAND [ARGS]...
615
616   Options:
617     -h, --help Show this message and exit.
618
619   Commands:
620     prepare  Prepares the Functest environment.
621     show     Shows information about the current...
622     status   Checks if the Functest environment is ready...
623
624 Checking Openstack and credentials
625 ----------------------------------
626 It is recommended and fairly straightforward to check that Openstack
627 and credentials are working as expected.
628
629 Once the credentials are there inside the container, they should be
630 sourced before running any Openstack commands::
631
632   source /home/opnfv/functest/conf/openstack.creds
633
634 After this, try to run any OpenStack command to see if you get any
635 output, for instance::
636
637   openstack user list
638
639 This will return a list of the actual users in the OpenStack
640 deployment. In any other case, check that the credentials are sourced::
641
642   env|grep OS_
643
644 This command must show a set of environment variables starting with
645 *OS_*, for example::
646
647   OS_REGION_NAME=RegionOne
648   OS_DEFAULT_DOMAIN=default
649   OS_PROJECT_NAME=admin
650   OS_PASSWORD=admin
651   OS_AUTH_STRATEGY=keystone
652   OS_AUTH_URL=http://172.30.10.3:5000/v2.0
653   OS_USERNAME=admin
654   OS_TENANT_NAME=admin
655   OS_ENDPOINT_TYPE=internalURL
656   OS_NO_CACHE=true
657
658 If the OpenStack command still does not show anything or complains
659 about connectivity issues, it could be due to an incorrect url given to
660 the OS_AUTH_URL environment variable. Check the deployment settings.
661
662 SSL Support
663 -----------
664 If you need to connect to a server that is TLS-enabled (the auth URL
665 begins with "https") and it uses a certificate from a private CA or a
666 self-signed certificate, then you will need to specify the path to an
667 appropriate CA certificate to use, to validate the server certificate
668 with the environment variable OS_CACERT::
669
670   echo $OS_CACERT
671   /etc/ssl/certs/ca.crt
672
673 However, this certificate does not exist in the container by default.
674 It has to be copied manually from the OpenStack deployment. This can be
675 done in 2 ways:
676
677   #. Create manually that file and copy the contents from the OpenStack
678      controller.
679   #. (Recommended) Add the file using a Docker volume when starting the
680      container::
681
682        -v <path_to_your_cert_file>:/etc/ssl/certs/ca.cert
683
684 You might need to export OS_CACERT environment variable inside the
685 container::
686
687   export OS_CACERT=/etc/ssl/certs/ca.crt
688
689 Certificate verification can be turned off using OS_INSECURE=true. For
690 example, Fuel uses self-signed cacerts by default, so an pre step would
691 be::
692
693   export OS_INSECURE=true
694
695 Proxy support
696 -------------
697 If your Jumphost node is operating behind a http proxy, then there are
698 2 places where some special actions may be needed to make operations
699 succeed:
700
701   #. Initial installation of docker engine First, try following the
702      official Docker documentation for Proxy settings. Some issues were
703      experienced on CentOS 7 based Jumphost. Some tips are documented
704      in section: `Docker Installation on CentOS behind http proxy`_
705      below.
706
707   #. Execution of the Functest environment preparation inside the
708      created docker container Functest needs internet access to
709      download some resources for some test cases. This might not
710      work properly if the Jumphost is connecting to internet
711      through a http Proxy.
712
713 If that is the case, make sure the resolv.conf and the needed
714 http_proxy and https_proxy environment variables, as well as the
715 'no_proxy' environment variable are set correctly::
716
717   # Make double sure that the 'no_proxy=...' line in the
718   # 'openstack.creds' file is commented out first. Otherwise, the
719   # values set into the 'no_proxy' environment variable below will
720   # be ovewrwritten, each time the command
721   # 'source ~/functest/conf/openstack.creds' is issued.
722
723   cd ~/functest/conf/
724   sed -i 's/export no_proxy/#export no_proxy/' openstack.creds
725   source ./openstack.creds
726
727   # Next calculate some IP addresses for which http_proxy
728   # usage should be excluded:
729
730   publicURL_IP=$(echo $OS_AUTH_URL | grep -Eo "([0-9]+\.){3}[0-9]+")
731
732   adminURL_IP=$(openstack catalog show identity | \
733   grep adminURL | grep -Eo "([0-9]+\.){3}[0-9]+")
734
735   export http_proxy="<your http proxy settings>"
736   export https_proxy="<your https proxy settings>"
737   export no_proxy="127.0.0.1,localhost,$publicURL_IP,$adminURL_IP"
738
739   # Ensure that "git" uses the http_proxy
740   # This may be needed if your firewall forbids SSL based git fetch
741   git config --global http.sslVerify True
742   git config --global http.proxy <Your http proxy settings>
743
744 Validation check: Before running **'functest env prepare'** CLI command,
745 make sure you can reach http and https sites from inside the Functest
746 docker container.
747
748 For example, try to use the **nc** command from inside the functest
749 docker container::
750
751   nc -v opnfv.org 80
752   Connection to opnfv.org 80 port [tcp/http] succeeded!
753
754   nc -v opnfv.org 443
755   Connection to opnfv.org 443 port [tcp/https] succeeded!
756
757 Note: In a Jumphost node based on the CentOS family OS, the **nc**
758 commands might not work. You can use the **curl** command instead.
759
760   curl http://www.opnfv.org:80
761   <HTML><HEAD><meta http-equiv="content-type"
762   .
763   .
764   </BODY></HTML>
765
766   curl https://www.opnfv.org:443
767   <HTML><HEAD><meta http-equiv="content-type"
768   .
769   .
770   </BODY></HTML>
771
772   (Ignore the content. If command returns a valid HTML page, it proves
773   the connection.)
774
775 Docker Installation on CentOS behind http proxy
776 -----------------------------------------------
777 This section is applicable for CentOS family OS on Jumphost which
778 itself is behind a proxy server. In that case, the instructions below
779 should be followed **before** installing the docker engine::
780
781   1) # Make a directory '/etc/systemd/system/docker.service.d'
782      # if it does not exist
783      sudo mkdir /etc/systemd/system/docker.service.d
784
785   2) # Create a file called 'env.conf' in that directory with
786      # the following contents:
787      [Service]
788      EnvironmentFile=-/etc/sysconfig/docker
789
790   3) # Set up a file called 'docker' in directory '/etc/sysconfig'
791      # with the following contents:
792      HTTP_PROXY="<Your http proxy settings>"
793      HTTPS_PROXY="<Your https proxy settings>"
794      http_proxy="${HTTP_PROXY}"
795      https_proxy="${HTTPS_PROXY}"
796
797   4) # Reload the daemon
798      systemctl daemon-reload
799
800   5) # Sanity check - check the following docker settings:
801      systemctl show docker | grep -i env
802
803      Expected result:
804      ----------------
805      EnvironmentFile=/etc/sysconfig/docker (ignore_errors=yes)
806      DropInPaths=/etc/systemd/system/docker.service.d/env.conf
807
808 Now follow the instructions in [`InstallDockerCentOS`_] to download
809 and install the **docker-engine**. The instructions conclude with a
810 "test pull" of a sample "Hello World" docker container. This should now
811 work with the above pre-requisite actions.
812
813 .. _dockerdocs: https://docs.docker.com/
814 .. _dockerhub: https://hub.docker.com/r/opnfv/functest/
815 .. _Proxy: https://docs.docker.com/engine/admin/systemd/#http-proxy
816 .. _FunctestDockerTags: https://hub.docker.com/r/opnfv/functest/tags/
817 .. _InstallDockerCentOS: https://docs.docker.com/engine/installation/linux/centos/
818 .. _OPNFV_FuncTestUserGuide: http://artifacts.opnfv.org/functest/docs/userguide/index.html