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
|
#!/usr/bin/env python
#
# See the file LICENSE for redistribution information.
#
# Copyright (c) 2011 WiredTiger, Inc.
# All rights reserved.
#
# wtscenarios.py
# Support scenarios based testing
#
import testscenarios
def powerrange(start, stop, mult):
"""
Like xrange, generates a range from start to stop.
Unlike xrange, the range is inclusive of stop,
each step is multiplicative, and as a special case,
the stop value is returned as the last item.
"""
val = start
while val <= stop:
yield val
newval = val * mult
if val < stop and newval > stop:
val = stop
else:
val = newval
def log2chr(val):
"""
For the log-base 2 of val, return the numeral or letter
corresponding to val (which is < 36). Hence, 1 return '0',
2 return '1', 2*15 returns 'f', 2*16 returns 'g', etc.
"""
p = 0
while val >= 2:
p += 1
val /= 2
if p < 10:
return chr(ord('0') + p)
else:
return chr(ord('a') + p - 10)
megabyte = 1024 * 1024
class wtscenario:
"""
A set of generators for different test scenarios
"""
@staticmethod
def session_create_scenario():
"""
Return a set of scenarios with the name of this method
'session_create_scenario' as the name of instance
variable containing a wtscenario object. The wtscenario
object can be queried to get a config string.
Each scenario is named according to the shortName() method.
"""
s = [
('default', dict(session_create_scenario=wtscenario())) ]
for imin in powerrange(512, 512*megabyte, 1024):
for imax in powerrange(imin, 512*megabyte, 1024):
for lmin in powerrange(512, 512*megabyte, 1024):
for lmax in powerrange(lmin, 512*megabyte, 1024):
scen = wtscenario()
scen.imin = imin
scen.imax = imax
scen.lmin = lmin
scen.lmax = lmax
s.append((scen.shortName(), dict(session_create_scenario=scen)))
return s
def shortName(self):
"""
Return a name of a scenario, based on the 'log2chr-ed numerals'
representing the four values for {internal,leaf} {minimum, maximum}
page size.
"""
return 'scen_' + log2chr(self.imin) + log2chr(self.imax) + log2chr(self.lmin) + log2chr(self.lmax)
def configString(self):
"""
Return the associated configuration string
"""
res = ''
if hasattr(self, 'imin'):
res += ',internal_node_min=' + str(self.imin)
if hasattr(self, 'imax'):
res += ',internal_node_max=' + str(self.imax)
if hasattr(self, 'lmin'):
res += ',leaf_node_min=' + str(self.lmin)
if hasattr(self, 'lmax'):
res += ',leaf_node_max=' + str(self.lmax)
return res
|