From 44a4a2ea62d645979600d163b0847711666527f7 Mon Sep 17 00:00:00 2001 From: Paulo Castello da Costa <6579971+paulosjca@users.noreply.github.com> Date: Mon, 3 May 2021 00:07:20 -0700 Subject: [PATCH] Fix typos and format of LoadTest generator output. (#26149) This change fixes typos and makes minor changes to the format of the generated yaml files for LoadTest configuration (embedded scenarios end in newline, and element lists are indented). The templates generated earlier are also updated. --- tools/run_tests/performance/README.md | 6 +- .../run_tests/performance/loadtest_config.py | 16 +- .../performance/loadtest_template.py | 11 +- ...loadtest_template_basic_all_languages.yaml | 476 +++++++++--------- 4 files changed, 264 insertions(+), 245 deletions(-) diff --git a/tools/run_tests/performance/README.md b/tools/run_tests/performance/README.md index 452f8074e5a..8e3ab27a45d 100644 --- a/tools/run_tests/performance/README.md +++ b/tools/run_tests/performance/README.md @@ -29,8 +29,8 @@ server, it might be useful to run workers manually. 2. Connect to each worker machine and start up a benchmark worker with a "driver_port". -- For example, to start the grpc-go benchmark worker: [grpc-go worker - main.go](https://github.com/grpc/grpc-go/blob/master/benchmark/worker/main.go) +- For example, to start the grpc-go benchmark worker: + [grpc-go worker main.go](https://github.com/grpc/grpc-go/blob/master/benchmark/worker/main.go) --driver_port #### Commands to start workers in different languages: @@ -347,7 +347,7 @@ $ ./tools/run_tests/performance/loadtest_template.py \ --name basic_all_languages ``` -The script `loadest_template.py` takes the following options: +The script `loadtest_template.py` takes the following options: - `-i`, `--inputs`
Space-separated list of the names of input files containing LoadTest configurations. May be repeated. diff --git a/tools/run_tests/performance/loadtest_config.py b/tools/run_tests/performance/loadtest_config.py index 773a9f646ac..00d9b3ec465 100755 --- a/tools/run_tests/performance/loadtest_config.py +++ b/tools/run_tests/performance/loadtest_config.py @@ -150,7 +150,8 @@ def gen_loadtest_configs( uniq = (uniquifier_elements + [run_index] if run_index else uniquifier_elements) name = loadtest_name(prefix, scenario['name'], uniq) - scenario_str = json.dumps({'scenarios': scenario}, indent=' ') + scenario_str = json.dumps({'scenarios': scenario}, + indent=' ') + '\n' config = copy.deepcopy(base_config) @@ -206,7 +207,7 @@ def parse_key_value_args(args: Optional[Iterable[str]]) -> Dict[str, str]: return d -def config_dumper(header_comment: str) -> Type[yaml.Dumper]: +def config_dumper(header_comment: str) -> Type[yaml.SafeDumper]: """Returns a custom dumper to dump configurations in the expected format.""" class ConfigDumper(yaml.SafeDumper): @@ -217,6 +218,15 @@ def config_dumper(header_comment: str) -> Type[yaml.Dumper]: self.write_indent() self.write_indicator(header_comment, need_whitespace=False) + def expect_block_sequence(self): + super().expect_block_sequence() + self.increase_indent() + + def expect_block_sequence_item(self, first=False): + if isinstance(self.event, yaml.SequenceEndEvent): + self.indent = self.indents.pop() + super().expect_block_sequence_item(first) + def str_presenter(dumper, data): if '\n' in data: return dumper.represent_scalar('tag:yaml.org,2002:str', @@ -266,7 +276,7 @@ def main() -> None: argp.add_argument( '-d', action='store_true', - help='Use creation date and time as an addditional uniquifier element.') + help='Use creation date and time as an additional uniquifier element.') argp.add_argument('-a', '--annotation', action='append', diff --git a/tools/run_tests/performance/loadtest_template.py b/tools/run_tests/performance/loadtest_template.py index e68493b23a2..9684bb9a2d6 100755 --- a/tools/run_tests/performance/loadtest_template.py +++ b/tools/run_tests/performance/loadtest_template.py @@ -122,7 +122,7 @@ def loadtest_template( return template -def template_dumper(header_comment: str) -> Type[yaml.Dumper]: +def template_dumper(header_comment: str) -> Type[yaml.SafeDumper]: """Returns a custom dumper to dump templates in the expected format.""" class TemplateDumper(yaml.SafeDumper): @@ -133,6 +133,15 @@ def template_dumper(header_comment: str) -> Type[yaml.Dumper]: self.write_indent() self.write_indicator(header_comment, need_whitespace=False) + def expect_block_sequence(self): + super().expect_block_sequence() + self.increase_indent() + + def expect_block_sequence_item(self, first=False): + if isinstance(self.event, yaml.SequenceEndEvent): + self.indent = self.indents.pop() + super().expect_block_sequence_item(first) + return TemplateDumper diff --git a/tools/run_tests/performance/templates/loadtest_template_basic_all_languages.yaml b/tools/run_tests/performance/templates/loadtest_template_basic_all_languages.yaml index 52dd32983ff..fb1d6337d46 100644 --- a/tools/run_tests/performance/templates/loadtest_template_basic_all_languages.yaml +++ b/tools/run_tests/performance/templates/loadtest_template_basic_all_languages.yaml @@ -14,246 +14,246 @@ metadata: name: basic_all_languages spec: clients: - - build: - command: - - bash - - /build_scripts/build_qps_worker.sh - clone: - gitRef: master - repo: https://github.com/grpc/grpc.git - language: csharp - pool: ${client_pool} - run: - args: - - exec - - qps_worker/Grpc.IntegrationTesting.QpsWorker.dll - command: - - dotnet - - build: - args: - - build - - //test/cpp/qps:qps_worker - command: - - bazel - clone: - gitRef: master - repo: https://github.com/grpc/grpc.git - language: cxx - pool: ${client_pool} - run: - command: - - bazel-bin/test/cpp/qps/qps_worker - - build: - args: - - build - - -o - - /src/workspace/bin/worker - - ./benchmark/worker - command: - - go - clone: - gitRef: master - repo: https://github.com/grpc/grpc-go.git - language: go - pool: ${client_pool} - run: - command: - - /src/workspace/bin/worker - - build: - args: - - -PskipAndroid=true - - -PskipCodegen=true - - :grpc-benchmarks:installDist - command: - - gradle - clone: - gitRef: master - repo: https://github.com/grpc/grpc-java.git - language: java - pool: ${client_pool} - run: - command: - - benchmarks/build/install/grpc-benchmarks/bin/benchmark_worker - - build: - command: - - bash - - /build_scripts/build_qps_worker.sh - clone: - gitRef: master - repo: https://github.com/grpc/grpc-node.git - language: node - pool: ${client_pool} - run: - args: - - -r - - ./test/fixtures/native_native.js - - test/performance/worker.js - - --benchmark_impl=grpc - command: - - node - - build: - command: - - bash - - /build_scripts/build_qps_worker.sh - clone: - gitRef: master - repo: https://github.com/grpc/grpc.git - language: php - pool: ${client_pool} - run: - command: - - bash - - /run_scripts/run_worker.sh - - build: - args: - - build - - //src/python/grpcio_tests/tests/qps:qps_worker - command: - - bazel - clone: - gitRef: master - repo: https://github.com/grpc/grpc.git - language: python - pool: ${client_pool} - run: - command: - - bazel-bin/src/python/grpcio_tests/tests/qps/qps_worker - - build: - command: - - bash - - /build_scripts/build_qps_worker.sh - clone: - gitRef: master - repo: https://github.com/grpc/grpc - language: ruby - pool: ${client_pool} - run: - args: - - src/ruby/qps/worker.rb - command: - - ruby + - build: + command: + - bash + - /build_scripts/build_qps_worker.sh + clone: + gitRef: master + repo: https://github.com/grpc/grpc.git + language: csharp + pool: ${client_pool} + run: + args: + - exec + - qps_worker/Grpc.IntegrationTesting.QpsWorker.dll + command: + - dotnet + - build: + args: + - build + - //test/cpp/qps:qps_worker + command: + - bazel + clone: + gitRef: master + repo: https://github.com/grpc/grpc.git + language: cxx + pool: ${client_pool} + run: + command: + - bazel-bin/test/cpp/qps/qps_worker + - build: + args: + - build + - -o + - /src/workspace/bin/worker + - ./benchmark/worker + command: + - go + clone: + gitRef: master + repo: https://github.com/grpc/grpc-go.git + language: go + pool: ${client_pool} + run: + command: + - /src/workspace/bin/worker + - build: + args: + - -PskipAndroid=true + - -PskipCodegen=true + - :grpc-benchmarks:installDist + command: + - gradle + clone: + gitRef: master + repo: https://github.com/grpc/grpc-java.git + language: java + pool: ${client_pool} + run: + command: + - benchmarks/build/install/grpc-benchmarks/bin/benchmark_worker + - build: + command: + - bash + - /build_scripts/build_qps_worker.sh + clone: + gitRef: master + repo: https://github.com/grpc/grpc-node.git + language: node + pool: ${client_pool} + run: + args: + - -r + - ./test/fixtures/native_native.js + - test/performance/worker.js + - --benchmark_impl=grpc + command: + - node + - build: + command: + - bash + - /build_scripts/build_qps_worker.sh + clone: + gitRef: master + repo: https://github.com/grpc/grpc.git + language: php + pool: ${client_pool} + run: + command: + - bash + - /run_scripts/run_worker.sh + - build: + args: + - build + - //src/python/grpcio_tests/tests/qps:qps_worker + command: + - bazel + clone: + gitRef: master + repo: https://github.com/grpc/grpc.git + language: python + pool: ${client_pool} + run: + command: + - bazel-bin/src/python/grpcio_tests/tests/qps/qps_worker + - build: + command: + - bash + - /build_scripts/build_qps_worker.sh + clone: + gitRef: master + repo: https://github.com/grpc/grpc + language: ruby + pool: ${client_pool} + run: + args: + - src/ruby/qps/worker.rb + command: + - ruby results: bigQueryTable: ${big_query_table} servers: - - build: - command: - - bash - - /build_scripts/build_qps_worker.sh - clone: - gitRef: master - repo: https://github.com/grpc/grpc.git - language: csharp - pool: ${server_pool} - run: - args: - - exec - - qps_worker/Grpc.IntegrationTesting.QpsWorker.dll - command: - - dotnet - - build: - args: - - build - - //test/cpp/qps:qps_worker - command: - - bazel - clone: - gitRef: master - repo: https://github.com/grpc/grpc.git - language: cxx - pool: ${server_pool} - run: - args: - - --server_port=10010 - command: - - bazel-bin/test/cpp/qps/qps_worker - - build: - args: - - build - - -o - - /src/workspace/bin/worker - - ./benchmark/worker - command: - - go - clone: - gitRef: master - repo: https://github.com/grpc/grpc-go.git - language: go - pool: ${server_pool} - run: - command: - - /src/workspace/bin/worker - - build: - args: - - -PskipAndroid=true - - -PskipCodegen=true - - :grpc-benchmarks:installDist - command: - - gradle - clone: - gitRef: master - repo: https://github.com/grpc/grpc-java.git - language: java - pool: ${server_pool} - run: - command: - - benchmarks/build/install/grpc-benchmarks/bin/benchmark_worker - - build: - command: - - bash - - /build_scripts/build_qps_worker.sh - clone: - gitRef: master - repo: https://github.com/grpc/grpc-node.git - language: node - pool: ${server_pool} - run: - args: - - -r - - ./test/fixtures/native_native.js - - test/performance/worker.js - - --benchmark_impl=grpc - command: - - node - - build: - command: - - bash - - /build_scripts/build_qps_worker.sh - clone: - gitRef: master - repo: https://github.com/grpc/grpc.git - language: php - pool: ${server_pool} - run: - command: - - bash - - /run_scripts/run_worker.sh - - build: - args: - - build - - //src/python/grpcio_tests/tests/qps:qps_worker - command: - - bazel - clone: - gitRef: master - repo: https://github.com/grpc/grpc.git - language: python - pool: ${server_pool} - run: - command: - - bazel-bin/src/python/grpcio_tests/tests/qps/qps_worker - - build: - command: - - bash - - /build_scripts/build_qps_worker.sh - clone: - gitRef: master - repo: https://github.com/grpc/grpc - language: ruby - pool: ${server_pool} - run: - args: - - src/ruby/qps/worker.rb - command: - - ruby + - build: + command: + - bash + - /build_scripts/build_qps_worker.sh + clone: + gitRef: master + repo: https://github.com/grpc/grpc.git + language: csharp + pool: ${server_pool} + run: + args: + - exec + - qps_worker/Grpc.IntegrationTesting.QpsWorker.dll + command: + - dotnet + - build: + args: + - build + - //test/cpp/qps:qps_worker + command: + - bazel + clone: + gitRef: master + repo: https://github.com/grpc/grpc.git + language: cxx + pool: ${server_pool} + run: + args: + - --server_port=10010 + command: + - bazel-bin/test/cpp/qps/qps_worker + - build: + args: + - build + - -o + - /src/workspace/bin/worker + - ./benchmark/worker + command: + - go + clone: + gitRef: master + repo: https://github.com/grpc/grpc-go.git + language: go + pool: ${server_pool} + run: + command: + - /src/workspace/bin/worker + - build: + args: + - -PskipAndroid=true + - -PskipCodegen=true + - :grpc-benchmarks:installDist + command: + - gradle + clone: + gitRef: master + repo: https://github.com/grpc/grpc-java.git + language: java + pool: ${server_pool} + run: + command: + - benchmarks/build/install/grpc-benchmarks/bin/benchmark_worker + - build: + command: + - bash + - /build_scripts/build_qps_worker.sh + clone: + gitRef: master + repo: https://github.com/grpc/grpc-node.git + language: node + pool: ${server_pool} + run: + args: + - -r + - ./test/fixtures/native_native.js + - test/performance/worker.js + - --benchmark_impl=grpc + command: + - node + - build: + command: + - bash + - /build_scripts/build_qps_worker.sh + clone: + gitRef: master + repo: https://github.com/grpc/grpc.git + language: php + pool: ${server_pool} + run: + command: + - bash + - /run_scripts/run_worker.sh + - build: + args: + - build + - //src/python/grpcio_tests/tests/qps:qps_worker + command: + - bazel + clone: + gitRef: master + repo: https://github.com/grpc/grpc.git + language: python + pool: ${server_pool} + run: + command: + - bazel-bin/src/python/grpcio_tests/tests/qps/qps_worker + - build: + command: + - bash + - /build_scripts/build_qps_worker.sh + clone: + gitRef: master + repo: https://github.com/grpc/grpc + language: ruby + pool: ${server_pool} + run: + args: + - src/ruby/qps/worker.rb + command: + - ruby timeoutSeconds: ${timeout_seconds} ttlSeconds: 86400