Skip to content

Commit 53e2739

Browse files
Add target and generated code for QPS (#1827)
Motivation: The first step in implementing QPS testing for V2 is to add the proto files representing the services and messages used in QPS and generating the code for them. Modifications: - Modified the fetch script to add the proto files we need - Modified the generate script to generate code for them -Created executable target for QPS worker Result: We can start implementing the performance worker.
1 parent 108a0b9 commit 53e2739

20 files changed

+7377
-1
lines changed

Package.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ extension Target.Dependency {
9191
static let grpc: Self = .target(name: grpcTargetName)
9292
static let cgrpcZlib: Self = .target(name: cgrpcZlibTargetName)
9393
static let protocGenGRPCSwift: Self = .target(name: "protoc-gen-grpc-swift")
94+
static let performanceWorker: Self = .target(name: "performance-worker")
9495
static let reflectionService: Self = .target(name: "GRPCReflectionService")
9596
static let grpcCodeGen: Self = .target(name: "GRPCCodeGen")
9697
static let grpcProtobuf: Self = .target(name: "GRPCProtobuf")
@@ -245,6 +246,14 @@ extension Target {
245246
]
246247
)
247248

249+
static let performanceWorker: Target = .executableTarget(
250+
name: "performance-worker",
251+
dependencies: [
252+
.grpcCore,
253+
.grpcProtobuf
254+
]
255+
)
256+
248257
static let grpcSwiftPlugin: Target = .plugin(
249258
name: "GRPCSwiftPlugin",
250259
capability: .buildTool(),
@@ -722,6 +731,7 @@ let package = Package(
722731
.grpcProtobuf,
723732
.grpcProtobufCodeGen,
724733
.interoperabilityTestImplementation,
734+
.performanceWorker,
725735

726736
// v2 tests
727737
.grpcCoreTests,

Protos/fetch.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,22 @@ rm -rf "$upstream"
3131

3232
# Create new directories to poulate. These are based on proto package name
3333
# rather than source repository name.
34-
mkdir -p "$upstream/grpc"
3534
mkdir -p "$upstream/google"
35+
mkdir -p "$upstream/grpc/testing"
36+
mkdir -p "$upstream/grpc/core"
3637

3738
# Copy over the grpc-proto protos.
3839
cp -rp "$checkouts/grpc-proto/grpc/service_config" "$upstream/grpc/service_config"
3940
cp -rp "$checkouts/grpc-proto/grpc/lookup" "$upstream/grpc/lookup"
4041
cp -rp "$checkouts/grpc-proto/grpc/reflection" "$upstream/grpc/reflection"
4142
cp -rp "$checkouts/grpc-proto/grpc/examples" "$upstream/grpc/examples"
43+
cp -rp "$checkouts/grpc-proto/grpc/testing/benchmark_service.proto" "$upstream/grpc/testing/benchmark_service.proto"
44+
cp -rp "$checkouts/grpc-proto/grpc/testing/messages.proto" "$upstream/grpc/testing/messages.proto"
45+
cp -rp "$checkouts/grpc-proto/grpc/testing/worker_service.proto" "$upstream/grpc/testing/worker_service.proto"
46+
cp -rp "$checkouts/grpc-proto/grpc/testing/control.proto" "$upstream/grpc/testing/control.proto"
47+
cp -rp "$checkouts/grpc-proto/grpc/testing/payloads.proto" "$upstream/grpc/testing/payloads.proto"
48+
cp -rp "$checkouts/grpc-proto/grpc/testing/stats.proto" "$upstream/grpc/testing/stats.proto"
49+
cp -rp "$checkouts/grpc-proto/grpc/core/stats.proto" "$upstream/grpc/core/stats.proto"
4250

4351
# Copy over the googleapis protos.
4452
mkdir -p "$upstream/google/rpc"

Protos/generate.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,29 @@ function generate_service_messages_interop_tests {
201201
done
202202
}
203203

204+
function generate_worker_service {
205+
local protos=(
206+
"$here/upstream/grpc/testing/payloads.proto"
207+
"$here/upstream/grpc/testing/control.proto"
208+
"$here/upstream/grpc/testing/messages.proto"
209+
"$here/upstream/grpc/testing/stats.proto"
210+
"$here/upstream/grpc/testing/benchmark_service.proto"
211+
"$here/upstream/grpc/testing/worker_service.proto"
212+
)
213+
local output="$root/Sources/performance-worker/Generated"
214+
215+
generate_message "$here/upstream/grpc/core/stats.proto" "$here/upstream" "$output" "Visibility=Internal" "FileNaming=PathToUnderscores"
216+
217+
for proto in "${protos[@]}"; do
218+
generate_message "$proto" "$here/upstream" "$output" "Visibility=Internal" "FileNaming=PathToUnderscores"
219+
if [ "$proto" == "$here/upstream/grpc/testing/worker_service.proto" ]; then
220+
generate_grpc "$proto" "$here/upstream" "$output" "Visibility=Internal" "Client=false" "_V2=true" "FileNaming=PathToUnderscores"
221+
else
222+
generate_grpc "$proto" "$here/upstream" "$output" "Visibility=Internal" "_V2=true" "FileNaming=PathToUnderscores"
223+
fi
224+
done
225+
}
226+
204227
#------------------------------------------------------------------------------
205228

206229
# Examples
@@ -220,3 +243,6 @@ generate_service_messages_interop_tests
220243
# Misc. tests
221244
generate_normalization_for_tests
222245
generate_rpc_code_for_tests
246+
247+
# Performance worker service
248+
generate_worker_service
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2017 gRPC authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package grpc.core;
18+
19+
message Bucket {
20+
double start = 1;
21+
uint64 count = 2;
22+
}
23+
24+
message Histogram {
25+
repeated Bucket buckets = 1;
26+
}
27+
28+
message Metric {
29+
string name = 1;
30+
oneof value {
31+
uint64 count = 10;
32+
Histogram histogram = 11;
33+
}
34+
}
35+
36+
message Stats {
37+
repeated Metric metrics = 1;
38+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright 2015 gRPC authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// An integration test service that covers all the method signature permutations
16+
// of unary/streaming requests/responses.
17+
syntax = "proto3";
18+
19+
import "grpc/testing/messages.proto";
20+
21+
package grpc.testing;
22+
23+
option java_multiple_files = true;
24+
option java_package = "io.grpc.testing";
25+
option java_outer_classname = "BenchmarkServiceProto";
26+
27+
service BenchmarkService {
28+
// One request followed by one response.
29+
// The server returns the client payload as-is.
30+
rpc UnaryCall(SimpleRequest) returns (SimpleResponse);
31+
32+
// Repeated sequence of one request followed by one response.
33+
// Should be called streaming ping-pong
34+
// The server returns the client payload as-is on each response
35+
rpc StreamingCall(stream SimpleRequest) returns (stream SimpleResponse);
36+
37+
// Single-sided unbounded streaming from client to server
38+
// The server returns the client payload as-is once the client does WritesDone
39+
rpc StreamingFromClient(stream SimpleRequest) returns (SimpleResponse);
40+
41+
// Single-sided unbounded streaming from server to client
42+
// The server repeatedly returns the client payload as-is
43+
rpc StreamingFromServer(SimpleRequest) returns (stream SimpleResponse);
44+
45+
// Two-sided unbounded streaming between server to client
46+
// Both sides send the content of their own choice to the other
47+
rpc StreamingBothWays(stream SimpleRequest) returns (stream SimpleResponse);
48+
}

0 commit comments

Comments
 (0)