~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to nova/tests/hyperv/README.rst

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, Adam Gandelman
  • Date: 2013-02-22 09:27:29 UTC
  • mfrom: (1.1.68)
  • Revision ID: package-import@ubuntu.com-20130222092729-nn3gt8rf97uvts77
Tags: 2013.1.g3-0ubuntu1
[ Chuck Short ]
* New usptream release. 
* debian/patches/debian/patches/fix-ubuntu-tests.patch: Refreshed.
* debian/nova-baremetal.logrotate: Fix logfile path.
* debian/control, debian/nova-spiceproxy.{install, logrotate, upstart}:
  Add spice html5 proxy support.
* debian/nova-novncproxy.upstart: Start on runlevel [2345]
* debian/rules: Call testr directly since run_tests.sh -N gives weird return
  value when tests pass.
* debian/pyddist-overrides: Add websockify.
* debian/nova-common.postinst: Removed config file conversion, since
  the option is no longer available. (LP: #1110567)
* debian/control: Add python-pyasn1 as a dependency.
* debian/control: Add python-oslo-config as a dependency.
* debian/control: Suggest sysfsutils, sg3-utils, multipath-tools for fibre
  channel support.

[ Adam Gandelman ]
* debian/control: Fix typo (websocikfy -> websockify).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
=====================================
2
 
OpenStack Hyper-V Nova Testing Architecture
3
 
=====================================
4
 
 
5
 
The Hyper-V Nova Compute plugin uses Windows Management Instrumentation (WMI)
6
 
as the main API for hypervisor related operations.
7
 
WMI has a database / procedural oriented nature that can become difficult to
8
 
test with a traditional static mock / stub based unit testing approach.
9
 
 
10
 
The included Hyper-V testing framework has been developed with the
11
 
following goals:
12
 
 
13
 
1) Dynamic mock generation.
14
 
2) Decoupling. No dependencies on WMI or any other module.
15
 
    The tests are designed to work with mocked objects in all cases, including
16
 
    OS-dependent (e.g. wmi, os, subprocess) and non-deterministic
17
 
    (e.g. time, uuid) modules
18
 
3) Transparency. Mocks and real objects can be swapped via DI
19
 
    or monkey patching.
20
 
4) Platform independence.
21
 
5) Tests need to be executed against the real object or against the mocks
22
 
    with a simple configuration switch. Development efforts can highly
23
 
    benefit from this feature.
24
 
6) It must be possible to change a mock's behavior without running the tests
25
 
    against the hypervisor (e.g. by manually adding a value / return value).
26
 
 
27
 
The tests included in this package include dynamically generated mock objects,
28
 
based on the recording of the attribute values and invocations on the
29
 
real WMI objects and other OS dependent features.
30
 
The generated mock objects are serialized in the nova/tests/hyperv/stubs
31
 
directory as gzipped pickled objects.
32
 
 
33
 
An environment variable controls the execution mode of the tests.
34
 
 
35
 
Recording mode:
36
 
 
37
 
NOVA_GENERATE_TEST_MOCKS=True
38
 
Tests are executed on the hypervisor (without mocks), and mock objects are
39
 
generated.
40
 
 
41
 
Replay mode:
42
 
 
43
 
NOVA_GENERATE_TEST_MOCKS=
44
 
Tests are executed with the existing mock objects (default).
45
 
 
46
 
Mock generation is performed by nova.tests.hyperv.mockproxy.MockProxy.
47
 
Instances of this class wrap objects that need to be mocked and act as a
48
 
delegate on the wrapped object by leveraging Python's __getattr__ feature.
49
 
Attribute values and method call return values are recorded at each access.
50
 
Objects returned by attributes and method invocations are wrapped in a
51
 
MockProxy consistently.
52
 
From a caller perspective, the MockProxy is completely transparent,
53
 
with the exception of calls to the type(...) builtin function.
54
 
 
55
 
At the end of the test, a mock is generated by each MockProxy by calling
56
 
the get_mock() method. A mock is represented by an instance of the
57
 
nova.tests.hyperv.mockproxy.Mock class.
58
 
 
59
 
The Mock class task consists of replicating the behaviour of the mocked
60
 
objects / modules by returning the same values in the same order, for example:
61
 
 
62
 
def check_path(path):
63
 
    if not os.path.exists(path):
64
 
        os.makedirs(path)
65
 
 
66
 
check_path(path)
67
 
# The second time os.path.exists returns True
68
 
check_path(path)
69
 
 
70
 
The injection of MockProxy / Mock instances is performed by the
71
 
nova.tests.hyperv.basetestcase.BaseTestCase class in the setUp()
72
 
method via selective monkey patching.
73
 
Mocks are serialized in tearDown() during recording.
74
 
 
75
 
The actual Hyper-V test case inherits from BaseTestCase:
76
 
nova.tests.hyperv.test_hypervapi.HyperVAPITestCase
77
 
 
78
 
 
79
 
Future directions:
80
 
 
81
 
1) Replace the pickled files with a more generic serialization option (e.g. json)
82
 
2) Add methods to statically extend the mocks (e.g. method call return values)
83
 
3) Extend an existing framework, e.g. mox