[docs] Update mailing list to use #yardstick
[yardstick.git] / docs / testing / developer / devguide / devguide.rst
1 ..
2       Licensed under the Apache License, Version 2.0 (the "License"); you may
3       not use this file except in compliance with the License. You may obtain
4       a copy of the License at
5
6           http://www.apache.org/licenses/LICENSE-2.0
7
8       Unless required by applicable law or agreed to in writing, software
9       distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10       WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11       License for the specific language governing permissions and limitations
12       under the License.
13
14       Convention for heading levels in Yardstick documentation:
15
16       =======  Heading 0 (reserved for the title in a document)
17       -------  Heading 1
18       ~~~~~~~  Heading 2
19       +++++++  Heading 3
20       '''''''  Heading 4
21
22       Avoid deeper levels because they do not render well.
23
24 Introduction
25 ------------
26
27 Yardstick is a project dealing with performance testing. Yardstick produces
28 its own test cases but can also be considered as a framework to support feature
29 project testing.
30
31 Yardstick developed a test API that can be used by any OPNFV project. Therefore
32 there are many ways to contribute to Yardstick.
33
34 You can:
35
36 * Develop new test cases
37 * Review codes
38 * Develop Yardstick API / framework
39 * Develop Yardstick grafana dashboards and Yardstick reporting page
40 * Write Yardstick documentation
41
42 This developer guide describes how to interact with the Yardstick project.
43 The first section details the main working areas of the project. The Second
44 part is a list of “How to” to help you to join the Yardstick family whatever
45 your field of interest is.
46
47 Where can I find some help to start?
48 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49
50 .. _`user guide`: http://artifacts.opnfv.org/yardstick/danube/1.0/docs/stesting_user_userguide/index.html
51 .. _`wiki page`: https://wiki.opnfv.org/display/yardstick/
52
53 This guide is made for you. You can have a look at the `user guide`_.
54 There are also references on documentation, video tutorials, tips in the
55 project `wiki page`_. You can also directly contact us by mail with
56 ``#yardstick`` or ``[yardstick]`` prefix in the subject at
57 ``opnfv-tech-discuss@lists.opnfv.org`` or on the IRC channel ``#opnfv-yardstick``.
58
59
60 Yardstick developer areas
61 -------------------------
62
63 Yardstick framework
64 ~~~~~~~~~~~~~~~~~~~
65
66 Yardstick can be considered as a framework. Yardstick is released as a docker
67 file, including tools, scripts and a CLI to prepare the environement and run
68 tests. It simplifies the integration of external test suites in CI pipelines
69 and provides commodity tools to collect and display results.
70
71 Since Danube, test categories (also known as tiers) have been created to group
72 similar tests, provide consistant sub-lists and at the end optimize test
73 duration for CI (see How To section).
74
75 The definition of the tiers has been agreed by the testing working group.
76
77 The tiers are:
78
79 * smoke
80 * features
81 * components
82 * performance
83 * vnf
84
85
86 How Todos?
87 ----------
88
89 How Yardstick works?
90 ~~~~~~~~~~~~~~~~~~~~
91
92 The installation and configuration of the Yardstick is described in the `user guide`_.
93
94 How to work with test cases?
95 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
96
97 Sample Test cases
98 +++++++++++++++++
99
100 Yardstick provides many sample test cases which are located at ``samples`` directory of repo.
101
102 Sample test cases are designed with the following goals:
103
104 1. Helping user better understand Yardstick features (including new feature and
105    new test capacity).
106
107 2. Helping developer to debug a new feature and test case before it is
108    offically released.
109
110 3. Helping other developers understand and verify the new patch before the
111    patch is merged.
112
113 Developers should upload their sample test cases as well when they are
114 uploading a new patch which is about the Yardstick new test case or new feature.
115
116
117 OPNFV Release Test cases
118 ++++++++++++++++++++++++
119
120 OPNFV Release test cases are located at ``yardstick/tests/opnfv/test_cases``.
121 These test cases are run by OPNFV CI jobs, which means these test cases should
122 be more mature than sample test cases.
123 OPNFV scenario owners can select related test cases and add them into the test
124 suites which represent their scenario.
125
126
127 Test case Description File
128 ++++++++++++++++++++++++++
129
130 This section will introduce the meaning of the Test case description file.
131 we will use ping.yaml as a example to show you how to understand the test case
132 description file.
133 This ``yaml`` file consists of two sections. One is ``scenarios``,  the other
134 is ``context``.::
135
136   ---
137     # Sample benchmark task config file
138     # measure network latency using ping
139
140     schema: "yardstick:task:0.1"
141
142     {% set provider = provider or none %}
143     {% set physical_network = physical_network or 'physnet1' %}
144     {% set segmentation_id = segmentation_id or none %}
145     scenarios:
146     -
147       type: Ping
148       options:
149         packetsize: 200
150       host: athena.demo
151       target: ares.demo
152
153       runner:
154         type: Duration
155         duration: 60
156         interval: 1
157
158       sla:
159         max_rtt: 10
160         action: monitor
161
162     context:
163       name: demo
164       image: yardstick-image
165       flavor: yardstick-flavor
166       user: ubuntu
167
168       placement_groups:
169         pgrp1:
170           policy: "availability"
171
172       servers:
173         athena:
174           floating_ip: true
175           placement: "pgrp1"
176         ares:
177           placement: "pgrp1"
178
179       networks:
180         test:
181           cidr: '10.0.1.0/24'
182           {% if provider == "vlan" %}
183           provider: {{provider}}
184           physical_network: {{physical_network}}
185             {% if segmentation_id %}
186           segmentation_id: {{segmentation_id}}
187             {% endif %}
188          {% endif %}
189
190
191 The ``contexts`` section is the description of pre-condition of testing. As
192 ``ping.yaml`` shows, you can configure the image, flavor, name, affinity and
193 network of Test VM (servers),  with this section, you will get a pre-condition
194 env for Testing.
195 Yardstick will automatically setup the stack which are described in this
196 section.
197 Yardstick converts this section to heat template and sets up the VMs with
198 heat-client (Yardstick can also support to convert this section to Kubernetes
199 template to setup containers).
200
201 In the examples above, two Test VMs (athena and ares) are configured by
202 keyword ``servers``.
203 ``flavor`` will determine how many vCPU, how much memory for test VMs.
204 As ``yardstick-flavor`` is a basic flavor which will be automatically created
205 when you run command ``yardstick env prepare``. ``yardstick-flavor`` is
206 ``1 vCPU 1G RAM,3G Disk``.
207 ``image`` is the image name of test VMs. If you use ``cirros.3.5.0``, you need
208 fill the username of this image into ``user``.
209 The ``policy`` of placement of Test VMs have two values (``affinity`` and
210 ``availability``). ``availability`` means anti-affinity.
211 In the ``network`` section, you can configure which ``provider`` network and
212 ``physical_network`` you want Test VMs to use.
213 You may need to configure ``segmentation_id`` when your network is vlan.
214
215 Moreover, you can configure your specific flavor as below, Yardstick will setup
216 the stack for you. ::
217
218   flavor:
219     name: yardstick-new-flavor
220     vcpus: 12
221     ram: 1024
222     disk: 2
223
224
225 Besides default ``Heat`` context, Yardstick also allows you to setup two other
226 types of context. They are ``Node`` and ``Kubernetes``. ::
227
228   context:
229     type: Kubernetes
230     name: k8s
231
232 and ::
233
234   context:
235     type: Node
236     name: LF
237
238
239 The ``scenarios`` section is the description of testing steps, you can
240 orchestrate the complex testing step through scenarios.
241
242 Each scenario will do one testing step.
243 In one scenario, you can configure the type of scenario (operation), ``runner``
244 type and ``sla`` of the scenario.
245
246 For TC002, We only have one step, which is Ping from host VM to target VM. In
247 this step, we also have some detailed operations implemented (such as ssh to
248 VM, ping from VM1 to VM2. Get the latency, verify the SLA, report the result).
249
250 If you want to get this implementation details implement, you can check with
251 the scenario.py file. For Ping scenario, you can find it in Yardstick repo
252 (``yardstick/yardstick/benchmark/scenarios/networking/ping.py``).
253
254 After you select the type of scenario (such as Ping), you will select one type
255 of ``runner``, there are 4 types of runner. ``Iteration`` and ``Duration`` are
256 the most commonly used, and the default is ``Iteration``.
257
258 For ``Iteration``, you can specify the iteration number and interval of iteration. ::
259
260   runner:
261     type: Iteration
262     iterations: 10
263     interval: 1
264
265 That means Yardstick will repeat the Ping test 10 times and the interval of
266 each iteration is one second.
267
268 For ``Duration``, you can specify the duration of this scenario and the
269 interval of each ping test. ::
270
271   runner:
272     type: Duration
273     duration: 60
274     interval: 10
275
276 That means Yardstick will run the ping test as loop until the total time of
277 this scenario reaches 60s and the interval of each loop is ten seconds.
278
279
280 SLA is the criterion of this scenario. This depends on the scenario. Different
281 scenarios can have different SLA metric.
282
283
284 How to write a new test case
285 ++++++++++++++++++++++++++++
286
287 Yardstick already provides a library of testing steps (i.e. different types of
288 scenario).
289
290 Basically, what you need to do is to orchestrate the scenario from the library.
291
292 Here, we will show two cases. One is how to write a simple test case, the other
293 is how to write a quite complex test case.
294
295 Write a new simple test case
296 ''''''''''''''''''''''''''''
297
298 First, you can image a basic test case description as below.
299
300 +-----------------------------------------------------------------------------+
301 |Storage Performance                                                          |
302 |                                                                             |
303 +--------------+--------------------------------------------------------------+
304 |metric        | IOPS (Average IOs performed per second),                     |
305 |              | Throughput (Average disk read/write bandwidth rate),         |
306 |              | Latency (Average disk read/write latency)                    |
307 |              |                                                              |
308 +--------------+--------------------------------------------------------------+
309 |test purpose  | The purpose of TC005 is to evaluate the IaaS storage         |
310 |              | performance with regards to IOPS, throughput and latency.    |
311 |              |                                                              |
312 +--------------+--------------------------------------------------------------+
313 |test          | fio test is invoked in a host VM on a compute blade, a job   |
314 |description   | file as well as parameters are passed to fio and fio will    |
315 |              | start doing what the job file tells it to do.                |
316 |              |                                                              |
317 +--------------+--------------------------------------------------------------+
318 |configuration | file: opnfv_yardstick_tc005.yaml                             |
319 |              |                                                              |
320 |              | IO types is set to read, write, randwrite, randread, rw.     |
321 |              | IO block size is set to 4KB, 64KB, 1024KB.                   |
322 |              | fio is run for each IO type and IO block size scheme,        |
323 |              | each iteration runs for 30 seconds (10 for ramp time, 20 for |
324 |              | runtime).                                                    |
325 |              |                                                              |
326 |              | For SLA, minimum read/write iops is set to 100,              |
327 |              | minimum read/write throughput is set to 400 KB/s,            |
328 |              | and maximum read/write latency is set to 20000 usec.         |
329 |              |                                                              |
330 +--------------+--------------------------------------------------------------+
331 |applicability | This test case can be configured with different:             |
332 |              |                                                              |
333 |              |   * IO types;                                                |
334 |              |   * IO block size;                                           |
335 |              |   * IO depth;                                                |
336 |              |   * ramp time;                                               |
337 |              |   * test duration.                                           |
338 |              |                                                              |
339 |              | Default values exist.                                        |
340 |              |                                                              |
341 |              | SLA is optional. The SLA in this test case serves as an      |
342 |              | example. Considerably higher throughput and lower latency    |
343 |              | are expected. However, to cover most configurations, both    |
344 |              | baremetal and fully virtualized  ones, this value should be  |
345 |              | possible to achieve and acceptable for black box testing.    |
346 |              | Many heavy IO applications start to suffer badly if the      |
347 |              | read/write bandwidths are lower than this.                   |
348 |              |                                                              |
349 +--------------+--------------------------------------------------------------+
350 |pre-test      | The test case image needs to be installed into Glance        |
351 |conditions    | with fio included in it.                                     |
352 |              |                                                              |
353 |              | No POD specific requirements have been identified.           |
354 |              |                                                              |
355 +--------------+--------------------------------------------------------------+
356 |test sequence | description and expected result                              |
357 |              |                                                              |
358 +--------------+--------------------------------------------------------------+
359 |step 1        | A host VM with fio installed is booted.                      |
360 |              |                                                              |
361 +--------------+--------------------------------------------------------------+
362 |step 2        | Yardstick is connected with the host VM by using ssh.        |
363 |              | 'fio_benchmark' bash script is copyied from Jump Host to     |
364 |              | the host VM via the ssh tunnel.                              |
365 |              |                                                              |
366 +--------------+--------------------------------------------------------------+
367 |step 3        | 'fio_benchmark' script is invoked. Simulated IO operations   |
368 |              | are started. IOPS, disk read/write bandwidth and latency are |
369 |              | recorded and checked against the SLA. Logs are produced and  |
370 |              | stored.                                                      |
371 |              |                                                              |
372 |              | Result: Logs are stored.                                     |
373 |              |                                                              |
374 +--------------+--------------------------------------------------------------+
375 |step 4        | The host VM is deleted.                                      |
376 |              |                                                              |
377 +--------------+--------------------------------------------------------------+
378 |test verdict  | Fails only if SLA is not passed, or if there is a test case  |
379 |              | execution problem.                                           |
380 |              |                                                              |
381 +--------------+--------------------------------------------------------------+
382
383 TODO
384
385 How can I contribute to Yardstick?
386 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
387
388 If you are already a contributor of any OPNFV project, you can contribute to
389 Yardstick. If you are totally new to OPNFV, you must first create your Linux
390 Foundation account, then contact us in order to declare you in the repository
391 database.
392
393 We distinguish 2 levels of contributors:
394
395 * the standard contributor can push patch and vote +1/0/-1 on any Yardstick patch
396 * The commitor can vote -2/-1/0/+1/+2 and merge
397
398 Yardstick commitors are promoted by the Yardstick contributors.
399
400 Gerrit & JIRA introduction
401 ++++++++++++++++++++++++++
402
403 .. _Gerrit: https://www.gerritcodereview.com/
404 .. _`OPNFV Gerrit`: http://gerrit.opnfv.org/
405 .. _link: https://identity.linuxfoundation.org/
406 .. _JIRA: https://jira.opnfv.org/secure/Dashboard.jspa
407
408 OPNFV uses Gerrit_ for web based code review and repository management for the
409 Git Version Control System. You can access `OPNFV Gerrit`_. Please note that
410 you need to have Linux Foundation ID in order to use OPNFV Gerrit. You can get
411 one from this link_.
412
413 OPNFV uses JIRA_ for issue management. An important principle of change
414 management is to have two-way trace-ability between issue management
415 (i.e. JIRA_) and the code repository (via Gerrit_). In this way, individual
416 commits can be traced to JIRA issues and we also know which commits were used
417 to resolve a JIRA issue.
418
419 If you want to contribute to Yardstick, you can pick a issue from Yardstick's
420 JIRA dashboard or you can create you own issue and submit it to JIRA.
421
422 Install Git and Git-reviews
423 +++++++++++++++++++++++++++
424
425 Installing and configuring Git and Git-Review is necessary in order to submit
426 code to Gerrit. The
427 `Getting to the code <https://wiki.opnfv.org/display/DEV/Developer+Getting+Started>`_
428 page will provide you with some help for that.
429
430
431 Verify your patch locally before submitting
432 +++++++++++++++++++++++++++++++++++++++++++
433
434 Once you finish a patch, you can submit it to Gerrit for code review. A
435 developer sends a new patch to Gerrit will trigger patch verify job on Jenkins
436 CI. The yardstick patch verify job includes python pylint check, unit test and
437 code coverage test. Before you submit your patch, it is recommended to run the
438 patch verification in your local environment first.
439
440 Open a terminal window and set the project's directory to the working
441 directory using the ``cd`` command. Assume that ``YARDSTICK_REPO_DIR`` is the
442 path to the Yardstick project folder on your computer::
443
444   cd $YARDSTICK_REPO_DIR
445
446 Verify your patch::
447
448   tox
449
450 It is used in CI but also by the CLI.
451
452 For more details on ``tox`` and tests, please refer to the `Running tests`_
453 and `working with tox`_ sections below, which describe the different available
454 environments.
455
456 Submit the code with Git
457 ++++++++++++++++++++++++
458
459 Tell Git which files you would like to take into account for the next commit.
460 This is called 'staging' the files, by placing them into the staging area,
461 using the ``git add`` command (or the synonym ``git stage`` command)::
462
463   git add $YARDSTICK_REPO_DIR/samples/sample.yaml
464
465 Alternatively, you can choose to stage all files that have been modified (that
466 is the files you have worked on) since the last time you generated a commit,
467 by using the `-a` argument::
468
469   git add -a
470
471 Git won't let you push (upload) any code to Gerrit if you haven't pulled the
472 latest changes first. So the next step is to pull (download) the latest
473 changes made to the project by other collaborators using the ``pull`` command::
474
475   git pull
476
477 Now that you have the latest version of the project and you have staged the
478 files you wish to push, it is time to actually commit your work to your local
479 Git repository::
480
481   git commit --signoff -m "Title of change"
482
483   Test of change that describes in high level what was done. There is a lot of
484   documentation in code so you do not need to repeat it here.
485
486   JIRA: YARDSTICK-XXX
487
488 .. _`this document`: http://chris.beams.io/posts/git-commit/
489
490 The message that is required for the commit should follow a specific set of
491 rules. This practice allows to standardize the description messages attached
492 to the commits, and eventually navigate among the latter more easily.
493
494 `This document`_ happened to be very clear and useful to get started with that.
495
496 Push the code to Gerrit for review
497 ++++++++++++++++++++++++++++++++++
498
499 Now that the code has been comitted into your local Git repository the
500 following step is to push it online to Gerrit for it to be reviewed. The
501 command we will use is ``git review``::
502
503   git review
504
505 This will automatically push your local commit into Gerrit. You can add
506 Yardstick committers and contributors to review your codes.
507
508 .. image:: images/review.PNG
509    :width: 800px
510    :alt: Gerrit for code review
511
512 You can find a list Yardstick people
513 `here <https://wiki.opnfv.org/display/yardstick/People>`_, or use the
514 ``yardstick-reviewers`` and ``yardstick-committers`` groups in gerrit.
515
516 Modify the code under review in Gerrit
517 ++++++++++++++++++++++++++++++++++++++
518
519 At the same time the code is being reviewed in Gerrit, you may need to edit it
520 to make some changes and then send it back for review. The following steps go
521 through the procedure.
522
523 Once you have modified/edited your code files under your IDE, you will have to
524 stage them. The ``git status`` command is very helpful at this point as it
525 provides an overview of Git's current state::
526
527   git status
528
529 This command lists the files that have been modified since the last commit.
530
531 You can now stage the files that have been modified as part of the Gerrit code
532 review addition/modification/improvement using ``git add`` command. It is now
533 time to commit the newly modified files, but the objective here is not to
534 create a new commit, we simply want to inject the new changes into the
535 previous commit. You can achieve that with the '--amend' option on the
536 ``git commit`` command::
537
538   git commit --amend
539
540 If the commit was successful, the ``git status`` command should not return the
541 updated files as about to be commited.
542
543 The final step consists in pushing the newly modified commit to Gerrit::
544
545   git review
546
547 Backporting changes to stable branches
548 --------------------------------------
549 During the release cycle, when master and the ``stable/<release>`` branch have
550 diverged, it may be necessary to backport (cherry-pick) changes top the
551 ``stable/<release>`` branch once they have merged to master.
552 These changes should be identified by the committers reviewing the patch.
553 Changes should be backported **as soon as possible** after merging of the
554 original code.
555
556 ..note::
557   Besides the commit and review process below, the Jira tick must be updated to
558   add dual release versions and indicate that the change is to be backported.
559
560 The process for backporting is as follows:
561
562 * Committer A merges a change to master (process for normal changes).
563 * Committer A cherry-picks the change to ``stable/<release>`` branch (if the
564   bug has been identified for backporting).
565 * The original author should review the code and verify that it still works
566   (and give a ``+1``).
567 * Committer B reviews the change, gives a ``+2`` and merges to
568   ``stable/<release>``.
569
570 A backported change needs a ``+1`` and a ``+2`` from a committer who didn’t
571 propose the change (i.e. minimum 3 people involved).
572
573 Development guidelines
574 ----------------------
575 This section provides guidelines and best practices for feature development
576 and bug fixing in Yardstick.
577
578 In general, bug fixes should be submitted as a single patch.
579
580 When developing larger features, all commits on the local topic branch can be
581 submitted together, by running ``git review`` on the tip of the branch. This
582 creates a chain of related patches in gerrit.
583
584 Each commit should contain one logical change and the author should aim for no
585 more than 300 lines of code per commit. This helps to make the changes easier
586 to review.
587
588 Each feature should have the following:
589
590 * Feature/bug fix code
591 * Unit tests (both positive and negative)
592 * Functional tests (optional)
593 * Sample testcases (if applicable)
594 * Documentation
595 * Update to release notes
596
597 Coding style
598 ~~~~~~~~~~~~
599 .. _`OpenStack Style Guidelines`: https://docs.openstack.org/hacking/latest/user/hacking.html
600 .. _`OPNFV coding guidelines`: https://wiki.opnfv.org/display/DEV/Contribution+Guidelines
601
602 Please follow the `OpenStack Style Guidelines`_ for code contributions (the
603 section on Internationalization (i18n) Strings is not applicable).
604
605 When writing commit message, the `OPNFV coding guidelines`_ on git commit
606 message style should also be used.
607
608 Running tests
609 ~~~~~~~~~~~~~
610 Once your patch has been submitted, a number of tests will be run by Jenkins
611 CI to verify the patch. Before submitting your patch, you should run these
612 tests locally. You can do this using ``tox``, which has a number of different
613 test environments defined in ``tox.ini``.
614 Calling ``tox`` without any additional arguments runs the default set of
615 tests (unit tests, functional tests, coverage and pylint).
616
617 If some tests are failing, you can save time and select test environments
618 individually, by passing one or more of the following command-line options to
619 ``tox``:
620
621 * ``-e py27``: Unit tests using Python 2.7
622 * ``-e py3``: Unit tests using Python 3
623 * ``-e pep8``: Linter and style checks on updated files
624 * ``-e functional``: Functional tests using Python 2.7
625 * ``-e functional-py3``: Functional tests using Python 3
626 * ``-e coverage``: Code coverage checks
627
628 .. note:: You need to stage your changes prior to running coverage for those
629    changes to be checked.
630
631 In addition to the tests run by Jenkins (listed above), there are a number of
632 other test environments defined.
633
634 * ``-e pep8-full``: Linter and style checks are run on the whole repo (not
635   just on updated files)
636 * ``-e os-requirements``: Check that the requirements are compatible with
637   OpenStack requirements.
638
639 Working with tox
640 ++++++++++++++++
641 .. _virtualenv: https://virtualenv.pypa.io/en/stable/
642
643 ``tox`` uses `virtualenv`_ to create isolated Python environments to run the
644 tests in. The test environments are located at
645 ``.tox/<environment_name>`` e.g. ``.tox/py27``.
646
647 If requirements are changed, you will need to recreate the tox test
648 environment to make sure the new requirements are installed. This is done by
649 passing the additional ``-r`` command-line option to ``tox``::
650
651     tox -r -e ...
652
653 This can also be achieved by deleting the test environments manually before
654 running ``tox``::
655
656    rm -rf .tox/<environment_name>
657    rm -rf .tox/py27
658
659 Writing unit tests
660 ~~~~~~~~~~~~~~~~~~
661 For each change submitted, a set of unit tests should be submitted, which
662 should include both positive and negative testing.
663
664 In order to help identify which tests are needed, follow the guidelines below.
665
666 * In general, there should be a separate test for each branching point, return
667   value and input set.
668 * Negative tests should be written to make sure exceptions are raised and/or
669   handled appropriately.
670
671 The following convention should be used for naming tests::
672
673     test_<method_name>_<some_comment>
674
675 The comment gives more information on the nature of the test, the side effect
676 being checked, or the parameter being modified::
677
678     test_my_method_runtime_error
679     test_my_method_invalid_credentials
680     test_my_method_param1_none
681
682 Mocking
683 +++++++
684 The ``mock`` library is used for unit testing to stub out external libraries.
685
686 The following conventions are used in Yardstick:
687
688 * Use ``mock.patch.object`` instead of ``mock.patch``.
689
690 * When naming mocked classes/functions, use ``mock_<class_and_function_name>``
691   e.g. ``mock_subprocess_call``
692
693 * Avoid decorating classes with mocks. Apply the mocking in ``setUp()``::
694
695     @mock.patch.object(ssh, 'SSH')
696     class MyClassTestCase(unittest.TestCase):
697
698   should be::
699
700     class MyClassTestCase(unittest.TestCase):
701         def setUp(self):
702             self._mock_ssh = mock.patch.object(ssh, 'SSH')
703             self.mock_ssh = self._mock_ssh.start()
704
705             self.addCleanup(self._stop_mocks)
706
707         def _stop_mocks(self):
708             self._mock_ssh.stop()
709
710 Plugins
711 -------
712
713 For information about Yardstick plugins, refer to the chapter
714 **Installing a plug-in into Yardstick** in the `user guide`_.
715