Merge "Add extra check to avoid double delete of instances"
[functest.git] / docs / testing / user / configguide / configguide.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/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 Colorado system platform,
20 tag "colorado.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        $REPOS_DIR/releng/utils/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 datbase
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             |-- ovno
337             |-- parser
338             |-- promise
339             |-- rally
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_base.py
410         |   |-- pytest_suite_runner.py
411         |   |-- testcase_base.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. Test results
449   are also located in a sub--directory called 'results'.
450 * **functest**: This directory contains all the code needed to run
451   functest internal cases and OPNFV onboarded feature or VNF test cases.
452
453 Functest directory has 6 directories:
454   * **ci**: This directory contains test structure definition files
455     (e.g <filename>.yaml) and bash shell/python scripts used to
456     configure and execute Functional tests. The test execution script
457     can be executed under the control of Jenkins CI jobs.
458   * **cli**: This directory holds the python based Functest CLI utility
459     source code, which is based on the Python 'click' framework.
460   * **core**: This directory holds the python based Functest core
461       source code. Three abstraction classes have been created to ease
462       the integration of internal, feature or vnf cases.
463   * **opnfv_tests**: This directory includes the scripts required by
464     Functest internal test cases and other feature projects test cases.
465   * **tests**: This directory includes the functest unit tests
466   * **utils**: this directory holds Python source code for some general
467     purpose helper utilities, which testers can also re-use in their
468     own test code. See for an example the Openstack helper utility:
469     'openstack_utils.py'.
470
471 Useful Docker commands
472 ----------------------
473 When typing **exit** in the container prompt, this will cause exiting
474 the container and probably stopping it. When stopping a running Docker
475 container all the changes will be lost, there is a keyboard shortcut
476 to quit the container without stopping it: <CTRL>-P + <CTRL>-Q. To
477 reconnect to the running container **DO NOT** use the *run* command
478 again (since it will create a new container), use the *exec* or *attach*
479 command instead::
480
481   docker ps  # <check the container ID from the output>
482   docker exec -ti <CONTAINER_ID> /bin/bash
483
484 There are other useful Docker commands that might be needed to manage possible
485 issues with the containers.
486
487 List the running containers::
488
489   docker ps
490
491 List all the containers including the stopped ones::
492
493   docker ps -a
494
495 Start a stopped container named "FunTest"::
496
497   docker start FunTest
498
499 Attach to a running container named "StrikeTwo"::
500
501   docker attach StrikeTwo
502
503 It is useful sometimes to remove a container if there are some problems::
504
505   docker rm <CONTAINER_ID>
506
507 Use the *-f* option if the container is still running, it will force to
508 destroy it::
509
510   docker rm -f <CONTAINER_ID>
511
512 Check the Docker documentation dockerdocs_ for more information.
513
514 Preparing the Functest environment
515 ----------------------------------
516 Once the Functest docker container is up and running, the required
517 Functest environment needs to be prepared. A custom built **functest**
518 CLI utility is available to perform the needed environment preparation
519 action. Once the environment is prepared, the **functest** CLI utility
520 can be used to run different functional tests. The usage of the
521 **functest** CLI utility to run tests is described further in the
522 Functest User Guide `OPNFV_FuncTestUserGuide`_
523
524 Prior to commencing the Functest environment preparation, we can check
525 the initial status of the environment. Issue the **functest env status**
526 command at the prompt::
527
528   functest env status
529   Functest environment is not installed.
530
531   Note: When the Functest environment is prepared, the command will
532   return the status: "Functest environment ready to run tests."
533
534 To prepare the Functest docker container for test case execution, issue
535 the **functest env prepare** command at the prompt::
536
537   functest env prepare
538
539 This script will make sure that the requirements to run the tests are
540 met and will install the needed libraries and tools by all Functest
541 test cases. It should be run only once every time the Functest docker
542 container is started from scratch. If you try to run this command, on
543 an already prepared enviroment, you will be prompted whether you really
544 want to continue or not::
545
546   functest env prepare
547   It seems that the environment has been already prepared.
548   Do you want to do it again? [y|n]
549
550   (Type 'n' to abort the request, or 'y' to repeat the
551    environment preparation)
552
553
554 To list some basic information about an already prepared Functest
555 docker container environment, issue the **functest env show** at the
556 prompt::
557
558   functest env show
559   +======================================================+
560   | Functest Environment info                            |
561   +======================================================+
562   |  INSTALLER: apex, 192.168.122.89                     |
563   |   SCENARIO: os-odl_l2-nofeature-ha                   |
564   |        POD: localhost                                |
565   | GIT BRANCH: master                                   |
566   |   GIT HASH: 5bf1647dec6860464eeb082b2875798f0759aa91 |
567   | DEBUG FLAG: false                                    |
568   +------------------------------------------------------+
569   |     STATUS: ready                                    |
570   +------------------------------------------------------+
571
572   Where:
573
574   INSTALLER:  Displays the INSTALLER_TYPE value
575               - here = "apex"
576               and the INSTALLER_IP value
577               - here = "192.168.122.89"
578   SCENARIO:   Displays the DEPLOY_SCENARIO value
579               - here = "os-odl_l2-nofeature-ha"
580   POD:        Displays the value passed in NODE_NAME
581               - here = "localhost"
582   GIT BRANCH: Displays the git branch of the OPNFV Functest
583               project repository included in the Functest
584               Docker Container.
585               - here = "master"
586                        (In first official colorado release
587                         would be "colorado.1.0")
588   GIT HASH:   Displays the git hash of the OPNFV Functest
589               project repository included in the Functest
590               Docker Container.
591               - here = "5bf1647dec6860464eeb082b2875798f0759aa91"
592   DEBUG FLAG: Displays the CI_DEBUG value
593               - here = "false"
594
595   NOTE: In Jenkins CI runs, an additional item "BUILD TAG"
596         would also be listed. The valaue is set by Jenkins CI.
597
598 Finally, the **functest** CLI has a **--help** options:
599
600 Some examples::
601
602   functest --help Usage: functest [OPTIONS] COMMAND [ARGS]...
603
604   Options:
605     --version  Show the version and exit.
606     -h, --help Show this message and exit.
607
608   Commands:
609     env
610     openstack
611     testcase
612     tier
613
614   functest env --help
615   Usage: functest env [OPTIONS] COMMAND [ARGS]...
616
617   Options:
618     -h, --help Show this message and exit.
619
620   Commands:
621     prepare  Prepares the Functest environment.
622     show     Shows information about the current...
623     status   Checks if the Functest environment is ready...
624
625 Checking Openstack and credentials
626 ----------------------------------
627 It is recommended and fairly straightforward to check that Openstack
628 and credentials are working as expected.
629
630 Once the credentials are there inside the container, they should be
631 sourced before running any Openstack commands::
632
633   source /home/opnfv/functest/conf/openstack.creds
634
635 After this, try to run any OpenStack command to see if you get any
636 output, for instance::
637
638   openstack user list
639
640 This will return a list of the actual users in the OpenStack
641 deployment. In any other case, check that the credentials are sourced::
642
643   env|grep OS_
644
645 This command must show a set of environment variables starting with
646 *OS_*, for example::
647
648   OS_REGION_NAME=RegionOne
649   OS_DEFAULT_DOMAIN=default
650   OS_PROJECT_NAME=admin
651   OS_PASSWORD=admin
652   OS_AUTH_STRATEGY=keystone
653   OS_AUTH_URL=http://172.30.10.3:5000/v2.0
654   OS_USERNAME=admin
655   OS_TENANT_NAME=admin
656   OS_ENDPOINT_TYPE=internalURL
657   OS_NO_CACHE=true
658
659 If the OpenStack command still does not show anything or complains
660 about connectivity issues, it could be due to an incorrect url given to
661 the OS_AUTH_URL environment variable. Check the deployment settings.
662
663 SSL Support
664 -----------
665 If you need to connect to a server that is TLS-enabled (the auth URL
666 begins with "https") and it uses a certificate from a private CA or a
667 self-signed certificate, then you will need to specify the path to an
668 appropriate CA certificate to use, to validate the server certificate
669 with the environment variable OS_CACERT::
670
671   echo $OS_CACERT
672   /etc/ssl/certs/ca.crt
673
674 However, this certificate does not exist in the container by default.
675 It has to be copied manually from the OpenStack deployment. This can be
676 done in 2 ways:
677
678   #. Create manually that file and copy the contents from the OpenStack
679      controller.
680   #. (Recommended) Add the file using a Docker volume when starting the
681      container::
682
683        -v <path_to_your_cert_file>:/etc/ssl/certs/ca.cert
684
685 You might need to export OS_CACERT environment variable inside the
686 container::
687
688   export OS_CACERT=/etc/ssl/certs/ca.crt
689
690 Certificate verification can be turned off using OS_INSECURE=true. For
691 example, Fuel uses self-signed cacerts by default, so an pre step would
692 be::
693
694   export OS_INSECURE=true
695
696 Proxy support
697 -------------
698 If your Jumphost node is operating behind a http proxy, then there are
699 2 places where some special actions may be needed to make operations
700 succeed:
701
702   #. Initial installation of docker engine First, try following the
703      official Docker documentation for Proxy settings. Some issues were
704      experienced on CentOS 7 based Jumphost. Some tips are documented
705      in section: `Docker Installation on CentOS behind http proxy`_
706      below.
707
708   #. Execution of the Functest environment preparation inside the
709      created docker container Functest needs internet access to
710      download some resources for some test cases. This might not
711      work properly if the Jumphost is connecting to internet
712      through a http Proxy.
713
714 If that is the case, make sure the resolv.conf and the needed
715 http_proxy and https_proxy environment variables, as well as the
716 'no_proxy' environment variable are set correctly::
717
718   # Make double sure that the 'no_proxy=...' line in the
719   # 'openstack.creds' file is commented out first. Otherwise, the
720   # values set into the 'no_proxy' environment variable below will
721   # be ovewrwritten, each time the command
722   # 'source ~/functest/conf/openstack.creds' is issued.
723
724   cd ~/functest/conf/
725   sed -i 's/export no_proxy/#export no_proxy/' openstack.creds
726   source ./openstack.creds
727
728   # Next calculate some IP addresses for which http_proxy
729   # usage should be excluded:
730
731   publicURL_IP=$(echo $OS_AUTH_URL | grep -Eo "([0-9]+\.){3}[0-9]+")
732
733   adminURL_IP=$(openstack catalog show identity | \
734   grep adminURL | grep -Eo "([0-9]+\.){3}[0-9]+")
735
736   export http_proxy="<your http proxy settings>"
737   export https_proxy="<your https proxy settings>"
738   export no_proxy="127.0.0.1,localhost,$publicURL_IP,$adminURL_IP"
739
740   # Ensure that "git" uses the http_proxy
741   # This may be needed if your firewall forbids SSL based git fetch
742   git config --global http.sslVerify True
743   git config --global http.proxy <Your http proxy settings>
744
745 Validation check: Before running **'functest env prepare'** CLI command,
746 make sure you can reach http and https sites from inside the Functest
747 docker container.
748
749 For example, try to use the **nc** command from inside the functest
750 docker container::
751
752   nc -v opnfv.org 80
753   Connection to opnfv.org 80 port [tcp/http] succeeded!
754
755   nc -v opnfv.org 443
756   Connection to opnfv.org 443 port [tcp/https] succeeded!
757
758 Note: In a Jumphost node based on the CentOS family OS, the **nc**
759 commands might not work. You can use the **curl** command instead.
760
761   curl http://www.opnfv.org:80
762   <HTML><HEAD><meta http-equiv="content-type"
763   .
764   .
765   </BODY></HTML>
766
767   curl https://www.opnfv.org:443
768   <HTML><HEAD><meta http-equiv="content-type"
769   .
770   .
771   </BODY></HTML>
772
773   (Ignore the content. If command returns a valid HTML page, it proves
774   the connection.)
775
776 Docker Installation on CentOS behind http proxy
777 -----------------------------------------------
778 This section is applicable for CentOS family OS on Jumphost which
779 itself is behind a proxy server. In that case, the instructions below
780 should be followed **before** installing the docker engine::
781
782   1) # Make a directory '/etc/systemd/system/docker.service.d'
783      # if it does not exist
784      sudo mkdir /etc/systemd/system/docker.service.d
785
786   2) # Create a file called 'env.conf' in that directory with
787      # the following contents:
788      [Service]
789      EnvironmentFile=-/etc/sysconfig/docker
790
791   3) # Set up a file called 'docker' in directory '/etc/sysconfig'
792      # with the following contents:
793      HTTP_PROXY="<Your http proxy settings>"
794      HTTPS_PROXY="<Your https proxy settings>"
795      http_proxy="${HTTP_PROXY}"
796      https_proxy="${HTTPS_PROXY}"
797
798   4) # Reload the daemon
799      systemctl daemon-reload
800
801   5) # Sanity check - check the following docker settings:
802      systemctl show docker | grep -i env
803
804      Expected result:
805      ----------------
806      EnvironmentFile=/etc/sysconfig/docker (ignore_errors=yes)
807      DropInPaths=/etc/systemd/system/docker.service.d/env.conf
808
809 Now follow the instructions in [`InstallDockerCentOS`_] to download
810 and install the **docker-engine**. The instructions conclude with a
811 "test pull" of a sample "Hello World" docker container. This should now
812 work with the above pre-requisite actions.
813
814 .. _dockerdocs: https://docs.docker.com/
815 .. _dockerhub: https://hub.docker.com/r/opnfv/functest/
816 .. _Proxy: https://docs.docker.com/engine/admin/systemd/#http-proxy
817 .. _FunctestDockerTags: https://hub.docker.com/r/opnfv/functest/tags/
818 .. _InstallDockerCentOS: https://docs.docker.com/engine/installation/linux/centos/
819 .. _OPNFV_FuncTestUserGuide: http://artifacts.opnfv.org/functest/docs/userguide/index.html