forked from IIIF/htj2k
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocustfile.py
118 lines (107 loc) · 3.57 KB
/
locustfile.py
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
from locust import HttpUser, task, events
locations = {
'ptiff-lossy-round1': {
'loc': 'ptiff/lossy',
'ext': 'tif'
},
'ptiff-lossless-round1': {
'loc': 'ptiff/lossless',
'ext': 'tif'
},
'jp2-lossy-round1': {
'loc': 'jp2/lossy',
'ext': 'jp2'
},
'jp2-lossless-round1': {
'loc': 'jp2/lossless',
'ext': 'jp2'
},
'htj2k-lossy-round1': {
'loc': 'htj2k/lossy',
'ext': 'htj2k.jp2'
},
'htj2k-lossless-round1': {
'loc': 'htj2k/lossless',
'ext': 'htj2k.jp2'
},
'htj2k-bodelian-lossless': {
'loc': 'params/htj2k_digital_bodelian_lossless_codeblock_64,64',
'ext': 'jph'
},
'htj2k_bodelian_lossy': {
'loc': 'params/htj2k_digital_bodelian_lossy_codeblock_64,64',
'ext': 'jph'
},
'htj2k_lossless': {
'loc': 'params/htj2k_lossless_codeblock_64,64',
'ext': 'jph'
},
'htj2k_lossless_plt': {
'loc': 'params/htj2k_lossless_plt_codeblock_64,64',
'ext': 'jph'
},
'htj2k_lossy_3bpp_plt': {
'loc': 'params/htj2k_lossy_3bpp_plt_codeblock_64,64',
'ext': 'jph'
},
'htj2k_lossy_Qfactor_90_plt': {
'loc': 'params/htj2k_lossy_Qfactor_90_plt_codeblock_64,64',
'ext': 'jph'
},
'j2k_bodelian_lossless': {
'loc': 'params/j2k1_digital_bodelian_lossless_codeblock_64,64',
'ext': 'jp2'
},
'j2k1_bodelian_lossy': {
'loc': 'params/j2k1_digital_bodelian_lossy_codeblock_64,64',
'ext': 'jp2'
},
'j2k1_lossless_plt': {
'loc': 'params/j2k1_lossless_plt_codeblock_64,64',
'ext': 'jp2'
},
'j2k1_lossy_3bpp_plt': {
'loc': 'params/j2k1_lossy_3bpp_plt_codeblock_64,64',
'ext': 'jp2'
}
}
urls = []
@events.init_command_line_parser.add_listener
def _(parser):
parser.add_argument("--url-list", type=str, env_var="URL_LIST", default="", help="File of IIIF URLs")
parser.add_argument("--limit", type=int, env_var="LIMIT", default="-1", help="Limit the number of URLs to test")
parser.add_argument("--mode", type=str, env_var="MODE", default="aggregate", help="Either full or aggregate")
@events.test_start.add_listener
def on_test_start(environment, **kwargs):
with open(environment.parsed_options.url_list, 'r') as fh:
# example line: gm_00002701.tif/10240,8192,588,34/!73,4/0/default.jpg
limit = int(environment.parsed_options.limit)
print ('Limit {}'.format(limit))
count = 0
for line in fh:
count += 1
url = line.replace('\n', '')
urls.append({
'id': url.split('/')[0].split(".")[0],
'params': "/".join(url.split('/')[1:])
})
if limit != -1 and count >= limit:
print ('Breaking as {} is greater or equal to {}'.format(count, limit))
break
class IIIFURLTester(HttpUser):
@task
def getURLs(self):
print (urls)
for urlInfo in urls:
for imgType, details in locations.items():
url = "/iiif/{}/{}.{}/{}".format(details['loc'], urlInfo['id'], details['ext'], urlInfo['params'])
print ('URL: ' + url)
name= ""
if self.environment.parsed_options.mode == "aggregate":
name = imgType
else:
name="{}:{}".format(imgType,url)
self.client.get(url,name=name)
print ('finished tests')
self.environment.runner.quit()
print ('Quiting')