-
Notifications
You must be signed in to change notification settings - Fork 26
/
README
169 lines (116 loc) · 6.61 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
Testing
-------
All of the following `make` commands run the tests in the currently active
Python environment, and need to be invoked in the Git repo work directory.
By default, the tests use the `pywbem` and `pywbem_mock` modules from the
respective directories in the Git repo work directory.
Pywbem 0.14.5 introduced a way to test installed versions of the pywbem
package. For details, see section "Testing installed versions of pywbem".
The `tests` directory has the following subdirectory structure:
tests
+-- unittest Unit tests
| +-- utils Utility functions used by unit tests
| +-- pywbem Unit tests for the pywbem package
| +-- pywbem_mock Unit tests for the pywbem_mock package
| +-- unittest_utils Unit tests for tests/unittest/utils
| +-- functiontest Unit tests for tests/functiontest
| +-- end2endtest_utils Unit tests for tests/end2endtest/utils
| +-- servers Unit tests for tests/servers
+-- functiontest Function tests
+-- end2endtest End2end tests
| +-- utils Utility functions used by end2end tests
+-- manualtest Manual tests
+-- server_definitions WBEM server definition file used by some tests and module
| for accessing it
+-- profiles Simple definitions of management profiles used by some tests
+-- schema The CIM schema MOF files used by some MOF tests
+-- dtd The CIM DTD file used by some CIM-XML validation tests
There are multiple types of tests in pywbem:
1. Unit tests and function tests
These tests do not require any WBEM server to be available, and the tests
validate their results automatically.
The distinction between unit tests and function tests as used in pywbem is
that function tests exercise the entire pywbem client component or entire
pywbem scripts, while unit tests exercise single modules.
They are run by executing:
$ make test
Test execution can be modified by a number of environment variables, as
documented in the make help (execute `make help`).
2. End2end tests
These tests are run against one or more WBEM servers, and the tests validate
their results automatically.
They are run by preparing a server definition file:
tests/server_definitions/server_definition_file.yml
from the provided example, and by executing:
$ make end2end
Again, test execution can be modified by a number of environment variables,
as documented in the make help (execute `make help`).
3. Manual tests
There are several Python scripts and shell scripts that can be run manually.
The results need to be validated manually.
These scripts are in the directory:
tests/manualtest/
and are executed by simply invoking them from within the main directory
of the repository, and providing that main directory as a Python package
path, e.g.:
PYTHONPATH=. tests/manualtest/run_cim_operations.py
Some of the scripts support a `--help` option that informs about their
usage.
The `run_cim_operations.py` script needs a particular MOF file loaded in the
repository of the WBEM server that is used for the test. This can be done
using the MOF compiler of pywbem:
$ mof_compiler -s <target_url> tests/unittest/pywbem/test.mof
To run the unit and function tests in all supported Python environments, the
Tox tool can be used. It creates the necessary virtual Python environments and
executes `make test` (i.e. the unit and function tests) in each of them.
For running Tox, it does not matter which Python environment is currently
active, as long as the Python `tox` package is installed in it:
$ tox # Run tests on all supported Python versions
$ tox -e py27 # Run tests on Python 2.7
Testing installed versions of pywbem
------------------------------------
By default, the tests use the pywbem and pywbem_mock modules from the
respective directories in the Git repo work directory.
Pywbem 0.14.5 introduced a way to test installed versions of the pywbem
package. This is useful for example for testing a version of pywbem that has
been packaged as an OS-level package. Typically, such a version would be
installed into the system Python.
In order to not clutter up the system Python with Python packages needed for
running the pywbem tests, the following steps use a virtual Python environment
that uses the packages of the system Python. That way, the installed version of
pywbem becomes available to the virtual Python environment from the system
Python, while any additional packages that are needed but not yet available
that way, will be installed into the virtual Python environment.
Follow these steps to run pywbem tests against a version of pywbem that is
installed into the system Python:
1. Verify that the following commands are available when the system Python
is active:
$ virtualenv --version # Python virtualenv package
$ pip --version
2. Create and activate a virtual Python environment of the intended Python
version, that is based on the system Python:
$ virtualenv --system-site-packages --no-setuptools --no-pip --no-wheel .virtualenv/test
$ source .virtualenv/test/bin/activate
The pywbem project is set up so that Git ignores the ``.virtualenv``
directory, so use that directory name for ease of Git handling.
3. Verify that in that virtual Python environment, pywbem comes from the
intended installation:
$ pip show pywbem
4. Ensure a fresh start of the make process. This should be done whenever
switching between the installed version of pywbem and the local directories:
$ make clobber
5. Run the pywbem tests with environment variable ``TEST_INSTALLED`` being set:
$ TEST_INSTALLED=1 make test
This will assume that the pywbem package and any prerequisite Python
packages and OS-level packages are already installed.
This will also move the current directory (i.e. the repo working directory)
to the end of the module search path, so that the installed version of
pywbem is used when importing it into the test scripts.
Setting ``TEST_INSTALLED=DEBUG`` causes some debug messages to be printed
that allow verifying from where the pywbem and pywbem_mock modules
are loaded.
This also works for the pywbem end2end tests:
$ TEST_INSTALLED=1 make end2end
Note that tox does not support creating its virtual Python environments
based on the system Python, so at this point, tox cannot be used for this
approach.