summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2023-02-16 18:40:39 -0800
committerTim Burke <tim.burke@gmail.com>2023-02-16 18:41:37 -0800
commit23aba5291e45892d04e50be851ef183b25a17b86 (patch)
treeee6ecf8538a60cbbab117bdb5181a14073983359
parent7d3192cdee334c7b38a806a699d76611ee8567ce (diff)
downloadswift-bench-23aba5291e45892d04e50be851ef183b25a17b86.tar.gz
py3: Fix distributed benchmarking
Change-Id: I52b38ca4ccaec0b77d333a710e238300679cf86b
-rw-r--r--swiftbench/bench.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/swiftbench/bench.py b/swiftbench/bench.py
index da1fdad..6371213 100644
--- a/swiftbench/bench.py
+++ b/swiftbench/bench.py
@@ -15,6 +15,7 @@
from __future__ import print_function
+import io
import json
import re
import sys
@@ -31,6 +32,7 @@ import eventlet
import eventlet.pools
from eventlet.green.httplib import CannotSendRequest
+import six
from six.moves import range
import swiftclient as client
@@ -152,7 +154,9 @@ class BenchServer(object):
while True:
client, address = s.accept()
self.logger.debug('Accepting connection from %s:%s', *address)
- client_file = client.makefile('rb+', 1)
+ client_file = client.makefile('rwb', 1)
+ if not six.PY2:
+ client_file = io.TextIOWrapper(client_file)
json_data = client_file.read()
conf = Values(json.loads(json_data))
@@ -343,7 +347,7 @@ class DistributedBenchController(object):
'DEL': dict(count=0, failures=0, rate=0.0),
}
for result in pile:
- for k, v in result.iteritems():
+ for k, v in result.items():
target = results[k]
target['count'] += int(v['count'])
target['failures'] += int(v['failures'])
@@ -357,11 +361,13 @@ class DistributedBenchController(object):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ip, port = client.split(':')
s.connect((ip, int(port)))
- s.sendall(json.dumps(self.conf.__dict__))
+ s.sendall(json.dumps(self.conf.__dict__).encode('ascii'))
s.shutdown(socket.SHUT_WR)
s_file = s.makefile('rb', 1)
result = {}
for line in s_file:
+ if not six.PY2:
+ line = line.decode('ascii')
match = self.final_re.search(line)
if match:
g = match.groups()