Skip to content

Commit

Permalink
Including locust file
Browse files Browse the repository at this point in the history
  • Loading branch information
glenrobson committed Aug 17, 2022
1 parent 7585548 commit e72caa7
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
58 changes: 58 additions & 0 deletions load_test/fromlist/locustfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

from locust import HttpUser, task, events

locations = {
'ptiff-lossy': {
'loc': 'ptiff/lossy',
'ext': 'tif'
},
'ptiff-lossless': {
'loc': 'ptiff/lossless',
'ext': 'tif'
},
'jp2-lossy': {
'loc': 'jp2/lossy',
'ext': 'jp2'
},
'jp2-lossless': {
'loc': 'jp2/lossless',
'ext': 'jp2'
},
'htj2k-lossy': {
'loc': 'htj2k/lossy',
'ext': 'htj2k.jp2'
},
'htj2k-lossless': {
'loc': 'htj2k/lossless',
'ext': 'htj2k.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")

@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
for line in fh:
url = line.replace('\n', '')
urls.append({
'id': url.split('/')[0].split(".")[0],
'params': "/".join(url.split('/')[1:])
})


class IIIFURLTester(HttpUser):

@task
def getURLs(self):
for urlInfo in urls:
for imgType, details in locations.items():
url = "/iiif/{}/{}.{}/{}".format(details['loc'], urlInfo['id'], details['ext'], urlInfo['params'])
print ('URL: ' + url)
self.client.get(url, name=imgType)

11 changes: 10 additions & 1 deletion reports/glen/2022-08-16.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,16 @@ https://github.com/ruven/iipsrv/issues/232

also my Kakadu directory layout was slightly different so it would be good to pass this as a parameter.

First run as follows:
## Step 4: Running the locust tests

I've created a locust script [locustfile.py](../../load_test/fromlist/locustfile.py) which will take a file as a parameter. The file contains IIIF URLs and is the one that Ruven used. I used the web interface for the first test which can be run as follows:

```
cd load_test/fromlist/
locust
```

First run results as follows:

```
Type Name # reqs # fails | Avg Min Max Med | req/s failures/s
Expand Down

0 comments on commit e72caa7

Please sign in to comment.