1 | -*- indented-text -*-
|
---|
2 |
|
---|
3 | (set lotus no)
|
---|
4 |
|
---|
5 |
|
---|
6 |
|
---|
7 | Notes on using comfychair with Samba (samba testing framework units):
|
---|
8 |
|
---|
9 | The tests need to rely on some external resources, such as
|
---|
10 |
|
---|
11 | If suitable resources are not available, need to skip particular
|
---|
12 | tests. Must include a message indicating what resources would be
|
---|
13 | needed to run that test. (e.g. must be root.)
|
---|
14 |
|
---|
15 | We want to be able to select and run particular subsets of tests, such
|
---|
16 | as "all winbind tests".
|
---|
17 |
|
---|
18 | We want to keep the number of configurable parameters down as much as
|
---|
19 | possible, to make it easy on people running the tests.
|
---|
20 |
|
---|
21 | Wherever possible, the tests should set up their preconditions, but a
|
---|
22 | few basic resources need to be provided by the people running the
|
---|
23 | tests. So for example, rather than asking the user for the name of a
|
---|
24 | non-root user, we should give the tests the administrator name and
|
---|
25 | password, and it can create a new user to use.
|
---|
26 |
|
---|
27 | This makes it simpler to get the tests running, and possible also
|
---|
28 | makes them more reproducible.
|
---|
29 |
|
---|
30 | In the future, rather than using NT machines provided by the test
|
---|
31 | person, we might have a way to drive VMWare non-persistent sessions,
|
---|
32 | to make tests even more tightly controlled.
|
---|
33 |
|
---|
34 |
|
---|
35 | Another design question is how to communicate this information to the
|
---|
36 | tests. If there's a lot of settings, then it might need to be stored
|
---|
37 | in a configuration file.
|
---|
38 |
|
---|
39 | However, if we succeed in cutting down the number of parameters, then
|
---|
40 | it might be straightforward to pass the information on the command
|
---|
41 | line or in an environment variable.
|
---|
42 |
|
---|
43 | Environment variables are probably better because they can't be seen
|
---|
44 | by other users, and they are more easily passed down through an
|
---|
45 | invocation of "make check".
|
---|
46 |
|
---|
47 |
|
---|
48 | |
---|
49 |
|
---|
50 | Notes on Samba Testing Framework for Unittests
|
---|
51 | ----------------------------------------------
|
---|
52 |
|
---|
53 | This is to be read after reading the notes.txt from comfychair. I'm
|
---|
54 | proposing a slightly more concrete description of what's described
|
---|
55 | there.
|
---|
56 |
|
---|
57 | The model of having tests require named resources looks useful for
|
---|
58 | incorporation into a framework that can be run by many people in
|
---|
59 | widely different environments.
|
---|
60 |
|
---|
61 | Some possible environments for running the test framework in are:
|
---|
62 |
|
---|
63 | - Casual downloader of Samba compiling from source and just wants
|
---|
64 | to run 'make check'. May only have one Unix machine and a
|
---|
65 | handful of clients.
|
---|
66 |
|
---|
67 | - Samba team member with access to a small number of other
|
---|
68 | machines or VMware sessions.
|
---|
69 |
|
---|
70 | - PSA developer who may not have intimate knowledge of Samba
|
---|
71 | internals and is only interested in testing against the PSA.
|
---|
72 |
|
---|
73 | - Non-team hacker wanting to run test suite after making small
|
---|
74 | hacks.
|
---|
75 |
|
---|
76 | - Build farm environment (loaner machine with no physical access
|
---|
77 | or root privilege).
|
---|
78 |
|
---|
79 | - HP BAT.
|
---|
80 |
|
---|
81 | Developers in most of these environments are also potential test case
|
---|
82 | authors. It should be easy for people unfamiliar with the framework
|
---|
83 | to write new tests and have them work. We should provide examples and
|
---|
84 | the existing tests should well written and understandable.
|
---|
85 |
|
---|
86 | Different types of tests:
|
---|
87 |
|
---|
88 | - Tests that check Samba internals and link against
|
---|
89 | libbigballofmud.so. For example:
|
---|
90 |
|
---|
91 | - Upper/lowercase string functions
|
---|
92 | - user_in_list() for large lists
|
---|
93 |
|
---|
94 | - Tests that use the Samba Python extensions.
|
---|
95 |
|
---|
96 | - Tests that execute Samba command line programs, for example
|
---|
97 | smbpasswd.
|
---|
98 |
|
---|
99 | - Tests that require other resources on the network such as domain
|
---|
100 | controllers or PSAs.
|
---|
101 |
|
---|
102 | - Tests that are performed on the documentation or the source code
|
---|
103 | such as:
|
---|
104 |
|
---|
105 | - grep for common spelling mistakes made by abartlet (-:
|
---|
106 | - grep for company copyright (IBM, HP)
|
---|
107 |
|
---|
108 | - Link to other existing testing frameworks (smbtorture,
|
---|
109 | abartlet's bash based build farm tests)
|
---|
110 |
|
---|
111 | I propose a TestResourceManager which would be instantiated by a test
|
---|
112 | case. The test case would require("resourcename") as part of its
|
---|
113 | constructor and raise a comfychair.NotRun exception if the resource
|
---|
114 | was not present. A TestResource class could be defined which could
|
---|
115 | read a configuration file or examine a environment variable and
|
---|
116 | register a resource only if some condition was satisfied.
|
---|
117 |
|
---|
118 | It would be nice to be able to completely separate the PSA testing
|
---|
119 | from the test framework. This would entail being able to define test
|
---|
120 | resources dynamically, possibly with a plugin type system.
|
---|
121 |
|
---|
122 | class TestResourceManager:
|
---|
123 | def __init__(self, name):
|
---|
124 | self.resources = {}
|
---|
125 |
|
---|
126 | def register(self, resource):
|
---|
127 | name = resource.name()
|
---|
128 | if self.resources.has_key(name):
|
---|
129 | raise "Test manager already has resource %s" % name
|
---|
130 | self.resources[name] = resource
|
---|
131 |
|
---|
132 | def require(self, resource_name):
|
---|
133 | if not self.resources.has_key(resource_name):
|
---|
134 | raise "Test manager does not have resources %s" % resource_name
|
---|
135 |
|
---|
136 | class TestResource:
|
---|
137 | def __init__(self, name):
|
---|
138 | self.name = name
|
---|
139 |
|
---|
140 | def name(self):
|
---|
141 | return self.name
|
---|
142 |
|
---|
143 | import os
|
---|
144 |
|
---|
145 | trm = TestResourceManager()
|
---|
146 |
|
---|
147 | if os.getuid() == 0:
|
---|
148 | trm.register(TestResource("root"))
|
---|
149 |
|
---|
150 | A config-o-matic Python module can take a list of machines and
|
---|
151 | administrator%password entries and classify them by operating system
|
---|
152 | version and service pack. These resources would be registered with
|
---|
153 | the TestResourceManager.
|
---|
154 |
|
---|
155 | Some random thoughts about named resources for network servers:
|
---|
156 |
|
---|
157 | require("nt4.sp3")
|
---|
158 | require("nt4.domaincontroller")
|
---|
159 | require("psa")
|
---|
160 |
|
---|
161 | Some kind of format for location of passwords, libraries:
|
---|
162 |
|
---|
163 | require("exec(smbpasswd)")
|
---|
164 | require("lib(bigballofmud)")
|
---|
165 |
|
---|
166 | maybe require("exec.smbpasswd") looks nicer...
|
---|
167 |
|
---|
168 | The require() function could return a dictionary of configuration
|
---|
169 | information or some handle to fetch dynamic information on. We may
|
---|
170 | need to create and destroy extra users or print queues. How to manage
|
---|
171 | cleanup of dynamic resources?
|
---|
172 |
|
---|
173 | Requirements for running stf:
|
---|
174 |
|
---|
175 | - Python, obviously
|
---|
176 | - Samba python extensions
|
---|