25c125851e19d4859fc205b3c4d0f874f43a8705
[yardstick.git] / docs / userguide / 07-installation.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International
2 .. License.
3 .. http://creativecommons.org/licenses/by/4.0
4 .. (c) OPNFV, Ericsson AB, Huawei Technologies Co.,Ltd and others.
5
6 Yardstick Installation
7 ======================
8
9 Abstract
10 --------
11
12 Yardstick currently supports installation on Ubuntu 14.04 or by using a Docker
13 image. Detailed steps about installing Yardstick using both of these options
14 can be found below.
15
16 To use Yardstick you should have access to an OpenStack environment,
17 with at least Nova, Neutron, Glance, Keystone and Heat installed.
18
19 The steps needed to run Yardstick are:
20
21 1. Install Yardstick and create the test configuration .yaml file.
22 2. Build a guest image and load the image into the OpenStack environment.
23 3. Create a Neutron external network and load OpenStack environment variables.
24 4. Run the test case.
25
26
27 Installing Yardstick on Ubuntu 14.04
28 ------------------------------------
29
30 .. _install-framework:
31
32 Installing Yardstick framework
33 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
34 Install dependencies:
35 ::
36
37   sudo apt-get update && sudo apt-get install -y \
38       wget \
39       git \
40       sshpass \
41       qemu-utils \
42       kpartx \
43       libffi-dev \
44       libssl-dev \
45       python \
46       python-dev \
47       python-virtualenv \
48       libxml2-dev \
49       libxslt1-dev \
50       python-setuptools
51
52 Create a python virtual environment, source it and update setuptools:
53 ::
54
55   virtualenv ~/yardstick_venv
56   source ~/yardstick_venv/bin/activate
57   easy_install -U setuptools
58
59 Download source code and install python dependencies:
60 ::
61
62   git clone https://gerrit.opnfv.org/gerrit/yardstick
63   cd yardstick
64   python setup.py install
65
66 There is also a YouTube video, showing the above steps:
67
68 .. image:: http://img.youtube.com/vi/4S4izNolmR0/0.jpg
69    :alt: http://www.youtube.com/watch?v=4S4izNolmR0
70    :target: http://www.youtube.com/watch?v=4S4izNolmR0
71
72 Installing extra tools
73 ^^^^^^^^^^^^^^^^^^^^^^
74 yardstick-plot
75 """"""""""""""
76 Yardstick has an internal plotting tool ``yardstick-plot``, which can be installed
77 using the following command:
78 ::
79
80   sudo apt-get install -y g++ libfreetype6-dev libpng-dev pkg-config
81   python setup.py develop easy_install yardstick[plot]
82
83 .. _guest-image:
84
85 Building a guest image
86 ^^^^^^^^^^^^^^^^^^^^^^
87 Yardstick has a tool for building an Ubuntu Cloud Server image containing all
88 the required tools to run test cases supported by Yardstick. It is necessary to
89 have sudo rights to use this tool.
90
91 Also you may need install several additional packages to use this tool, by
92 follwing the commands below:
93 ::
94
95   apt-get update && apt-get install -y \
96       qemu-utils \
97       kpartx
98
99 This image can be built using the following command while in the directory where
100 Yardstick is installed (``~/yardstick`` if the framework is installed
101 by following the commands above):
102 ::
103
104   sudo ./tools/yardstick-img-modify tools/ubuntu-server-cloudimg-modify.sh
105
106 **Warning:** the script will create files by default in:
107 ``/tmp/workspace/yardstick`` and the files will be owned by root!
108
109 The created image can be added to OpenStack using the ``glance image-create`` or
110 via the OpenStack Dashboard.
111
112 Example command:
113 ::
114
115   glance --os-image-api-version 1 image-create \
116   --name yardstick-trusty-server --is-public true \
117   --disk-format qcow2 --container-format bare \
118   --file /tmp/workspace/yardstick/yardstick-trusty-server.img
119
120
121 Installing Yardstick using Docker
122 ---------------------------------
123
124 Yardstick has two Docker images, first one (**Yardstick-framework**) serves as a
125 replacement for installing the Yardstick framework in a virtual environment (for
126 example as done in :ref:`install-framework`), while the other image is mostly for
127 CI purposes (**Yardstick-CI**).
128
129 Yardstick-framework image
130 ^^^^^^^^^^^^^^^^^^^^^^^^^
131 Download the source code:
132
133 ::
134
135   git clone https://gerrit.opnfv.org/gerrit/yardstick
136
137 Build the Docker image and tag it as *yardstick-framework*:
138
139 ::
140
141   cd yardstick
142   docker build -t yardstick-framework .
143
144 Run the Docker instance:
145
146 ::
147
148   docker run --name yardstick_instance -i -t yardstick-framework
149
150 To build a guest image for Yardstick, see :ref:`guest-image`.
151
152 Yardstick-CI image
153 ^^^^^^^^^^^^^^^^^^
154 Pull the Yardstick-CI Docker image from Docker hub:
155
156 ::
157
158   docker pull opnfv/yardstick:$DOCKER_TAG
159
160 Where ``$DOCKER_TAG`` is latest for master branch, as for the release branches,
161 this coincides with its release name, such as brahmaputra.1.0.
162
163 Run the Docker image:
164
165 ::
166
167   docker run \
168    --privileged=true \
169     --rm \
170     -t \
171     -e "INSTALLER_TYPE=${INSTALLER_TYPE}" \
172     -e "INSTALLER_IP=${INSTALLER_IP}" \
173     opnfv/yardstick \
174     exec_tests.sh ${YARDSTICK_DB_BACKEND} ${YARDSTICK_SUITE_NAME}
175
176 Where ``${INSTALLER_TYPE}`` can be apex, compass, fuel or joid, ``${INSTALLER_IP}``
177 is the installer master node IP address (i.e. 10.20.0.2 is default for fuel). ``${YARDSTICK_DB_BACKEND}``
178 is the IP and port number of DB, ``${YARDSTICK_SUITE_NAME}`` is the test suite you want to run.
179 For more details, please refer to the Jenkins job defined in Releng project, labconfig information
180 and sshkey are required. See the link
181 https://git.opnfv.org/cgit/releng/tree/jjb/yardstick/yardstick-ci-jobs.yml.
182
183 Note: exec_tests.sh is used for executing test suite here, furthermore, if someone wants to execute the
184 test suite manually, it can be used as long as the parameters are configured correct. Another script
185 called run_tests.sh is used for unittest in Jenkins verify job, in local manaul environment,
186 it is recommended to run before test suite execuation.
187
188 Basic steps performed by the **Yardstick-CI** container:
189
190 1. clone yardstick and releng repos
191 2. setup OS credentials (releng scripts)
192 3. install yardstick and dependencies
193 4. build yardstick cloud image and upload it to glance
194 5. upload cirros-0.3.3 cloud image to glance
195 6. run yardstick test scenarios
196 7. cleanup
197
198
199 OpenStack parameters and credentials
200 ------------------------------------
201
202 Yardstick-flavor
203 ^^^^^^^^^^^^^^^^
204 Most of the sample test cases in Yardstick are using an OpenStack flavor called
205 *yardstick-flavor* which deviates from the OpenStack standard m1.tiny flavor by the
206 disk size - instead of 1GB it has 3GB. Other parameters are the same as in m1.tiny.
207
208 Environment variables
209 ^^^^^^^^^^^^^^^^^^^^^
210 Before running Yardstick it is necessary to export OpenStack environment variables
211 from the OpenStack *openrc* file (using the ``source`` command) and export the
212 external network name ``export EXTERNAL_NETWORK="external-network-name"``,
213 the default name for the external network is ``net04_ext``.
214
215 Credential environment variables in the *openrc* file have to include at least:
216
217 * OS_AUTH_URL
218 * OS_USERNAME
219 * OS_PASSWORD
220 * OS_TENANT_NAME
221
222 Yardstick default key pair
223 ^^^^^^^^^^^^^^^^^^^^^^^^^^
224 Yardstick uses a SSH key pair to connect to the guest image. This key pair can
225 be found in the ``resources/files`` directory. To run the ``ping-hot.yaml`` test
226 sample, this key pair needs to be imported to the OpenStack environment.
227
228
229 Examples and verifying the install
230 ----------------------------------
231
232 It is recommended to verify that Yardstick was installed successfully
233 by executing some simple commands and test samples. Below is an example invocation
234 of yardstick help command and ping.py test sample:
235 ::
236
237   yardstick –h
238   yardstick task start samples/ping.yaml
239
240 Each testing tool supported by Yardstick has a sample configuration file.
241 These configuration files can be found in the **samples** directory.
242
243 Example invocation of ``yardstick-plot`` tool:
244 ::
245
246   yardstick-plot -i /tmp/yardstick.out -o /tmp/plots/
247
248 Default location for the output is ``/tmp/yardstick.out``.
249
250 More info about the tool can be found by executing:
251 ::
252
253   yardstick-plot -h
254
255
256 Deploy InfluxDB and Grafana locally
257 ------------------------------------
258
259 .. pull docker images
260
261 Pull docker images
262 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
263
264 ::
265
266   docker pull tutum/influxdb
267   docker pull grafana/grafana
268
269 Run influxdb and config
270 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
271 Run influxdb
272 ::
273
274   docker run -d --name influxdb -p 8083:8083 -p 8086:8086 --expose 8090 --expose 8099 tutum/influxdb
275   docker exec -it influxdb bash
276
277 Config influxdb
278 ::
279
280   influx
281   >CREATE USER root WITH PASSWORD 'root' WITH ALL PRIVILEGES
282   >CREATE DATABASE yardstick;
283   >use yardstick;
284   >show MEASUREMENTS;
285
286 Run grafana and config
287 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
288 Run grafana
289 ::
290
291   docker run -d --name grafana -p 3000:3000 grafana/grafana
292
293 Config grafana
294 ::
295
296   http://{YOUR_IP_HERE}:3000
297   log on using admin/admin and config database resource to be {YOUR_IP_HERE}:8086
298
299 .. image:: images/Grafana_config.png
300
301 Config yardstick conf
302 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
303 cp ./etc/yardstick/yardstick.conf.sample /etc/yardstick/yardstick.conf
304
305 vi /etc/yardstick/yardstick.conf
306 Config yardstick.conf
307 ::
308
309   [DEFAULT]
310   debug = True
311   dispatcher = influxdb
312
313   [dispatcher_influxdb]
314   timeout = 5
315   target = http://{YOUR_IP_HERE}:8086
316   db_name = yardstick
317   username = root
318   password = root
319
320 Now you can run yardstick test case and store the results in influxdb
321 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^