1TEST_UTIL(3)                     test_util 1.6                    TEST_UTIL(3)
2
3
4

NAME

6       nfstest.test_util - Test utilities module
7

DESCRIPTION

9       Provides  a  set  of tools for testing either the NFS client or the NFS
10       server, most of the functionality is  focused  mainly  on  testing  the
11       client.  These tools include the following:
12
13           - Process command line arguments
14           - Provide functionality for PASS/FAIL
15           - Provide test grouping functionality
16           - Provide multiple client support
17           - Logging mechanism
18           - Debug info control
19           - Mount/Unmount control
20           - Create files/directories
21           - Provide mechanism to start a packet trace
22           - Provide mechanism to simulate a network partition
23           - Support for pNFS testing
24
25       In order to use some of the functionality available, the user id in all
26       the client hosts must have access to run commands  as  root  using  the
27       'sudo'  command without the need for a password, this includes the host
28       where the test is being executed. This is used  to  run  commands  like
29       'mount'  and  'umount'. Furthermore, the user id must be able to ssh to
30       remote hosts without the need for a password if test requires  the  use
31       of multiple clients.
32
33       Network  partition  is  simulated  by  the use of 'iptables', please be
34       advised that after every test run the iptables is flushed and reset  so
35       any  rules previously setup will be lost. Currently, there is no mecha‐
36       nism to restore the iptables rules to their original state.
37

CLASSES

39   class TestUtil(nfstest.nfs_util.NFSUtil)
40       TestUtil object
41
42       TestUtil() -> New server object
43
44       Usage:
45           x = TestUtil()
46
47           # Process command line options
48           x.scan_options()
49
50           # Start packet trace using tcpdump
51           x.trace_start()
52
53           # Mount volume
54           x.mount()
55
56           # Create file
57           x.create_file()
58
59           # Unmount volume
60           x.umount()
61
62           # Stop packet trace
63           x.trace_stop()
64
65           # Exit script
66           x.exit()
67
68
69       Methods defined here:
70       ---------------------
71
72       __del__(self)
73       Destructor
74
75       Gracefully stop the packet trace, cleanup files, unmount volume,
76       and reset network.
77
78       __init__(self, **kwargs)
79       Constructor
80
81       Initialize object's private data.
82
83
84              sid:   Test script ID [default: '']
85                     This is used to have options targeted for a given ID without
86                     including these options in any other test script.
87
88              usage: Usage string [default: '']
89
90              testnames:
91                     List of test names [default: []]
92                     When this list is not empty, the --runtest option is enabled and
93                     test scripts should use the run_tests() method to run all the
94                     tests. Test script should have methods named as <testname>_test.
95
96              testgroups:
97                     Dictionary of test groups where the key is the name of the test
98                     group and its value is a dictionary having the following keys:
99                     tests:
100                     A list of tests belonging to this test group
101                     desc:
102                     Description of the test group, this is displayed
103                     in the help if the name of the test group is also
104                     included in testnames
105                     tincl:
106                     Include a comma separated list of tests belonging to
107                     this test group to the description [default: False]
108                     wrap:
109                     Reformat the description so it fits in lines no
110                     more than the width given. The description is not
111                     formatted for a value of zero [default: 72]
112
113              Example:
114                  x = TestUtil(testnames=['basic', 'lock'])
115
116                  # The following methods should exist:
117                  x.basic_test()
118                  x.lock_test()
119
120       cleanup(self, newline=True)
121       Clean up test environment.
122
123       Remove any files created: test files, trace files.
124
125       close_files(self)
126       Close all files opened by open_files().
127
128       config(self, msg)
129       Display config message and terminate test with an exit value of 2.
130
131       create_dir(self, dir=None, mode=493)
132       Create a directory under the given directory with the given mode.
133
134       create_file(self, offset=0, size=None, dir=None, mode=None, **kwds)
135       Create a file starting to write at given offset with total size
136       of written data given by the size option.
137
138
139              offset:
140                     File offset where data will be written to [default: 0]
141
142              size:  Total number of bytes to write [default: --filesize option]
143
144              dir:   Create file under this directory
145
146              mode:  File permissions [default: use default OS permissions]
147
148              pattern:
149                     Data pattern to write to the file [default: data_pattern default]
150
151              ftype: File type to create [default: FTYPE_FILE]
152
153              hole_list:
154                     List of offsets where each hole is located [default: None]
155
156              hole_size:
157                     Size of each hole [default: --wsize option]
158
159              Returns the file name created, the file name is also stored
160              in the object attribute filename -- attribute absfile is also
161              available as the absolute path of the file just created.
162
163              File created is removed at cleanup.
164
165       create_rexec(self, servername=None, **kwds)
166       Create remote server object.
167
168       data_pattern(self, offset, size, pattern=None)
169       Return data pattern.
170
171
172              offset:
173                     Starting offset of pattern
174
175              size:  Size of data to return
176
177              pattern:
178                     Data pattern to return, default is of the form:
179                     hex_offset(0x%08X) abcdefghijklmnopqrst
180
181       delay_io(self, delay=None)
182       Delay I/O by value given or the value given in --iodelay option.
183
184       exit(self)
185       Terminate script with an exit value of 0 when all tests passed
186       and a value of 1 when there is at least one test failure.
187
188       get_dirname(self, dir=None)
189       Return a unique directory name under the given directory.
190
191       get_filename(self, dir=None)
192       Return a unique file name under the given directory.
193
194       get_logname(self)
195       Get next log file name.
196
197       get_name(self)
198       Get unique name for this instance.
199
200       lock_files(self, lock_type=None, offset=0, length=0)
201       Lock all files opened by open_files().
202
203       open_files(self, mode, create=True)
204       Open files according to given mode, the file descriptors are saved
205       internally to be used with write_files(), read_files() and
206       close_files(). The number of files to open is controlled by
207       the command line option '--nfiles'.
208
209       The mode could be either 'r' or 'w' for opening files for reading
210       or writing respectively. The open flags for mode 'r' is O_RDONLY
211       while for mode 'w' is O_WRONLY|O_CREAT|O_SYNC. The O_SYNC is used
212       to avoid the client buffering the written data.
213
214       read_files(self)
215       Read a block of data (size given by --rsize) from all files opened
216       by open_files() for reading.
217
218       run_tests(self, **kwargs)
219       Run all test specified by the --runtest option.
220
221
222              testnames:
223                     List of testnames to run [default: all tests given by --testnames]
224
225              All other arguments given are passed to the test methods.
226
227       scan_options(self)
228       Process command line options.
229
230       Process all the options in the file given by '--file', then the
231       ones in the command line. This allows for command line options
232       to over write options given in the file.
233
234       Format of options file:
235           # For options expecting a value
236           <option_name> = <value>
237
238           # For boolean (flag) options
239           <option_name>
240
241       Process options files and make sure not to process the same file
242       twice, this is used for the case where HOMECFG and CWDCFG are the
243       same, more specifically when environment variable HOME is not
244       defined. Also, the precedence order is defined as follows:
245         1. options given in command line
246         2. options given in file specified by the -f|--file option
247         3. options given in file specified by ./.nfstest
248         4. options given in file specified by $HOME/.nfstest
249         5. options given in file specified by /etc/nfstest
250
251       NOTE:
252         Must use the long name of the option (--<option_name>) in the file.
253
254       setup(self, nfiles=None)
255       Set up test environment.
256
257       Create nfiles number of files [default: --nfiles option]
258
259       test(self, expr, msg, subtest=None, failmsg=None, terminate=False)
260       Test expr and display message as PASS/FAIL, terminate execution
261       if terminate option is True.
262
263
264              expr:  If expr is true, display as a PASS message,
265                     otherwise as a FAIL message
266
267              msg:   Message to display
268
269              subtest:
270                     If given, append this string to the displayed message and
271                     mark this test as a member of the sub-group given by msg
272
273              failmsg:
274                     If given, append this string to the displayed message when
275                     expr is false [default: None]
276
277              terminate:
278                     Terminate execution if true and expr is false [default: False]
279
280              If tverbose=normal or level 1:
281                  Sub-group message is displayed as a PASS/FAIL message including
282                  the number of tests that passed and failed within the sub-group
283              If tverbose=verbose or level 2:
284                  All tests messages are displayed
285
286       test_group(self, msg)
287       Display heading message and start a test group.
288
289       If tverbose=group or level 0:
290           Group message is displayed as a PASS/FAIL message including the
291           number of tests that passed and failed within this test group.
292       If tverbose=normal|verbose or level 1|2:
293           Group message is displayed as a heading messages for the tests
294           belonging to this test group.
295
296       test_info(self, msg)
297       Display info message.
298
299       test_options(self, name=None)
300       Get options for the given test name. If the test name is not given
301       it is determined by inspecting the stack to find which method is
302       calling this method.
303
304       testid_count(self, tid)
305       Return the number of instances the testid has occurred.
306
307       warning(self, msg)
308       Display warning message.
309
310       write_data(self, fd, offset=0, size=None, pattern=None)
311       Write data to the file given by the file descriptor
312
313
314              fd:    File descriptor
315
316              offset:
317                     File offset where data will be written to [default: 0]
318
319              size:  Total number of bytes to write [default: --filesize option]
320
321              pattern:
322                     Data pattern to write to the file [default: data_pattern default]
323
324       write_files(self)
325       Write a block of data (size given by --wsize) to all files opened
326       by open_files() for writing.
327
328       Static methods defined here:
329       ----------------------------
330
331       get_list(value, hash, type=<type 'str'>)
332       Return a list of elements from the comma separated string.
333       Validate and translate these elements using the input dictionary
334       'hash' where every element in the string is the key of 'hash'
335       and its value is appended to the returned list.
336
337       str_list(value, type=<type 'str'>, sep=',')
338       Return a list of <type> elements from the comma separated string.
339

SEE ALSO

341       baseobj(3), formatstr(3), nfstest.host(3), nfstest.nfs_util(3)
342
343

BUGS

345       No known bugs.
346

AUTHOR

348       Jorge Mora (mora@netapp.com)
349
350
351
352NFStest 2.1.5                  14 February 2017                   TEST_UTIL(3)
Impressum