Adding scale up feature to prox MPLS Tagging OvS-DPDK & SRIOV
[yardstick.git] / docs / testing / user / userguide / 05-operation.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, Intel, Ericsson AB, Huawei Technologies Co. Ltd and others.
5
6 ..
7       Convention for heading levels in Yardstick:
8       =======  Heading 0 (reserved for the title in a document)
9       -------  Heading 1
10       ^^^^^^^  Heading 2
11       +++++++  Heading 3
12       '''''''  Heading 4
13       Avoid deeper levels because they do not render well.
14
15 ===============
16 Yardstick Usage
17 ===============
18
19 Once you have yardstick installed, you can start using it to run testcases
20 immediately, through the CLI. You can also define and run new testcases and
21 test suites. This chapter details basic usage (running testcases), as well as
22 more advanced usage (creating your own testcases).
23
24 Yardstick common CLI
25 --------------------
26
27 List test cases
28 ^^^^^^^^^^^^^^^
29
30 ``yardstick testcase list``: This command line would list all test cases in
31 Yardstick. It would show like below::
32
33    +---------------------------------------------------------------------------------------
34    | Testcase Name         | Description
35    +---------------------------------------------------------------------------------------
36    | opnfv_yardstick_tc001 | Measure network throughput using pktgen
37    | opnfv_yardstick_tc002 | measure network latency using ping
38    | opnfv_yardstick_tc005 | Measure Storage IOPS, throughput and latency using fio.
39    ...
40    +---------------------------------------------------------------------------------------
41
42
43 Show a test case config file
44 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
45
46 Take opnfv_yardstick_tc002 for an example. This test case measure network
47 latency. You just need to type in ``yardstick testcase show
48 opnfv_yardstick_tc002``, and the console would show the config yaml of this
49 test case:
50
51 .. literalinclude::
52    ../../../../tests/opnfv/test_cases/opnfv_yardstick_tc002.yaml
53    :lines: 9-
54
55 Run a Yardstick test case
56 ^^^^^^^^^^^^^^^^^^^^^^^^^
57
58 If you want run a test case, then you need to use ``yardstick task start
59 <test_case_path>`` this command support some parameters as below:
60
61    +---------------------+--------------------------------------------------+
62    | Parameters          | Detail                                           |
63    +=====================+==================================================+
64    | -d                  | show debug log of yardstick running              |
65    |                     |                                                  |
66    +---------------------+--------------------------------------------------+
67    | --task-args         | If you want to customize test case parameters,   |
68    |                     | use "--task-args" to pass the value. The format  |
69    |                     | is a json string with parameter key-value pair.  |
70    |                     |                                                  |
71    +---------------------+--------------------------------------------------+
72    | --task-args-file    | If you want to use yardstick                     |
73    |                     | env prepare command(or                           |
74    |                     | related API) to load the                         |
75    +---------------------+--------------------------------------------------+
76    | --parse-only        |                                                  |
77    |                     |                                                  |
78    |                     |                                                  |
79    +---------------------+--------------------------------------------------+
80    | --output-file \     | Specify where to output the log. if not pass,    |
81    | OUTPUT_FILE_PATH    | the default value is                             |
82    |                     | "/tmp/yardstick/yardstick.log"                   |
83    |                     |                                                  |
84    +---------------------+--------------------------------------------------+
85    | --suite \           | run a test suite, TEST_SUITE_PATH specify where  |
86    | TEST_SUITE_PATH     | the test suite locates                           |
87    |                     |                                                  |
88    +---------------------+--------------------------------------------------+
89
90
91 Run Yardstick in a local environment
92 ------------------------------------
93
94 We also have a guide about `How to run Yardstick in a local environment`_.
95 This work is contributed by Tapio Tallgren.
96
97 Create a new testcase for Yardstick
98 -----------------------------------
99
100 As a user, you may want to define a new testcase in addition to the ones
101 already available in Yardstick. This section will show you how to do this.
102
103 Each testcase consists of two sections:
104
105 * ``scenarios`` describes what will be done by the test
106 * ``context`` describes the environment in which the test will be run.
107
108 Defining the testcase scenarios
109 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
110
111 TODO
112
113 Defining the testcase context(s)
114 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
115
116 Each testcase consists of one or more contexts, which describe the environment
117 in which the testcase will be run.
118 Current available contexts are:
119
120 * ``Dummy``: this is a no-op context, and is used when there is no environment
121   to set up e.g. when testing whether OpenStack services are available
122 * ``Node``: this context is used to perform operations on baremetal servers
123 * ``Heat``: uses OpenStack to provision the required hosts, networks, etc.
124 * ``Kubernetes``: uses Kubernetes to provision the resources required for the
125   test.
126
127 Regardless of the context type, the ``context`` section of the testcase will
128 consist of the following::
129
130    context:
131      name: demo
132      type: Dummy|Node|Heat|Kubernetes
133
134 The content of the ``context`` section will vary based on the context type.
135
136 Dummy Context
137 +++++++++++++
138
139 No additional information is required for the Dummy context::
140
141   context:
142     name: my_context
143     type: Dummy
144
145 Node Context
146 ++++++++++++
147
148 TODO
149
150 Heat Context
151 ++++++++++++
152
153 In addition to ``name`` and ``type``, a Heat context requires the following
154 arguments:
155
156 * ``image``: the image to be used to boot VMs
157 * ``flavor``: the flavor to be used for VMs in the context
158 * ``user``: the username for connecting into the VMs
159 * ``networks``: The networks to be created, networks are identified by name
160
161   * ``name``: network name (required)
162   * (TODO) Any optional attributes
163
164 * ``servers``: The servers to be created
165
166   * ``name``: server name
167   * (TODO) Any optional attributes
168
169 In addition to the required arguments, the following optional arguments can be
170 passed to the Heat context:
171
172 * ``placement_groups``:
173
174   * ``name``: the name of the placement group to be created
175   * ``policy``: either ``affinity`` or ``availability``
176 * ``server_groups``:
177
178   * ``name``: the name of the server group
179   * ``policy``: either ``affinity`` or ``anti-affinity``
180
181 Combining these elements together, a sample Heat context config looks like:
182
183 .. literalinclude::
184    ../../../../yardstick/tests/integration/dummy-scenario-heat-context.yaml
185    :start-after: ---
186    :emphasize-lines: 14-
187
188 Using exisiting HOT Templates
189 '''''''''''''''''''''''''''''
190
191 TODO
192
193 Kubernetes Context
194 ++++++++++++++++++
195
196 TODO
197
198 Using multiple contexts in a testcase
199 +++++++++++++++++++++++++++++++++++++
200
201 When using multiple contexts in a testcase, the ``context`` section is replaced
202 by a ``contexts`` section, and each context is separated with a ``-`` line::
203
204   contexts:
205   -
206     name: context1
207     type: Heat
208     ...
209   -
210     name: context2
211     type: Node
212     ...
213
214
215 Reusing a context
216 +++++++++++++++++
217
218 Typically, a context is torn down after a testcase is run, however, the user
219 may wish to keep an context intact after a testcase is complete.
220
221 .. note::
222   This feature has been implemented for the Heat context only
223
224 To keep or reuse a context, the ``flags`` option must be specified:
225
226 * ``no_setup``: skip the deploy stage, and fetch the details of a deployed
227    context/Heat stack.
228 * ``no_teardown``: skip the undeploy stage, thus keeping the stack intact for
229    the next test
230
231 If either of these ``flags`` are ``True``, the context information must still
232 be given. By default, these flags are disabled::
233
234   context:
235     name: mycontext
236     type: Heat
237     flags:
238       no_setup: True
239       no_teardown: True
240     ...
241
242 Create a test suite for Yardstick
243 ---------------------------------
244
245 A test suite in Yardstick is a .yaml file which includes one or more test
246 cases. Yardstick is able to support running test suite task, so you can
247 customize your own test suite and run it in one task.
248
249 ``tests/opnfv/test_suites`` is the folder where Yardstick puts CI test suite.
250 A typical test suite is like below (the ``fuel_test_suite.yaml`` example):
251
252 .. literalinclude::
253    ../../../../tests/opnfv/test_suites/fuel_test_suite.yaml
254    :lines: 9-
255
256 As you can see, there are two test cases in the ``fuel_test_suite.yaml``. The
257 ``schema`` and the ``name`` must be specified. The test cases should be listed
258 via the tag ``test_cases`` and their relative path is also marked via the tag
259 ``test_cases_dir``.
260
261 Yardstick test suite also supports constraints and task args for each test
262 case. Here is another sample (the ``os-nosdn-nofeature-ha.yaml`` example) to
263 show this, which is digested from one big test suite::
264
265    ---
266
267    schema: "yardstick:suite:0.1"
268
269    name: "os-nosdn-nofeature-ha"
270    test_cases_dir: "tests/opnfv/test_cases/"
271    test_cases:
272    -
273      file_name: opnfv_yardstick_tc002.yaml
274    -
275      file_name: opnfv_yardstick_tc005.yaml
276    -
277      file_name: opnfv_yardstick_tc043.yaml
278         constraint:
279            installer: compass
280            pod: huawei-pod1
281         task_args:
282            huawei-pod1: '{"pod_info": "etc/yardstick/.../pod.yaml",
283            "host": "node4.LF","target": "node5.LF"}'
284
285 As you can see in test case ``opnfv_yardstick_tc043.yaml``, there are two
286 tags, ``constraint`` and ``task_args``. ``constraint`` is to specify which
287 installer or pod it can be run in the CI environment. ``task_args`` is to
288 specify the task arguments for each pod.
289
290 All in all, to create a test suite in Yardstick, you just need to create a
291 yaml file and add test cases, constraint or task arguments if necessary.
292
293 References
294 ----------
295
296 .. _`How to run Yardstick in a local environment`: https://wiki.opnfv.org/display/yardstick/How+to+run+Yardstick+in+a+local+environment