Bug #10445 ยป leaktest.py
1 |
#!/usr/bin/env python
|
---|---|
2 |
|
3 |
# usage:
|
4 |
# leaktest.py "default" iteration-count collection-uuid
|
5 |
# leaktest.py "workaround" iteration-count collection-uuid
|
6 |
|
7 |
import arvados |
8 |
import os |
9 |
import resource |
10 |
import subprocess |
11 |
import sys |
12 |
|
13 |
_, workaround, iterations, uuid = sys.argv |
14 |
|
15 |
api = arvados.api('v1') |
16 |
if workaround == 'workaround': |
17 |
print "Using block_manager workaround" |
18 |
block_manager = arvados.collection.CollectionReader( |
19 |
uuid, api_client=api)._my_block_manager() |
20 |
else: |
21 |
print "Not using block_manager workaround" |
22 |
block_manager = None |
23 |
|
24 |
for i in range(int(iterations)): |
25 |
print "{}...".format(i+1), |
26 |
sys.stdout.flush() |
27 |
cr = arvados.collection.CollectionReader( |
28 |
uuid, api_client=api, block_manager=block_manager) |
29 |
for fn in cr: |
30 |
f = cr.open(fn) |
31 |
f.read() |
32 |
f.close() |
33 |
print "" |
34 |
|
35 |
print "Max RSS: {}".format(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss) |
36 |
conn = 0 |
37 |
for line in subprocess.check_output(['netstat', '-pane'], stderr=open(os.devnull, 'w')).splitlines(): |
38 |
if line.find(str(os.getpid())+"/python") >= 0: |
39 |
conn += 1 |
40 |
print "Network connections still open: {}".format(conn) |