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.
13 Yardstick supports installation by Docker or directly in Ubuntu. The
14 installation procedure for Docker and direct installation are detailed in
17 To use Yardstick you should have access to an OpenStack environment, with at
18 least Nova, Neutron, Glance, Keystone and Heat installed.
20 The steps needed to run Yardstick are:
23 2. Load OpenStack environment variables.
24 #. Create Yardstick flavor.
25 #. Build a guest image and load it into the OpenStack environment.
26 #. Create the test configuration ``.yaml`` file and run the test case/suite.
32 The OPNFV deployment is out of the scope of this document and can be found `here <http://artifacts.opnfv.org/opnfvdocs/colorado/docs/configguide/index.html>`_. The OPNFV platform is considered as the System Under Test (SUT) in this document.
34 Several prerequisites are needed for Yardstick:
36 #. A Jumphost to run Yardstick on
37 #. A Docker daemon or a virtual environment installed on the Jumphost
38 #. A public/external network created on the SUT
39 #. Connectivity from the Jumphost to the SUT public/external network
41 **NOTE:** *Jumphost* refers to any server which meets the previous
42 requirements. Normally it is the same server from where the OPNFV
43 deployment has been triggered.
45 **WARNING:** Connectivity from Jumphost is essential and it is of paramount
46 importance to make sure it is working before even considering to install
47 and run Yardstick. Make also sure you understand how your networking is
50 **NOTE:** If your Jumphost is operating behind a company http proxy and/or
51 Firewall, please consult first the section `Proxy Support (**Todo**)`_, towards
52 the end of this document. That section details some tips/tricks which
53 *may* be of help in a proxified environment.
56 Install Yardstick using Docker (**recommended**)
57 ---------------------------------------------------
59 Yardstick has a Docker image. It is recommended to use this Docker image to run Yardstick test.
61 Prepare the Yardstick container
62 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
64 .. _dockerhub: https://hub.docker.com/r/opnfv/yardstick/
66 Install docker on your guest system with the following command, if not done yet::
68 wget -qO- https://get.docker.com/ | sh
70 Pull the Yardstick Docker image (``opnfv/yardstick``) from the public dockerhub
71 registry under the OPNFV account: dockerhub_, with the following docker
74 docker pull opnfv/yardstick:stable
76 After pulling the Docker image, check that it is available with the
77 following docker command::
79 [yardsticker@jumphost ~]$ docker images
80 REPOSITORY TAG IMAGE ID CREATED SIZE
81 opnfv/yardstick stable a4501714757a 1 day ago 915.4 MB
83 Run the Docker image to get a Yardstick container::
85 docker run -itd --privileged -v /var/run/docker.sock:/var/run/docker.sock -p 8888:5000 -e INSTALLER_IP=192.168.200.2 -e INSTALLER_TYPE=compass --name yardstick opnfv/yardstick:stable
89 +----------------------------------------------+------------------------------+
90 | parameters | Detail |
91 +==============================================+==============================+
92 | -itd | -i: interactive, Keep STDIN |
93 | | open even if not attached. |
94 | | -t: allocate a pseudo-TTY. |
95 | | -d: run container in |
96 | | detached mode, in the |
98 +----------------------------------------------+------------------------------+
99 | --privileged | If you want to build |
100 | | ``yardstick-image`` in |
101 | | Yardstick container, this |
102 | | parameter is needed. |
103 +----------------------------------------------+------------------------------+
104 | -e INSTALLER_IP=192.168.200.2 | If you want to use yardstick |
105 | | env prepare command(or |
106 | -e INSTALLER_TYPE=compass | related API) to load the |
107 | | images that Yardstick needs, |
108 | | these parameters should be |
110 | | The INSTALLER_IP and |
111 | | INSTALLER_TYPE are depending |
112 | | on your OpenStack installer. |
113 | | Currently Apex, Compass, |
114 | | Fuel and Joid are supported. |
115 | | If you use other installers, |
116 | | such as devstack, these |
117 | | parameters can be ignores. |
118 +----------------------------------------------+------------------------------+
119 | -p 8888:5000 | If you want to call |
120 | | Yardstick API out of |
121 | | Yardstick container, this |
122 | | parameter is needed. |
123 +----------------------------------------------+------------------------------+
124 | -v /var/run/docker.sock:/var/run/docker.sock | If you want to use yardstick |
125 | | env grafana/influxdb to |
126 | | create a grafana/influxdb |
127 | | container out of Yardstick |
128 | | container, this parameter is |
130 +----------------------------------------------+------------------------------+
131 | --name yardstick | The name for this container, |
132 | | not needed and can be |
133 | | defined by the user. |
134 +----------------------------------------------+------------------------------+
136 Configure the Yardstick container environment
137 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
139 There are three ways to configure environments for running Yardstick, which will be shown in the following sections. Before that, enter the Yardstick container::
141 docker exec -it yardstick /bin/bash
143 and then configure Yardstick environments in the Yardstick container.
145 The first way (**recommended**)
146 ###################################
148 In the Yardstick container, the Yardstick repository is located in the ``/home/opnfv/repos`` directory. Yardstick provides a CLI to prepare OpenStack environment variables and create Yardstick flavor and guest images automatically::
150 yardstick env prepare
152 **NOTE**: The above command works for four OPNFV installers -- **Apex**, **Compass**, **Fuel** and **Joid**.
153 For Non-OPNFV installer OpenStack environment, the above command can also be used to configure the environment.
154 But before running the above command in a Non-OPNFV installer environment, it is necessary to create the /etc/yardstick/openstack.creds file and
155 save OpenStack environment variables in it. For details of the required OpenStack environment variables please refer to
156 section **Export OpenStack environment variables**
158 The env prepare command may take up to 6-8 minutes to finish building
159 yardstick-image and other environment preparation. Meanwhile if you wish to
160 monitor the env prepare process, you can enter the Yardstick container in a new
161 terminal window and execute the following command::
163 tail -f /var/log/yardstick/uwsgi.log
169 Export OpenStack environment variables
170 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
172 Before running Yardstick it is necessary to export OpenStack environment variables::
176 Environment variables in the ``openrc`` file have to include at least:
182 * ``EXTERNAL_NETWORK``
184 A sample `openrc` file may look like this::
186 export OS_PASSWORD=console
187 export OS_TENANT_NAME=admin
188 export OS_AUTH_URL=http://172.16.1.222:35357/v2.0
189 export OS_USERNAME=admin
190 export OS_VOLUME_API_VERSION=2
191 export EXTERNAL_NETWORK=net04_ext
193 Manually create Yardstick falvor and guest images
194 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
196 Before executing Yardstick test cases, make sure that Yardstick flavor and guest image are available in OpenStack. Detailed steps about creating the Yardstick flavor and building the Yardstick guest image can be found below.
198 Most of the sample test cases in Yardstick are using an OpenStack flavor called
199 ``yardstick-flavor`` which deviates from the OpenStack standard ``m1.tiny`` flavor by the disk size - instead of 1GB it has 3GB. Other parameters are the same as in ``m1.tiny``.
201 Create ``yardstick-flavor``::
203 nova flavor-create yardstick-flavor 100 512 3 1
205 Most of the sample test cases in Yardstick are using a guest image called
206 ``yardstick-image`` which deviates from an Ubuntu Cloud Server image
207 containing all the required tools to run test cases supported by Yardstick.
208 Yardstick has a tool for building this custom image. It is necessary to have
209 ``sudo`` rights to use this tool.
211 Also you may need install several additional packages to use this tool, by
212 follwing the commands below::
214 sudo apt-get update && sudo apt-get install -y qemu-utils kpartx
216 This image can be built using the following command in the directory where Yardstick is installed::
218 export YARD_IMG_ARCH='amd64'
219 sudo echo "Defaults env_keep += \'YARD_IMG_ARCH\'" >> /etc/sudoers
220 sudo tools/yardstick-img-modify tools/ubuntu-server-cloudimg-modify.sh
222 **Warning:** Before building the guest image inside the Yardstick container, make sure the container is granted with privilege. The script will create files by default in ``/tmp/workspace/yardstick`` and the files will be owned by root!
224 The created image can be added to OpenStack using the ``glance image-create`` or via the OpenStack Dashboard. Example command is::
226 glance --os-image-api-version 1 image-create \
227 --name yardstick-image --is-public true \
228 --disk-format qcow2 --container-format bare \
229 --file /tmp/workspace/yardstick/yardstick-image.img
231 .. _`Cirros 0.3.5`: http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
232 .. _`Ubuntu 16.04`: https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img
234 Some Yardstick test cases use a `Cirros 0.3.5`_ image and/or a `Ubuntu 16.04`_ image. Add Cirros and Ubuntu images to OpenStack::
236 openstack image create \
237 --disk-format qcow2 \
238 --container-format bare \
239 --file $cirros_image_file \
242 openstack image create \
243 --disk-format qcow2 \
244 --container-format bare \
245 --file $ubuntu_image_file \
252 Similar to the second way, the first step is also to `Export OpenStack environment variables`_. Then the following steps should be done.
254 Automatically create Yardstcik flavor and guest images
255 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
257 Yardstick has a script for automatically creating Yardstick flavor and building
258 Yardstick guest images. This script is mainly used for CI and can be also used in the local environment::
260 source $YARDSTICK_REPO_DIR/tests/ci/load_images.sh
263 Delete the Yardstick container
264 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
266 If you want to uninstall Yardstick, just delete the Yardstick container::
268 docker stop yardstick && docker rm yardstick
271 Install Yardstick directly in Ubuntu
272 ---------------------------------------
274 .. _install-framework:
276 Alternatively you can install Yardstick framework directly in Ubuntu or in an Ubuntu Docker image. No matter which way you choose to install Yardstick, the following installation steps are identical.
278 If you choose to use the Ubuntu Docker image, you can pull the Ubuntu
279 Docker image from Docker hub::
281 docker pull ubuntu:16.04
285 ^^^^^^^^^^^^^^^^^^^^^
287 Prerequisite preparation::
289 apt-get update && apt-get install -y git python-setuptools python-pip
290 easy_install -U setuptools==30.0.0
291 pip install appdirs==1.4.0
292 pip install virtualenv
294 Create a virtual environment::
296 virtualenv ~/yardstick_venv
297 export YARDSTICK_VENV=~/yardstick_venv
298 source ~/yardstick_venv/bin/activate
300 Download the source code and install Yardstick from it::
302 git clone https://gerrit.opnfv.org/gerrit/yardstick
303 export YARDSTICK_REPO_DIR=~/yardstick
308 Configure the Yardstick environment (**Todo**)
309 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
311 For installing Yardstick directly in Ubuntu, the ``yardstick env`` command is not available. You need to prepare OpenStack environment variables and create Yardstick flavor and guest images manually.
315 ^^^^^^^^^^^^^^^^^^^^^^
317 For unistalling Yardstick, just delete the virtual environment::
319 rm -rf ~/yardstick_venv
322 Verify the installation
323 -----------------------------
325 It is recommended to verify that Yardstick was installed successfully
326 by executing some simple commands and test samples. Before executing Yardstick
327 test cases make sure ``yardstick-flavor`` and ``yardstick-image`` can be found in OpenStack and the ``openrc`` file is sourced. Below is an example
328 invocation of Yardstick ``help`` command and ``ping.py`` test sample::
331 yardstick task start samples/ping.yaml
333 **NOTE:** The above commands could be run in both the Yardstick container and the Ubuntu directly.
335 Each testing tool supported by Yardstick has a sample configuration file.
336 These configuration files can be found in the ``samples`` directory.
338 Default location for the output is ``/tmp/yardstick.out``.
341 Deploy InfluxDB and Grafana using Docker
342 -------------------------------------------
344 Without InfluxDB, Yardstick stores results for runnning test case in the file
345 ``/tmp/yardstick.out``. However, it's unconvenient to retrieve and display
346 test results. So we will show how to use InfluxDB to store data and use
347 Grafana to display data in the following sections.
349 Automatically deploy InfluxDB and Grafana containers (**recommended**)
350 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
352 Firstly, enter the Yardstick container::
354 docker exec -it yardstick /bin/bash
356 Secondly, create InfluxDB container and configure with the following command::
358 yardstick env influxdb
360 Thirdly, create and configure Grafana container::
362 yardstick env grafana
364 Then you can run a test case and visit http://host_ip:3000 (``admin``/``admin``) to see the results.
366 **NOTE:** Executing ``yardstick env`` command to deploy InfluxDB and Grafana requires Jumphost's docker API version => 1.24. Run the following command to check the docker API version on the Jumphost::
370 Manually deploy InfluxDB and Grafana containers
371 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
373 You could also deploy influxDB and Grafana containers manually on the Jumphost.
374 The following sections show how to do.
376 .. pull docker images
383 docker pull tutum/influxdb
384 docker pull grafana/grafana
386 Run and configure influxDB
387 ###############################
391 docker run -d --name influxdb \
392 -p 8083:8083 -p 8086:8086 --expose 8090 --expose 8099 \
394 docker exec -it influxdb bash
399 >CREATE USER root WITH PASSWORD 'root' WITH ALL PRIVILEGES
400 >CREATE DATABASE yardstick;
404 Run and configure Grafana
405 ###############################
409 docker run -d --name grafana -p 3000:3000 grafana/grafana
411 Log on http://{YOUR_IP_HERE}:3000 using ``admin``/``admin`` and configure database resource to be ``{YOUR_IP_HERE}:8086``.
413 .. image:: images/Grafana_config.png
415 :alt: Grafana data source configration
417 Configure ``yardstick.conf``
418 ##############################
422 docker exec -it yardstick /bin/bash
423 cp etc/yardstick/yardstick.conf.sample /etc/yardstick/yardstick.conf
424 vi /etc/yardstick/yardstick.conf
426 Modify ``yardstick.conf``::
430 dispatcher = influxdb
432 [dispatcher_influxdb]
434 target = http://{YOUR_IP_HERE}:8086
439 Now you can run Yardstick test cases and store the results in influxDB.
442 Deploy InfluxDB and Grafana directly in Ubuntu (**Todo**)
443 -----------------------------------------------------------
451 **yardstick testcase list**
453 This command line would list all test cases in yardstick.
454 It would show like below::
456 +---------------------------------------------------------------------------------------
457 | Testcase Name | Description
458 +---------------------------------------------------------------------------------------
459 | opnfv_yardstick_tc001 | Measure network throughput using pktgen
460 | opnfv_yardstick_tc002 | measure network latency using ping
461 | opnfv_yardstick_tc005 | Measure Storage IOPS, throughput and latency using fio.
462 | opnfv_yardstick_tc006 | Measure volume storage IOPS, throughput and latency using fio.
463 | opnfv_yardstick_tc008 | Measure network throughput and packet loss using Pktgen
464 | opnfv_yardstick_tc009 | Measure network throughput and packet loss using pktgen
465 | opnfv_yardstick_tc010 | measure memory read latency using lmbench.
466 | opnfv_yardstick_tc011 | Measure packet delay variation (jitter) using iperf3.
467 | opnfv_yardstick_tc012 | Measure memory read and write bandwidth using lmbench.
468 | opnfv_yardstick_tc014 | Measure Processing speed using unixbench.
469 | opnfv_yardstick_tc019 | Sample test case for the HA of controller node service.
471 +---------------------------------------------------------------------------------------
472 show a test case config file
473 >>>>>>>>>>>>>>>>>>>>>>>>>>>>
474 Take opnfv_yardstick_tc002 for an example. This test case measure network latency.
475 You just need to type in **yardstick testcase show opnfv_yardstick_tc002**, and the console
476 would show the config yaml of this test case::
477 ##############################################################################
478 # Copyright (c) 2017 kristian.hunt@gmail.com and others.
480 # All rights reserved. This program and the accompanying materials
481 # are made available under the terms of the Apache License, Version 2.0
482 # which accompanies this distribution, and is available at
483 # http://www.apache.org/licenses/LICENSE-2.0
484 ##############################################################################
487 schema: "yardstick:task:0.1"
489 Yardstick TC002 config file;
490 measure network latency using ping;
492 {% set image = image or "cirros-0.3.5" %}
494 {% set provider = provider or none %}
495 {% set physical_network = physical_network or 'physnet1' %}
496 {% set segmentation_id = segmentation_id or none %}
497 {% set packetsize = packetsize or 100 %}
500 {% for i in range(2) %}
504 packetsize: {{packetsize}}
521 flavor: yardstick-flavor
526 policy: "availability"
538 {% if provider == "vlan" %}
539 provider: {{provider}}
540 physical_network: {{physical_network}}å
541 {% if segmentation_id %}
542 segmentation_id: {{segmentation_id}}
546 start a task to run yardstick test case
547 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
548 If you want run a test case, then you need to use **yardstick task start <test_case_path>**
549 this command support some parameters as below:
551 +---------------------+--------------------------------------------------+
552 | Parameters | Detail |
553 +=====================+==================================================+
554 | -d | show debug log of yardstick running |
556 +---------------------+--------------------------------------------------+
557 | --task-args | If you want to customize test case parameters, |
558 | | use "--task-args" to pass the value. The format |
559 | | is a json string with parameter key-value pair. |
561 +---------------------+--------------------------------------------------+
562 | --task-args-file | If you want to use yardstick |
563 | | env prepare command(or |
564 | | related API) to load the |
565 +---------------------+--------------------------------------------------+
569 +---------------------+--------------------------------------------------+
570 | --output-file \ | Specify where to output the log. if not pass, |
571 | OUTPUT_FILE_PATH | the default value is |
572 | | "/tmp/yardstick/yardstick.log" |
574 +---------------------+--------------------------------------------------+
575 | --suite \ | run a test suite, TEST_SUITE_PATH speciy where |
576 | TEST_SUITE_PATH | the test suite locates |
578 +---------------------+--------------------------------------------------+
581 Run Yardstick in a local environment
582 ------------------------------------
584 We also have a guide about how to run Yardstick in a local environment.
585 This work is contributed by Tapio Tallgren.
586 You can find this guide at `here <https://wiki.opnfv.org/display/yardstick/How+to+run+Yardstick+in+a+local+environment>`_.
589 Create a test suite for Yardstick
590 ------------------------------------
592 A test suite in yardstick is a yaml file which include one or more test cases.
593 Yardstick is able to support running test suite task, so you can customize your
594 own test suite and run it in one task.
596 ``tests/opnfv/test_suites`` is the folder where Yardstick puts CI test suite. A typical test suite is like below (the ``fuel_test_suite.yaml`` example)::
599 # Fuel integration test task suite
601 schema: "yardstick:suite:0.1"
603 name: "fuel_test_suite"
604 test_cases_dir: "samples/"
609 file_name: iperf3.yaml
611 As you can see, there are two test cases in the ``fuel_test_suite.yaml``. The
612 ``schema`` and the ``name`` must be specified. The test cases should be listed
613 via the tag ``test_cases`` and their relative path is also marked via the tag
616 Yardstick test suite also supports constraints and task args for each test
617 case. Here is another sample (the ``os-nosdn-nofeature-ha.yaml`` example) to
618 show this, which is digested from one big test suite::
622 schema: "yardstick:suite:0.1"
624 name: "os-nosdn-nofeature-ha"
625 test_cases_dir: "tests/opnfv/test_cases/"
628 file_name: opnfv_yardstick_tc002.yaml
630 file_name: opnfv_yardstick_tc005.yaml
632 file_name: opnfv_yardstick_tc043.yaml
637 huawei-pod1: '{"pod_info": "etc/yardstick/.../pod.yaml",
638 "host": "node4.LF","target": "node5.LF"}'
640 As you can see in test case ``opnfv_yardstick_tc043.yaml``, there are two
641 tags, ``constraint`` and ``task_args``. ``constraint`` is to specify which
642 installer or pod it can be run in the CI environment. ``task_args`` is to
643 specify the task arguments for each pod.
645 All in all, to create a test suite in Yardstick, you just need to create a
646 yaml file and add test cases, constraint or task arguments if necessary.
649 Proxy Support (**Todo**)
650 ---------------------------