1 .. This work is licensed under a Creative Commons Attribution 4.0 International
3 http://creativecommons.org/licenses/by/4.0
4 (c) OPNFV, Ericsson AB, Huawei Technologies Co.,Ltd and others.
7 Convention for heading levels in Yardstick documentation:
8 ======= Heading 0 (reserved for the title in a document)
14 Avoid deeper levels because they do not render well.
17 Convention for heading levels in Yardstick documentation:
19 ======= Heading 0 (reserved for the title in a document)
25 Avoid deeper levels because they do not render well.
27 ======================
28 Yardstick Installation
29 ======================
31 Yardstick supports installation by Docker or directly in Ubuntu. The
32 installation procedure for Docker and direct installation are detailed in
35 To use Yardstick you should have access to an OpenStack environment, with at
36 least Nova, Neutron, Glance, Keystone and Heat installed.
38 The steps needed to run Yardstick are:
41 2. Load OpenStack environment variables.
42 3. Create Yardstick flavor.
43 4. Build a guest image and load it into the OpenStack environment.
44 5. Create the test configuration ``.yaml`` file and run the test case/suite.
50 The OPNFV deployment is out of the scope of this document and can be found in
51 `User Guide & Configuration Guide`_. The OPNFV platform is considered as the
52 System Under Test (SUT) in this document.
54 Several prerequisites are needed for Yardstick:
56 1. A Jumphost to run Yardstick on
57 2. A Docker daemon or a virtual environment installed on the Jumphost
58 3. A public/external network created on the SUT
59 4. Connectivity from the Jumphost to the SUT public/external network
61 .. note:: *Jumphost* refers to any server which meets the previous
62 requirements. Normally it is the same server from where the OPNFV
63 deployment has been triggered.
65 .. warning:: Connectivity from Jumphost is essential and it is of paramount
66 importance to make sure it is working before even considering to install
67 and run Yardstick. Make also sure you understand how your networking is
70 .. note:: If your Jumphost is operating behind a company http proxy and/or
71 Firewall, please first consult `Proxy Support`_ section which is towards
72 the end of this document. That section details some tips/tricks which *may*
73 be of help in a proxified environment.
76 Install Yardstick using Docker (first option) (**recommended**)
77 ---------------------------------------------------------------
79 Yardstick has a Docker image. It is recommended to use this Docker image to run
82 Prepare the Yardstick container
83 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
85 Install docker on your guest system with the following command, if not done
88 wget -qO- https://get.docker.com/ | sh
90 Pull the Yardstick Docker image (``opnfv/yardstick``) from the public dockerhub
91 registry under the OPNFV account in dockerhub_, with the following docker
94 sudo -EH docker pull opnfv/yardstick:stable
96 After pulling the Docker image, check that it is available with the
97 following docker command::
99 [yardsticker@jumphost ~]$ docker images
100 REPOSITORY TAG IMAGE ID CREATED SIZE
101 opnfv/yardstick stable a4501714757a 1 day ago 915.4 MB
103 Run the Docker image to get a Yardstick container::
105 docker run -itd --privileged -v /var/run/docker.sock:/var/run/docker.sock \
106 -p 8888:5000 --name yardstick opnfv/yardstick:stable
108 Description of the parameters used with ``docker run`` command
110 +------------------------+--------------------------------------------------+
111 | Parameters | Detail |
112 +========================+==================================================+
113 | -itd | -i: interactive, Keep STDIN open even if not |
115 | +--------------------------------------------------+
116 | | -t: allocate a pseudo-TTY detached mode, in the |
118 +------------------------+--------------------------------------------------+
119 | --privileged | If you want to build ``yardstick-image`` in |
120 | | Yardstick container, this parameter is needed |
121 +------------------------+--------------------------------------------------+
122 | -p 8888:5000 | Redirect the a host port (8888) to a container |
124 +------------------------+--------------------------------------------------+
125 | -v /var/run/docker.sock| If you want to use yardstick env |
126 | :/var/run/docker.sock | grafana/influxdb to create a grafana/influxdb |
127 | | container out of Yardstick container |
128 +------------------------+--------------------------------------------------+
129 | --name yardstick | The name for this container |
130 +------------------------+--------------------------------------------------+
133 If the host is restarted
134 ^^^^^^^^^^^^^^^^^^^^^^^^
136 The yardstick container must be started if the host is rebooted::
138 docker start yardstick
140 Configure the Yardstick container environment
141 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
143 There are three ways to configure environments for running Yardstick, explained
144 in the following sections. Before that, access the Yardstick container::
146 docker exec -it yardstick /bin/bash
148 and then configure Yardstick environments in the Yardstick container.
150 Using the CLI command ``env prepare`` (first way) (**recommended**)
151 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
153 In the Yardstick container, the Yardstick repository is located in the
154 ``/home/opnfv/repos`` directory. Yardstick provides a CLI to prepare OpenStack
155 environment variables and create Yardstick flavor and guest images
158 yardstick env prepare
160 .. note:: Since Euphrates release, the above command will not be able to
161 automatically configure the ``/etc/yardstick/openstack.creds`` file. So before
162 running the above command, it is necessary to create the
163 ``/etc/yardstick/openstack.creds`` file and save OpenStack environment
164 variables into it manually. If you have the openstack credential file saved
165 outside the Yardstick Docker container, you can do this easily by mapping the
166 credential file into Yardstick container using::
168 '-v /path/to/credential_file:/etc/yardstick/openstack.creds'
170 when running the Yardstick container. For details of the required OpenStack
171 environment variables please refer to section `Export OpenStack environment
174 The ``env prepare`` command may take up to 6-8 minutes to finish building
175 yardstick-image and other environment preparation. Meanwhile if you wish to
176 monitor the env prepare process, you can enter the Yardstick container in a new
177 terminal window and execute the following command::
179 tail -f /var/log/yardstick/uwsgi.log
182 Manually exporting the env variables and initializing OpenStack (second way)
183 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
185 Export OpenStack environment variables
186 ''''''''''''''''''''''''''''''''''''''
188 Before running Yardstick it is necessary to export OpenStack environment
193 Environment variables in the ``openrc`` file have to include at least::
201 A sample ``openrc`` file may look like this::
203 export OS_PASSWORD=console
204 export OS_PROJECT_NAME=admin
205 export OS_AUTH_URL=http://172.16.1.222:35357/v2.0
206 export OS_USERNAME=admin
207 export OS_VOLUME_API_VERSION=2
208 export EXTERNAL_NETWORK=net04_ext
211 Manual creation of Yardstick flavor and guest images
212 ''''''''''''''''''''''''''''''''''''''''''''''''''''
214 Before executing Yardstick test cases, make sure that Yardstick flavor and
215 guest image are available in OpenStack. Detailed steps about creating the
216 Yardstick flavor and building the Yardstick guest image can be found below.
218 Most of the sample test cases in Yardstick are using an OpenStack flavor called
219 ``yardstick-flavor`` which deviates from the OpenStack standard ``m1.tiny``
220 flavor by the disk size; instead of 1GB it has 3GB. Other parameters are the
221 same as in ``m1.tiny``.
223 Create ``yardstick-flavor``::
225 openstack flavor create --disk 3 --vcpus 1 --ram 512 --swap 100 \
228 Most of the sample test cases in Yardstick are using a guest image called
229 ``yardstick-image`` which deviates from an Ubuntu Cloud Server image
230 containing all the required tools to run test cases supported by Yardstick.
231 Yardstick has a tool for building this custom image. It is necessary to have
232 ``sudo`` rights to use this tool.
234 Also you may need install several additional packages to use this tool, by
235 follwing the commands below::
237 sudo -EH apt-get update && sudo -EH apt-get install -y qemu-utils kpartx
239 This image can be built using the following command in the directory where
240 Yardstick is installed::
242 export YARD_IMG_ARCH='amd64'
243 echo "Defaults env_keep += \'YARD_IMG_ARCH\'" | sudo tee --append \
244 /etc/sudoers > /dev/null
245 sudo -EH tools/yardstick-img-modify tools/ubuntu-server-cloudimg-modify.sh
247 .. warning:: Before building the guest image inside the Yardstick container,
248 make sure the container is granted with privilege. The script will create files
249 by default in ``/tmp/workspace/yardstick`` and the files will be owned by root.
251 The created image can be added to OpenStack using the OpenStack client or via
252 the OpenStack Dashboard::
254 openstack image create --disk-format qcow2 --container-format bare \
255 --public --file /tmp/workspace/yardstick/yardstick-image.img \
259 Some Yardstick test cases use a `Cirros 0.3.5`_ image and/or a `Ubuntu 16.04`_
260 image. Add Cirros and Ubuntu images to OpenStack::
262 openstack image create --disk-format qcow2 --container-format bare \
263 --public --file $cirros_image_file cirros-0.3.5
264 openstack image create --disk-format qcow2 --container-format bare \
265 --file $ubuntu_image_file Ubuntu-16.04
268 Automatic initialization of OpenStack (third way)
269 +++++++++++++++++++++++++++++++++++++++++++++++++
271 Similar to the second way, the first step is also to
272 `Export OpenStack environment variables`_. Then the following steps should be
275 Automatic creation of Yardstick flavor and guest images
276 '''''''''''''''''''''''''''''''''''''''''''''''''''''''
278 Yardstick has a script for automatically creating Yardstick flavor and building
279 Yardstick guest images. This script is mainly used for CI and can be also used
280 in the local environment::
282 source $YARDSTICK_REPO_DIR/tests/ci/load_images.sh
285 The Yardstick container GUI
286 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
288 In Euphrates release, Yardstick implemented a GUI for Yardstick Docker
289 container. After booting up Yardstick container, you can visit the GUI at
290 ``<container_host_ip>:8888/gui/index.html``.
292 For usage of Yardstick GUI, please watch our demo video at
293 `Yardstick GUI demo`_.
295 .. note:: The Yardstick GUI is still in development, the GUI layout and
298 Delete the Yardstick container
299 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
301 If you want to uninstall Yardstick, just delete the Yardstick container::
303 sudo docker stop yardstick && docker rm yardstick
307 Install Yardstick directly in Ubuntu (second option)
308 ----------------------------------------------------
310 .. _install-framework:
312 Alternatively you can install Yardstick framework directly in Ubuntu or in an
313 Ubuntu Docker image. No matter which way you choose to install Yardstick, the
314 following installation steps are identical.
316 If you choose to use the Ubuntu Docker image, you can pull the Ubuntu
317 Docker image from Docker hub::
319 sudo -EH docker pull ubuntu:16.04
325 Prerequisite preparation::
327 sudo -EH apt-get update && sudo -EH apt-get install -y \
328 git python-setuptools python-pip
329 sudo -EH easy_install -U setuptools==30.0.0
330 sudo -EH pip install appdirs==1.4.0
331 sudo -EH pip install virtualenv
333 Download the source code and install Yardstick from it::
335 git clone https://gerrit.opnfv.org/gerrit/yardstick
336 export YARDSTICK_REPO_DIR=~/yardstick
338 sudo -EH ./install.sh
340 If the host is ever restarted, nginx and uwsgi need to be restarted::
342 service nginx restart
343 uwsgi -i /etc/yardstick/yardstick.ini
345 Configure the Yardstick environment (**Todo**)
346 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
348 For installing Yardstick directly in Ubuntu, the ``yardstick env`` command is
349 not available. You need to prepare OpenStack environment variables and create
350 Yardstick flavor and guest images manually.
355 For uninstalling Yardstick, just delete the virtual environment::
357 rm -rf ~/yardstick_venv
360 Install Yardstick directly in OpenSUSE
361 --------------------------------------
363 .. _install-framework:
365 You can install Yardstick framework directly in OpenSUSE.
371 Prerequisite preparation::
373 sudo -EH zypper -n install -y gcc \
386 python-setuptools-git
388 Create a virtual environment::
390 virtualenv ~/yardstick_venv
391 export YARDSTICK_VENV=~/yardstick_venv
392 source ~/yardstick_venv/bin/activate
393 sudo -EH easy_install -U setuptools
395 Download the source code and install Yardstick from it::
397 git clone https://gerrit.opnfv.org/gerrit/yardstick
398 export YARDSTICK_REPO_DIR=~/yardstick
400 sudo -EH python setup.py install
401 sudo -EH pip install -r requirements.txt
403 Install missing python modules::
405 sudo -EH pip install pyyaml \
412 python.glanceclient \
413 python.neutronclient \
418 Configure the Yardstick environment
419 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
421 Source the OpenStack environment variables::
423 source DEVSTACK_DIRECTORY/openrc
425 Export the Openstack external network. The default installation of Devstack
426 names the external network public::
428 export EXTERNAL_NETWORK=public
429 export OS_USERNAME=demo
431 Change the API version used by Yardstick to v2.0 (the devstack openrc sets it
434 export OS_AUTH_URL=http://PUBLIC_IP_ADDRESS:5000/v2.0
440 For unistalling Yardstick, just delete the virtual environment::
442 rm -rf ~/yardstick_venv
445 Verify the installation
446 -----------------------
448 It is recommended to verify that Yardstick was installed successfully
449 by executing some simple commands and test samples. Before executing Yardstick
450 test cases make sure ``yardstick-flavor`` and ``yardstick-image`` can be found
451 in OpenStack and the ``openrc`` file is sourced. Below is an example invocation
452 of Yardstick ``help`` command and ``ping.py`` test sample::
455 yardstick task start samples/ping.yaml
457 .. note:: The above commands could be run in both the Yardstick container and
460 Each testing tool supported by Yardstick has a sample configuration file.
461 These configuration files can be found in the ``samples`` directory.
463 Default location for the output is ``/tmp/yardstick.out``.
466 Automatic installation of Yardstick
467 -----------------------------------
469 Automatic installation can be used as an alternative to the manual by
470 providing parameters for ansible script ``install.yaml`` in a ``nsb_setup.sh``
471 file. Yardstick can be installed on the bare metal and to the container. Yardstick
472 container can be either pulled or built.
474 Bare metal installation
475 ^^^^^^^^^^^^^^^^^^^^^^^
477 Modify ``nsb_setup.sh`` file ``install.yaml`` parameters to install Yardstick
480 .. code-block:: console
482 ansible-playbook -i install-inventory.ini install.yaml \
483 -e IMAGE_PROPERTY='none' \
484 -e YARDSTICK_DIR=<path to Yardstick folder>
486 .. note:: By default ``INSTALLATION_MODE`` is ``baremetal``.
488 .. note:: No modification in ``install-inventory.ini`` is needed for Yardstick
491 .. note:: To install Yardstick in virtual environment pass parameter
492 ``-e VIRTUAL_ENVIRONMENT=True``.
494 Container installation
495 ^^^^^^^^^^^^^^^^^^^^^^
497 Modify ``install.yaml`` parameters in ``nsb_setup.sh`` file to pull or build
498 Yardstick container. To pull Yardstick image and start container run:
500 .. code-block:: console
502 ansible-playbook -i install-inventory.ini install.yaml \
503 -e IMAGE_PROPERTY='none' \
504 -e INSTALLATION_MODE=container_pull
506 .. note:: Yardstick docker image is available for both Ubuntu 16.04 and Ubuntu
507 18.04. By default Ubuntu 16.04 based docker image is used. To use
508 Ubuntu 18.04 based docker image pass ``-i opnfv/yardstick-ubuntu-18.04``
509 parameter to ``nsb_setup.sh``.
511 To build Yardstick image modify Dockerfile as per comments in it and run:
513 .. code-block:: console
516 docker build -f docker/Dockerfile -t opnfv/yardstick:<tag> .
518 .. note:: Yardstick docker image based on Ubuntu 16.04 will be built.
519 Pass ``-f docker/Dockerfile_ubuntu18`` to build Yardstick docker image based
522 .. note:: Add ``--build-arg http_proxy=http://<proxy_host>:<proxy_port>`` to
523 build docker image if server is behind the proxy.
525 Parameters for ``install.yaml``
526 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
528 Description of the parameters used with ``install.yaml``:
530 +-------------------------+-------------------------------------------------+
531 | Parameters | Detail |
532 +=========================+=================================================+
533 | -i install-inventory.ini|| Installs package dependency to remote servers |
535 | || Mandatory parameter |
536 | || By default no remote servers are provided |
537 +-------------------------+-------------------------------------------------+
538 | -e YARDSTICK_DIR || Path to Yardstick folder |
539 | || Mandatory parameter for Yardstick bare metal |
541 +-------------------------+-------------------------------------------------+
542 | -e INSTALLATION_MODE || baremetal: Yardstick is installed to the bare |
544 | || Default parameter |
545 | +-------------------------------------------------+
546 | || container: Yardstick is installed in container |
547 | || Container is built from Dockerfile |
548 | +-------------------------------------------------+
549 | || container_pull: Yardstick is installed in |
551 | || Container is pulled from docker hub |
552 +-------------------------+-------------------------------------------------+
553 | -e OS_RELEASE || xenial or bionic: Ubuntu version to be used for|
554 | || VM image (nsb or normal) |
555 | || Default is Ubuntu 16.04, xenial |
556 +-------------------------+-------------------------------------------------+
557 | -e IMAGE_PROPERTY || nsb: Build Yardstick NSB VM image |
558 | || Used to run Yardstick NSB tests on sample VNF |
559 | || Default parameter |
560 | +-------------------------------------------------+
561 | || normal: Build VM image to run ping test in |
563 | +-------------------------------------------------+
564 | || none: don't build a VM image. |
565 +-------------------------+-------------------------------------------------+
566 | -e VIRTUAL_ENVIRONMENT || False or True: Whether install in virtualenv |
567 | || Default is False |
568 +-------------------------+-------------------------------------------------+
569 | -e YARD_IMAGE_ARCH || CPU architecture on servers |
570 | || Default is 'amd64' |
571 +-------------------------+-------------------------------------------------+
574 Deploy InfluxDB and Grafana using Docker
575 ----------------------------------------
577 Without InfluxDB, Yardstick stores results for running test case in the file
578 ``/tmp/yardstick.out``. However, it's inconvenient to retrieve and display
579 test results. So we will show how to use InfluxDB to store data and use
580 Grafana to display data in the following sections.
582 Automatic deployment of InfluxDB and Grafana containers (**recommended**)
583 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
585 1. Enter the Yardstick container::
587 sudo -EH docker exec -it yardstick /bin/bash
589 2. Create InfluxDB container and configure with the following command::
591 yardstick env influxdb
593 3. Create and configure Grafana container::
595 yardstick env grafana
597 Then you can run a test case and visit http://host_ip:1948
598 (``admin``/``admin``) to see the results.
600 .. note:: Executing ``yardstick env`` command to deploy InfluxDB and Grafana
601 requires Jumphost's docker API version => 1.24. Run the following command to
602 check the docker API version on the Jumphost::
607 Manual deployment of InfluxDB and Grafana containers
608 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
610 You can also deploy influxDB and Grafana containers manually on the Jumphost.
611 The following sections show how to do.
615 sudo -EH docker pull tutum/influxdb
616 sudo -EH docker pull grafana/grafana
620 sudo -EH docker run -d --name influxdb \
621 -p 8083:8083 -p 8086:8086 --expose 8090 --expose 8099 \
626 docker exec -it influxdb influx
627 > CREATE USER root WITH PASSWORD 'root' WITH ALL PRIVILEGES
628 > CREATE DATABASE yardstick;
635 sudo -EH docker run -d --name grafana -p 1948:3000 grafana/grafana
637 Log on to ``http://{YOUR_IP_HERE}:1948`` using ``admin``/``admin`` and configure
638 database resource to be ``{YOUR_IP_HERE}:8086``.
640 .. image:: images/Grafana_config.png
642 :alt: Grafana data source configuration
644 Configure ``yardstick.conf``::
646 sudo -EH docker exec -it yardstick /bin/bash
647 sudo cp etc/yardstick/yardstick.conf.sample /etc/yardstick/yardstick.conf
648 sudo vi /etc/yardstick/yardstick.conf
650 Modify ``yardstick.conf`` to add the ``influxdb`` dispatcher::
654 dispatcher = influxdb
656 [dispatcher_influxdb]
658 target = http://{YOUR_IP_HERE}:8086
663 Now Yardstick will store results in InfluxDB when you run a testcase.
665 Deploy InfluxDB and Grafana directly in Ubuntu (**Todo**)
666 ---------------------------------------------------------
671 To configure the Jumphost to access Internet through a proxy its necessary to
672 export several variables to the environment, contained in the following
676 _proxy=<proxy_address>
677 _proxyport=<proxy_port>
678 _ip=$(hostname -I | awk '{print $1}')
680 export ftp_proxy=http://$_proxy:$_proxyport
681 export FTP_PROXY=http://$_proxy:$_proxyport
682 export http_proxy=http://$_proxy:$_proxyport
683 export HTTP_PROXY=http://$_proxy:$_proxyport
684 export https_proxy=http://$_proxy:$_proxyport
685 export HTTPS_PROXY=http://$_proxy:$_proxyport
686 export no_proxy=127.0.0.1,localhost,$_ip,$(hostname),<.localdomain>
687 export NO_PROXY=127.0.0.1,localhost,$_ip,$(hostname),<.localdomain>
689 To enable Internet access from a container using ``docker``, depends on the OS
690 version. On Ubuntu 14.04 LTS, which uses SysVinit, ``/etc/default/docker`` must
694 # If you need Docker to use an HTTP proxy, it can also be specified here.
695 export http_proxy="http://<proxy_address>:<proxy_port>/"
696 export https_proxy="https://<proxy_address>:<proxy_port>/"
698 Then its necessary to restart the ``docker`` service::
700 sudo -EH service docker restart
702 In Ubuntu 16.04 LTS, which uses Systemd, its necessary to create a drop-in
705 sudo mkdir /etc/systemd/system/docker.service.d
707 Then, the proxy configuration will be stored in the following file::
709 # cat /etc/systemd/system/docker.service.d/http-proxy.conf
711 Environment="HTTP_PROXY=https://<proxy_address>:<proxy_port>/"
712 Environment="HTTPS_PROXY=https://<proxy_address>:<proxy_port>/"
713 Environment="NO_PROXY=localhost,127.0.0.1,<localaddress>,<.localdomain>"
715 The changes need to be flushed and the ``docker`` service restarted::
717 sudo systemctl daemon-reload
718 sudo systemctl restart docker
720 Any container is already created won't contain these modifications. If needed,
721 stop and delete the container::
723 sudo docker stop yardstick
724 sudo docker rm yardstick
726 .. warning:: Be careful, the above ``rm`` command will delete the container
727 completely. Everything on this container will be lost.
729 Then follow the previous instructions `Prepare the Yardstick container`_ to
730 rebuild the Yardstick container.
736 .. _`User Guide & Configuration Guide`: http://docs.opnfv.org/en/latest/release/userguide.introduction.html
737 .. _dockerhub: https://hub.docker.com/r/opnfv/yardstick/
738 .. _`Cirros 0.3.5`: http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
739 .. _`Ubuntu 16.04`: https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img
740 .. _`Yardstick GUI demo`: https://www.youtube.com/watch?v=M3qbJDp6QBk