Skip to content

Commit f890d29

Browse files
authored
Storage: Move benchwrapper directory into 'tests/perf/'. (#9246)
1 parent 6988dd1 commit f890d29

File tree

8 files changed

+352
-288
lines changed

8 files changed

+352
-288
lines changed

storage/test_utils/README.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

storage/test_utils/storage_pb2.py

Lines changed: 0 additions & 195 deletions
This file was deleted.

storage/test_utils/storage_pb2_grpc.py

Lines changed: 0 additions & 63 deletions
This file was deleted.

storage/tests/perf/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# storage benchwrapp
2+
3+
main.py is a gRPC wrapper around the storage library for benchmarking purposes.
4+
5+
## Running
6+
7+
```bash
8+
$ export STORAGE_EMULATOR_HOST=http://localhost:8080
9+
$ pip install grpcio
10+
$ cd storage
11+
$ pip install -e . # install google.cloud.storage locally
12+
$ cd tests/perf
13+
$ python3 benchwrapper.py --port 8081
14+
```
15+
16+
## Re-generating protos
17+
18+
```bash
19+
$ pip install grpcio-tools
20+
$ python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. *.proto
21+
```
Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,21 @@
1212

1313
parser = argparse.ArgumentParser()
1414

15-
if os.environ.get('STORAGE_EMULATOR_HOST') == None:
16-
sys.exit('This benchmarking server only works when connected to an emulator. Please set STORAGE_EMULATOR_HOST.')
15+
if os.environ.get("STORAGE_EMULATOR_HOST") is None:
16+
sys.exit(
17+
"This benchmarking server only works when connected to an emulator. Please set STORAGE_EMULATOR_HOST."
18+
)
1719

18-
parser.add_argument('--port', help='The port to run on.')
20+
parser.add_argument("--port", help="The port to run on.")
1921

2022
args = parser.parse_args()
2123

22-
if args.port == None:
23-
sys.exit('Usage: python3 main.py --port 8081')
24+
if args.port is None:
25+
sys.exit("Usage: python3 main.py --port 8081")
2426

2527
client = storage.Client()
2628

29+
2730
class StorageBenchWrapperServicer(storage_pb2_grpc.StorageBenchWrapperServicer):
2831
def Write(self, request, context):
2932
# TODO(deklerk): implement this
@@ -35,14 +38,17 @@ def Read(self, request, context):
3538
blob.download_as_string()
3639
return storage_pb2.EmptyResponse()
3740

41+
3842
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
39-
storage_pb2_grpc.add_StorageBenchWrapperServicer_to_server(StorageBenchWrapperServicer(), server)
43+
storage_pb2_grpc.add_StorageBenchWrapperServicer_to_server(
44+
StorageBenchWrapperServicer(), server
45+
)
4046

41-
print('listening on localhost:'+args.port)
42-
server.add_insecure_port('[::]:'+args.port)
47+
print("listening on localhost:" + args.port)
48+
server.add_insecure_port("[::]:" + args.port)
4349
server.start()
4450
try:
4551
while True:
4652
time.sleep(_ONE_DAY_IN_SECONDS)
4753
except KeyboardInterrupt:
48-
server.stop(0)
54+
server.stop(0)

0 commit comments

Comments
 (0)