Skip to content

Commit 9233651

Browse files
OmniLab Teamcopybara-github
authored andcommitted
Implement GetTest + GetTestLog RPC handlers for FE v6 Test Detail.
PiperOrigin-RevId: 948840520
1 parent bdc3aae commit 9233651

3 files changed

Lines changed: 131 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2022 Google LLC
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+
# https://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+
16+
load("@rules_java//java:java_library.bzl", "java_library")
17+
18+
package(
19+
default_applicable_licenses = ["//:license"],
20+
default_visibility = ["//src/devtools/mobileharness/fe/v6:visibility"],
21+
)
22+
23+
java_library(
24+
name = "test",
25+
srcs = glob(["*.java"]),
26+
deps = [
27+
"//src/devtools/mobileharness/fe/v6/service/proto/test:test_service_java_grpc",
28+
"//src/devtools/mobileharness/fe/v6/service/proto/test:test_service_java_proto",
29+
"//src/java/com/google/devtools/common/metrics/stability/rpc/grpc:service_util",
30+
"@grpc-java//stub",
31+
"@maven//:com_google_guava_guava",
32+
"@maven//:com_google_inject_guice",
33+
"@maven//:javax_inject_jsr330_api",
34+
],
35+
)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.devtools.mobileharness.fe.v6.service.test;
18+
19+
import com.google.common.util.concurrent.ListeningExecutorService;
20+
import com.google.devtools.common.metrics.stability.rpc.grpc.GrpcServiceUtil;
21+
import com.google.devtools.mobileharness.fe.v6.service.proto.test.GetTestLogRequest;
22+
import com.google.devtools.mobileharness.fe.v6.service.proto.test.GetTestLogResponse;
23+
import com.google.devtools.mobileharness.fe.v6.service.proto.test.GetTestRequest;
24+
import com.google.devtools.mobileharness.fe.v6.service.proto.test.GetTestResponse;
25+
import com.google.devtools.mobileharness.fe.v6.service.proto.test.TestServiceGrpc;
26+
import io.grpc.stub.StreamObserver;
27+
import javax.inject.Inject;
28+
29+
/** gRPC implementation of the TestService. */
30+
public final class TestServiceGrpcImpl extends TestServiceGrpc.TestServiceImplBase {
31+
32+
private final TestServiceLogic logic;
33+
private final ListeningExecutorService executor;
34+
35+
@Inject
36+
TestServiceGrpcImpl(TestServiceLogic logic, ListeningExecutorService executor) {
37+
this.logic = logic;
38+
this.executor = executor;
39+
}
40+
41+
@Override
42+
public void getTest(GetTestRequest request, StreamObserver<GetTestResponse> responseObserver) {
43+
GrpcServiceUtil.invokeAsync(
44+
request,
45+
responseObserver,
46+
logic::getTest,
47+
executor,
48+
TestServiceGrpc.getServiceDescriptor(),
49+
TestServiceGrpc.getGetTestMethod());
50+
}
51+
52+
@Override
53+
public void getTestLog(
54+
GetTestLogRequest request, StreamObserver<GetTestLogResponse> responseObserver) {
55+
GrpcServiceUtil.invokeAsync(
56+
request,
57+
responseObserver,
58+
logic::getTestLog,
59+
executor,
60+
TestServiceGrpc.getServiceDescriptor(),
61+
TestServiceGrpc.getGetTestLogMethod());
62+
}
63+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.devtools.mobileharness.fe.v6.service.test;
18+
19+
import com.google.common.util.concurrent.ListenableFuture;
20+
import com.google.devtools.mobileharness.fe.v6.service.proto.test.GetTestLogRequest;
21+
import com.google.devtools.mobileharness.fe.v6.service.proto.test.GetTestLogResponse;
22+
import com.google.devtools.mobileharness.fe.v6.service.proto.test.GetTestRequest;
23+
import com.google.devtools.mobileharness.fe.v6.service.proto.test.GetTestResponse;
24+
25+
/** Logic interface for the Test Detail service. */
26+
public interface TestServiceLogic {
27+
28+
/** Gets the full test detail (overview, execution details, troubleshooting, sub-tests). */
29+
ListenableFuture<GetTestResponse> getTest(GetTestRequest request);
30+
31+
/** Gets a paginated chunk of the test log. */
32+
ListenableFuture<GetTestLogResponse> getTestLog(GetTestLogRequest request);
33+
}

0 commit comments

Comments
 (0)