Skip to content

Commit 562778d

Browse files
houshiancopybara-github
authored andcommitted
Internal change
PiperOrigin-RevId: 929589329
1 parent de3ba93 commit 562778d

40 files changed

Lines changed: 1717 additions & 1471 deletions

src/devtools/mobileharness/infra/ats/common/proto/BUILD

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,19 @@ py_proto_library(
4444
name = "xts_common_py_proto",
4545
deps = [":xts_common_proto"],
4646
)
47+
48+
proto_library(
49+
name = "session_request_info_proto",
50+
srcs = ["session_request_info.proto"],
51+
deps = [
52+
":xts_common_proto",
53+
"//src/devtools/mobileharness/infra/ats/server/proto:service_proto",
54+
"//src/devtools/mobileharness/platform/android/xts/proto:configuration_proto",
55+
"@protobuf//:duration_proto",
56+
],
57+
)
58+
59+
java_proto_library(
60+
name = "session_request_info_java_proto",
61+
deps = [":session_request_info_proto"],
62+
)
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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+
syntax = "proto3";
18+
19+
package mobileharness.infra.ats.common;
20+
21+
import "google/protobuf/duration.proto";
22+
import "src/devtools/mobileharness/infra/ats/common/proto/xts_common.proto";
23+
import "src/devtools/mobileharness/infra/ats/server/proto/service.proto";
24+
import "src/devtools/mobileharness/platform/android/xts/proto/configuration.proto";
25+
26+
option java_package = "com.google.devtools.mobileharness.infra.ats.common.proto";
27+
option java_multiple_files = true;
28+
option java_outer_classname = "SessionRequestInfoProto";
29+
30+
message FilterValues {
31+
repeated string values = 1;
32+
}
33+
34+
// Data holder used to create jobInfo. Data comes from session request handlers,
35+
// like RunCommandHandler.
36+
message SessionRequestInfo {
37+
string test_plan = 1;
38+
string command_line_args = 2;
39+
string xts_root_dir = 3;
40+
optional string android_xts_zip = 4;
41+
optional string android_xts_zip_download_url = 5;
42+
optional string android_xts_zip_password = 6;
43+
repeated string device_serials = 7;
44+
optional DeviceInfo device_info = 8;
45+
repeated string exclude_device_serials = 9;
46+
repeated string product_types = 10;
47+
map<string, string> device_properties = 11;
48+
repeated string module_names = 12;
49+
optional string test_name = 13;
50+
optional int32 shard_count = 14;
51+
repeated string include_filters = 15;
52+
repeated string exclude_filters = 16;
53+
repeated string strict_include_filters = 17;
54+
map<string, FilterValues> module_metadata_include_filters = 18;
55+
map<string, FilterValues> module_metadata_exclude_filters = 19;
56+
// When testPlan is "retry", at least one of retrySessionId,
57+
// retrySessionResultDirName or retrySessionIndex should be set before calling
58+
// build().
59+
optional int32 retry_session_index = 20;
60+
// When testPlan is "retry", at least one of retrySessionId,
61+
// retrySessionResultDirName or retrySessionIndex should be set before calling
62+
// build().
63+
optional string retry_session_result_dir_name = 21;
64+
// When testPlan is "retry", at least one of retrySessionId,
65+
// retrySessionResultDirName or retrySessionIndex should be set before calling
66+
// build().
67+
optional string retry_session_id = 22;
68+
optional RetryType retry_type = 23;
69+
// Must be set if retrySessionId is set. This is for ATS Server retry.
70+
optional string retry_result_dir = 24;
71+
repeated string module_args = 25;
72+
repeated string extra_args = 26;
73+
string xts_type = 27;
74+
optional string python_pkg_index_url = 28;
75+
repeated string given_matched_non_tf_modules = 29;
76+
// Key is config file absolute path.
77+
map<string, xts.config.Configuration> v2_configs_map = 30;
78+
// Key is expanded module name (e.g. `arm64-v8a CtsBatteryHealthTestCases`).
79+
map<string, xts.config.Configuration> expanded_modules = 31;
80+
bool enable_module_parameter = 32;
81+
bool enable_module_optional_parameter = 33;
82+
google.protobuf.Duration job_timeout = 34;
83+
google.protobuf.Duration start_timeout = 35;
84+
map<string, string> env_vars = 36;
85+
optional string sub_plan_name = 37;
86+
// The backup subplan name for subPlanName in case the subplan file is
87+
// modified during test run.
88+
optional string sub_plan_name_backup = 38;
89+
bool html_in_zip = 39;
90+
optional string session_client_id = 40;
91+
optional string device_type = 41;
92+
optional int32 max_battery_level = 42;
93+
optional int32 min_battery_level = 43;
94+
optional int32 max_battery_temperature = 44;
95+
optional int32 min_sdk_level = 45;
96+
optional int32 max_sdk_level = 46;
97+
bool is_ats_server_request = 47;
98+
optional string remote_runner_file_path_prefix = 48;
99+
bool report_system_checkers = 49;
100+
optional ShardingMode sharding_mode = 50;
101+
optional bool skip_device_info = 51;
102+
optional bool is_xts_dynamic_download_enabled = 52;
103+
optional bool is_mobly_resultstore_upload_enabled = 53;
104+
map<string, string> xts_suite_info = 54;
105+
optional TestSuiteInfo test_suite_info = 55;
106+
repeated string exclude_runners = 56;
107+
// The test resources passed in from ATS server. Used for building command.xml
108+
// file.
109+
repeated mobileharness.infra.ats.server.TestResource
110+
ats_server_test_resources = 57;
111+
// The test environment passed in from ATS server. Used for building
112+
// command.xml file.
113+
optional mobileharness.infra.ats.server.TestEnvironment
114+
ats_server_test_environment = 58;
115+
bool allow_partial_device_match = 59;
116+
optional bool enable_default_logs = 60;
117+
bool enable_token_sharding = 61;
118+
optional string business_logic_url = 62;
119+
bool ignore_business_logic_failure = 63;
120+
}

src/java/com/google/devtools/mobileharness/infra/ats/common/BUILD

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ java_library(
5252
srcs = ["DeviceDetailsRetriever.java"],
5353
deps = [
5454
":device_details",
55-
":session_request_info",
55+
"//src/devtools/mobileharness/infra/ats/common/proto:session_request_info_java_proto",
5656
"//src/java/com/google/devtools/mobileharness/api/model/error",
5757
"//src/java/com/google/devtools/mobileharness/infra/controller/device:device_management_filter",
5858
"//src/java/com/google/devtools/mobileharness/platform/android/sdktool/adb:adb_internal_util",
@@ -128,7 +128,7 @@ java_library(
128128
srcs = ["LocalDeviceUtil.java"],
129129
deps = [
130130
":device_details",
131-
":session_request_info",
131+
"//src/devtools/mobileharness/infra/ats/common/proto:session_request_info_java_proto",
132132
"//src/devtools/mobileharness/infra/ats/common/proto:xts_common_java_proto",
133133
"//src/java/com/google/devtools/mobileharness/api/model/error",
134134
"@maven//:com_google_guava_guava",
@@ -144,7 +144,7 @@ java_library(
144144
":device_selection",
145145
":device_selection_options",
146146
":local_device_util",
147-
":session_request_info",
147+
"//src/devtools/mobileharness/infra/ats/common/proto:session_request_info_java_proto",
148148
"//src/devtools/mobileharness/infra/ats/common/proto:xts_common_java_proto",
149149
"//src/java/com/google/devtools/mobileharness/api/model/error",
150150
"//src/java/com/google/devtools/mobileharness/api/model/error:exception_factory",
@@ -170,10 +170,11 @@ java_library(
170170
":device_details",
171171
":local_device_util",
172172
":session_handler_helper",
173-
":session_request_info",
173+
":session_request_info_util",
174174
"//src/devtools/mobileharness/api/model/proto:device_java_proto",
175175
"//src/devtools/mobileharness/api/model/proto:job_java_proto",
176176
"//src/devtools/mobileharness/api/query/proto:device_query_java_proto",
177+
"//src/devtools/mobileharness/infra/ats/common/proto:session_request_info_java_proto",
177178
"//src/devtools/mobileharness/infra/ats/common/proto:xts_common_java_proto",
178179
"//src/devtools/mobileharness/platform/android/xts/proto:configuration_java_proto",
179180
"//src/devtools/mobileharness/platform/android/xts/proto:device_configuration_java_proto",
@@ -224,13 +225,10 @@ java_library(
224225
)
225226

226227
java_library(
227-
name = "session_request_info",
228-
srcs = ["SessionRequestInfo.java"],
228+
name = "session_request_info_util",
229+
srcs = ["SessionRequestInfoUtil.java"],
229230
deps = [
230-
"//src/devtools/mobileharness/infra/ats/common/proto:xts_common_java_proto",
231-
"//src/devtools/mobileharness/infra/ats/server/proto:service_java_proto",
232-
"//src/devtools/mobileharness/platform/android/xts/proto:configuration_java_proto",
233-
"//src/java/com/google/devtools/mobileharness/shared/util/auto:auto_value",
231+
"//src/devtools/mobileharness/infra/ats/common/proto:session_request_info_java_proto",
234232
"@maven//:com_google_guava_guava",
235233
],
236234
)
@@ -240,8 +238,8 @@ java_library(
240238
srcs = ["SessionResultHandlerUtil.java"],
241239
deps = [
242240
":session_handler_helper",
243-
":session_request_info",
244241
"//src/devtools/mobileharness/api/model/proto:test_java_proto",
242+
"//src/devtools/mobileharness/infra/ats/common/proto:session_request_info_java_proto",
245243
"//src/devtools/mobileharness/infra/ats/console/result/proto:report_java_proto",
246244
"//src/java/com/google/devtools/mobileharness/api/model/error",
247245
"//src/java/com/google/devtools/mobileharness/infra/ats/console/result/report:compatibility_report_creator",

src/java/com/google/devtools/mobileharness/infra/ats/common/DeviceDetailsRetriever.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.google.common.collect.ImmutableMap;
2424
import com.google.common.flogger.FluentLogger;
2525
import com.google.devtools.mobileharness.api.model.error.MobileHarnessException;
26+
import com.google.devtools.mobileharness.infra.ats.common.proto.SessionRequestInfo;
2627
import com.google.devtools.mobileharness.infra.controller.device.DeviceManagementFilter;
2728
import com.google.devtools.mobileharness.platform.android.sdktool.adb.AndroidAdbInternalUtil;
2829
import com.google.devtools.mobileharness.platform.android.sdktool.adb.AndroidAdbUtil;
@@ -72,30 +73,29 @@ public ImmutableMap<String, DeviceDetails> getAllLocalAndroidDevicesWithNeededDe
7273
.map(
7374
deviceId -> {
7475
DeviceDetails.Builder deviceDetails = DeviceDetails.builder().setId(deviceId);
75-
if (!sessionRequestInfo.productTypes().isEmpty()) {
76+
if (!sessionRequestInfo.getProductTypesList().isEmpty()) {
7677
Optional<String> productType = getDeviceProductType(deviceId);
7778
productType.ifPresent(deviceDetails::setProductType);
7879
Optional<String> productVariant = getDeviceProductVariant(deviceId);
7980
productVariant.ifPresent(deviceDetails::setProductVariant);
8081
}
81-
if (sessionRequestInfo.maxSdkLevel().isPresent()
82-
|| sessionRequestInfo.minSdkLevel().isPresent()) {
82+
if (sessionRequestInfo.hasMaxSdkLevel() || sessionRequestInfo.hasMinSdkLevel()) {
8383
Optional<Integer> sdkVersion = getDeviceSdkVersion(deviceId);
8484
sdkVersion.ifPresent(deviceDetails::setSdkVersion);
8585
}
86-
if (sessionRequestInfo.maxBatteryLevel().isPresent()
87-
|| sessionRequestInfo.minBatteryLevel().isPresent()) {
86+
if (sessionRequestInfo.hasMaxBatteryLevel()
87+
|| sessionRequestInfo.hasMinBatteryLevel()) {
8888
Optional<Integer> batteryLevel = getDeviceBatteryLevel(deviceId);
8989
batteryLevel.ifPresent(deviceDetails::setBatteryLevel);
9090
}
91-
if (sessionRequestInfo.maxBatteryTemperature().isPresent()) {
91+
if (sessionRequestInfo.hasMaxBatteryTemperature()) {
9292
Optional<Integer> batteryTemperature = getDeviceBatteryTemperature(deviceId);
9393
batteryTemperature.ifPresent(deviceDetails::setBatteryTemperature);
9494
}
9595
ImmutableMap.Builder<String, String> collectedDeviceProperties =
9696
ImmutableMap.builder();
9797
sessionRequestInfo
98-
.deviceProperties()
98+
.getDevicePropertiesMap()
9999
.keySet()
100100
.forEach(
101101
propName -> {

src/java/com/google/devtools/mobileharness/infra/ats/common/LocalDeviceUtil.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import com.google.common.collect.ImmutableSet;
2020
import com.google.devtools.mobileharness.api.model.error.MobileHarnessException;
21+
import com.google.devtools.mobileharness.infra.ats.common.proto.SessionRequestInfo;
2122
import com.google.devtools.mobileharness.infra.ats.common.proto.XtsCommonProto.DeviceInfo;
2223
import java.util.Optional;
2324

src/java/com/google/devtools/mobileharness/infra/ats/common/LocalDeviceUtilImpl.java

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
import static com.google.devtools.mobileharness.shared.constant.LogRecordImportance.IMPORTANCE;
2121
import static com.google.devtools.mobileharness.shared.constant.LogRecordImportance.Importance.IMPORTANT;
2222

23+
import com.google.common.collect.ImmutableList;
2324
import com.google.common.collect.ImmutableMap;
2425
import com.google.common.collect.ImmutableSet;
2526
import com.google.common.flogger.FluentLogger;
2627
import com.google.devtools.mobileharness.api.model.error.InfraErrorId;
2728
import com.google.devtools.mobileharness.api.model.error.MobileHarnessException;
2829
import com.google.devtools.mobileharness.api.model.error.MobileHarnessExceptionFactory;
30+
import com.google.devtools.mobileharness.infra.ats.common.proto.SessionRequestInfo;
2931
import com.google.devtools.mobileharness.infra.ats.common.proto.XtsCommonProto.DeviceInfo;
3032
import com.google.devtools.mobileharness.platform.android.sdktool.adb.AndroidAdbUtil;
3133
import com.google.devtools.mobileharness.platform.android.sdktool.adb.AndroidProperty;
@@ -58,15 +60,26 @@ public ImmutableSet<DeviceDetails> getLocalAvailableDevices(SessionRequestInfo s
5860

5961
DeviceSelectionOptions.Builder optionsBuilder =
6062
DeviceSelectionOptions.builder()
61-
.setSerials(sessionRequestInfo.deviceSerials())
62-
.setExcludeSerials(sessionRequestInfo.excludeDeviceSerials())
63-
.setProductTypes(sessionRequestInfo.productTypes())
64-
.setDeviceProperties(sessionRequestInfo.deviceProperties());
65-
sessionRequestInfo.maxBatteryLevel().ifPresent(optionsBuilder::setMaxBatteryLevel);
66-
sessionRequestInfo.minBatteryLevel().ifPresent(optionsBuilder::setMinBatteryLevel);
67-
sessionRequestInfo.maxBatteryTemperature().ifPresent(optionsBuilder::setMaxBatteryTemperature);
68-
sessionRequestInfo.minSdkLevel().ifPresent(optionsBuilder::setMinSdkLevel);
69-
sessionRequestInfo.maxSdkLevel().ifPresent(optionsBuilder::setMaxSdkLevel);
63+
.setSerials(ImmutableList.copyOf(sessionRequestInfo.getDeviceSerialsList()))
64+
.setExcludeSerials(
65+
ImmutableList.copyOf(sessionRequestInfo.getExcludeDeviceSerialsList()))
66+
.setProductTypes(ImmutableList.copyOf(sessionRequestInfo.getProductTypesList()))
67+
.setDeviceProperties(ImmutableMap.copyOf(sessionRequestInfo.getDevicePropertiesMap()));
68+
if (sessionRequestInfo.hasMaxBatteryLevel()) {
69+
optionsBuilder.setMaxBatteryLevel(sessionRequestInfo.getMaxBatteryLevel());
70+
}
71+
if (sessionRequestInfo.hasMinBatteryLevel()) {
72+
optionsBuilder.setMinBatteryLevel(sessionRequestInfo.getMinBatteryLevel());
73+
}
74+
if (sessionRequestInfo.hasMaxBatteryTemperature()) {
75+
optionsBuilder.setMaxBatteryTemperature(sessionRequestInfo.getMaxBatteryTemperature());
76+
}
77+
if (sessionRequestInfo.hasMinSdkLevel()) {
78+
optionsBuilder.setMinSdkLevel(sessionRequestInfo.getMinSdkLevel());
79+
}
80+
if (sessionRequestInfo.hasMaxSdkLevel()) {
81+
optionsBuilder.setMaxSdkLevel(sessionRequestInfo.getMaxSdkLevel());
82+
}
7083
DeviceSelectionOptions deviceSelectionOptions = optionsBuilder.build();
7184

7285
ImmutableSet<DeviceDetails> availableDevices =
@@ -92,11 +105,11 @@ public Optional<DeviceInfo> getDeviceInfoFromLocal(SessionRequestInfo sessionReq
92105
.keySet();
93106
if (!allLocalAndroidDevices.isEmpty()) {
94107
Optional<String> deviceSerial;
95-
if (sessionRequestInfo.deviceSerials().isEmpty()) {
108+
if (sessionRequestInfo.getDeviceSerialsList().isEmpty()) {
96109
deviceSerial = allLocalAndroidDevices.stream().findFirst();
97110
} else {
98111
deviceSerial =
99-
sessionRequestInfo.deviceSerials().stream()
112+
sessionRequestInfo.getDeviceSerialsList().stream()
100113
.filter(allLocalAndroidDevices::contains)
101114
.findFirst();
102115
}

0 commit comments

Comments
 (0)