summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2023-05-16 19:47:01 +0000
committerGerrit Code Review <review@openstack.org>2023-05-16 19:47:01 +0000
commitf4a1509534ea159359e1483931a870e70ce1a89d (patch)
treea3df0314e858435a6fb02a4d06b66acf25f7f0c3
parentbe8295eda4df5e83df909ddae0978def412166b9 (diff)
parent23aba5291e45892d04e50be851ef183b25a17b86 (diff)
downloadswift-bench-f4a1509534ea159359e1483931a870e70ce1a89d.tar.gz
Merge "py3: Fix distributed benchmarking"HEADmaster
-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()