Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 718150410
  • Loading branch information
DeviceInfra authored and copybara-github committed Feb 7, 2025
1 parent 92c8c24 commit 11327ee
Show file tree
Hide file tree
Showing 19 changed files with 255 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@ public Integer call() {
name = "commands",
aliases = {"c"},
description = "List all commands currently waiting to be executed")
public int commands() throws MobileHarnessException, InterruptedException {
public int commands(@Option(names = "all") boolean listAllCommands)
throws MobileHarnessException, InterruptedException {
serverPreparer.prepareOlcServer();
ImmutableList<AtsSessionPluginConfigOutput> sessionPluginConfigOutputs =
atsSessionStub.getAllUnfinishedSessions(
RunCommand.RUN_COMMAND_SESSION_NAME, /* fromCurrentClient= */ true);
RunCommand.RUN_COMMAND_SESSION_NAME, /* fromCurrentClient= */ !listAllCommands);
String result = PluginOutputPrinter.listCommands(sessionPluginConfigOutputs);
consoleUtil.printlnStdout(result);
return ExitCode.OK;
Expand Down Expand Up @@ -139,11 +140,12 @@ public int devices(@Option(names = "all") boolean listAllDevices)
name = "invocations",
aliases = {"i"},
description = "List all invocation threads")
public int invocations() throws MobileHarnessException, InterruptedException {
public int invocations(@Option(names = "all") boolean listAllInvocations)
throws MobileHarnessException, InterruptedException {
serverPreparer.prepareOlcServer();
ImmutableList<AtsSessionPluginConfigOutput> sessionPluginConfigOutputs =
atsSessionStub.getAllUnfinishedSessions(
RunCommand.RUN_COMMAND_SESSION_NAME, /* fromCurrentClient= */ true);
RunCommand.RUN_COMMAND_SESSION_NAME, /* fromCurrentClient= */ !listAllInvocations);
String result = PluginOutputPrinter.listInvocations(sessionPluginConfigOutputs);
consoleUtil.printlnStdout(result);
return ExitCode.OK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public class TestRetryHandler {
"AndroidCopycatRemoteControlledMoblySnippetTest",
"IosCopycatRemoteControlledMoblySnippetTest",
"MoblyAospPackageTest",
"VegaTest",
"XtsTradefedTest");

/** Minimal job remaining time needed for triggering the extra retry for infra errors. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ java_library(
"//src/java/com/google/devtools/mobileharness/infra/controller/device/config",
"//src/java/com/google/devtools/mobileharness/shared/util/logging:google_logger",
"//src/java/com/google/devtools/mobileharness/shared/util/time:sleeper",
"//src/java/com/google/wireless/qa/mobileharness/shared:exception",
"//src/java/com/google/wireless/qa/mobileharness/shared/api",
"@maven//:com_google_guava_guava",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ void refreshDeviceConfigs() throws MobileHarnessException, InterruptedException
* failed while updating remote testbed directory
*/
@VisibleForTesting
void refreshLabConfig()
throws com.google.wireless.qa.mobileharness.shared.MobileHarnessException {
void refreshLabConfig() throws MobileHarnessException {
Optional<LabConfig> remoteLabConfig = loadLabConfig(hostName);
LabConfig localLabConfig = apiConfig.getLabConfigToStore();
// If lab config exists in device config server, update local ApiConfig with it;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public final class Constants {

/** Default timeout in milliseconds for installation/uninstallation. */
public static final Duration DEFAULT_INSTALL_TIMEOUT = Duration.ofMinutes(6);
public static final Duration DEFAULT_INSTALL_TIMEOUT = Duration.ofMinutes(15);

private Constants() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,33 @@
/**
* Types of dumpsys.
*
* @see <a href="https://developer.android.com/studio/command-line/dumpsys">dumpsys</a>
* @see <a href="http://wrightrocket.blogspot.com/2010/12/useful-commands-in-adb-shell.html">Using
* dumpsys commands in the Android adb shell</a>
*/
public enum DumpSysType {
ACCOUNT("account"), // Account information
ACTIVITY("activity"), // Activity information
ALL("all"), // Use it to get a diagnostic output for all system services as command "adb shell
// dumpsys".
BATTERY("battery"), // Battery information
BATTERYSTATS("batterystats"), // Batterystats information
CAMERA("media.camera"), // Camera information
CONNECTIVITY("connectivity"), // Network connectivity
CPUINFO("cpuinfo"), // Processor usage
DISPLAY("display"), // Information of the keyboards, windows and their z order
GFXINFO("gfxinfo"), // GPU rendering information
INPUT(
"input"), // The state of the system’s input devices, such as keyboards and touchscreens, and
// processing of input events. See https://source.android.com/devices/input/diagnostics.html.
MEMINFO("meminfo"), // Memory usage
NONE(""), // Use it to for all types as command "adb shell dumpsys".
NONE(""), // Alias for ALL.
PACKAGE("package"), // Package info of applications
PROCSTATS("procstats"), // statistics of app's runtime, PSS and USS
POWER("power"), // Power manager information
PROCSTATS("procstats"), // statistics of app's runtime, PSS and USS
WIFI("wifi"), // Available access points and current connection
WIFISCANNER("wifiscanner"), // Scanned wifi information
WINDOW("window"), // Display information
INPUT("input"); // The state of the system’s input devices, such as keyboards and touchscreens,
// and processing of input events. See https://source.android.com/devices/input/diagnostics.html
WINDOW("window"); // Display information

private final String dumpSysTypeValue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,35 +70,35 @@ public static SubPlan createSubPlanForPreviousResult(
"%s %s %s", module.getAbi(), module.getName(), previousResult.getTestFilter()),
isNonTfModule);
}
// If the previous result has include/exclude filters, for example the previous run was
// running with given subplan file, whose include/exclude filters are stored in the
// previous result.
if (!prevResultIncludeFilters.isEmpty()) {
prevResultIncludeFilters.stream()
.filter(
filter ->
filter.matchModule(
module.getName(), module.getAbi(), /* moduleParameter= */ null))
.forEach(
prevResultIncludeFilter ->
addIncludeFilter(
subPlan, prevResultIncludeFilter.filterString(), isNonTfModule));
}
if (!prevResultExcludeFilters.isEmpty()) {
prevResultExcludeFilters.stream()
.filter(
filter ->
filter.matchModule(
module.getName(), module.getAbi(), /* moduleParameter= */ null))
.forEach(
prevResultExcludeFilter ->
addExcludeFilter(
subPlan, prevResultExcludeFilter.filterString(), isNonTfModule));
}
if (RetryResultHelper.shouldRunModule(module, types, addSubPlanCmd, passedInModules)) {
if (types.contains("not_executed") && !module.getDone()) {
logger.atInfo().log(
"Module [%s %s] was not done in previous run", module.getAbi(), module.getName());
// If the previous result has include/exclude filters, for example the previous run was
// running with given subplan file, previous include/exclude filters should be applied to
// the current run when the module is not done.
if (!prevResultIncludeFilters.isEmpty()) {
prevResultIncludeFilters.stream()
.filter(
filter ->
filter.matchModule(
module.getName(), module.getAbi(), /* moduleParameter= */ null))
.forEach(
prevResultIncludeFilter ->
addIncludeFilter(
subPlan, prevResultIncludeFilter.filterString(), isNonTfModule));
}
if (!prevResultExcludeFilters.isEmpty()) {
prevResultExcludeFilters.stream()
.filter(
filter ->
filter.matchModule(
module.getName(), module.getAbi(), /* moduleParameter= */ null))
.forEach(
prevResultExcludeFilter ->
addExcludeFilter(
subPlan, prevResultExcludeFilter.filterString(), isNonTfModule));
}
// Exclude tests that should not be run
for (TestCase testCase : module.getTestCaseList()) {
for (Test test : testCase.getTestList()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ java_library(
"//src/java/com/google/devtools/common/metrics/stability/converter",
"//src/java/com/google/devtools/mobileharness/api/model/error",
"//src/java/com/google/devtools/mobileharness/shared/model/error:unknown_error",
"//src/java/com/google/wireless/qa/mobileharness/shared:exception",
"//src/java/com/google/wireless/qa/mobileharness/shared/proto:common_java_proto",
"@maven//:com_google_code_findbugs_jsr305",
"@maven//:com_google_guava_guava",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.google.devtools.mobileharness.shared.util.error;

import static com.google.common.base.Strings.nullToEmpty;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static java.util.Arrays.stream;

import com.google.common.base.Strings;
Expand Down Expand Up @@ -167,12 +168,12 @@ public static ExceptionProto.ExceptionSummary toCommonExceptionSummary(
.setFileName(mhStackTraceElement.getFileName())
.setLineNumber(mhStackTraceElement.getLineNumber())
.build())
.collect(Collectors.toList())))
.collect(toImmutableList())))
.build();
}

/**
* Coverts the ExceptionDetail proto from the devtools/common/metrics/stability version to the MH
* Converts the ExceptionDetail proto from the devtools/common/metrics/stability version to the MH
* version.
*
* <p>Note this conversion will drop the error namespace info.
Expand Down Expand Up @@ -285,15 +286,6 @@ static ErrorId finalizeErrorId(Throwable throwable, @Nullable ErrorId errorId) {
if (throwable instanceof MobileHarnessException) {
MobileHarnessException mhException = (MobileHarnessException) throwable;
errorId = mhException.getErrorId();
} else if (throwable
instanceof com.google.wireless.qa.mobileharness.shared.MobileHarnessException) {
com.google.wireless.qa.mobileharness.shared.MobileHarnessException mhOldException =
(com.google.wireless.qa.mobileharness.shared.MobileHarnessException) throwable;
errorId =
UnknownErrorId.of(
mhOldException.getErrorCode(),
mhOldException.getErrorName(),
mhOldException.getErrorType());
} else if (errorId == null) {
errorId = BasicErrorId.NON_MH_EXCEPTION;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,14 @@ public class Flags {
converter = Flag.BooleanConverter.class)
public Flag<Boolean> enableAtsFileServerUploader = enableAtsFileServerUploaderDefault;

private static final Flag<Boolean> enableFastbootDetectorDefault = Flag.value(true);

@com.beust.jcommander.Parameter(
names = "--enable_fastboot_detector",
description = "Whether to enable fastboot detector. Default is true.",
converter = Flag.BooleanConverter.class)
public Flag<Boolean> enableFastbootDetector = enableFastbootDetectorDefault;

private static final Flag<Boolean> enableFastbootInAndroidRealDeviceDefault = Flag.value(true);

@com.beust.jcommander.Parameter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ public void setUp() throws Exception {
/* parseCommandOnly= */ false));
injector.injectMembers(this);
atsConsole.injector = injector;

// Prepares the cts configs file for testing
realLocalFileUtil.copyFileOrDir(TEST_CTS_CONFIG_DIR, xtsRootDirPath);
}

@After
Expand Down Expand Up @@ -182,9 +185,6 @@ public void tearDown() throws Exception {

@Test
public void listDevicesAndModules_expectedOutput() throws Exception {
// Prepares the cts configs file for testing
realLocalFileUtil.copyFileOrDir(TEST_CTS_CONFIG_DIR, xtsRootDirPath);

when(lineReader.readLine(anyString()))
.thenReturn("list devices")
.thenReturn("list devices all")
Expand Down Expand Up @@ -232,6 +232,18 @@ public void listResults() throws Exception {
+ " SQ3A.220705.003.A1 redfin");
}

@Test
public void listCommands() throws Exception {
when(lineReader.readLine(anyString()))
.thenReturn("run cts")
.thenReturn("list commands")
.thenReturn("exit");

atsConsole.run();

verify(lineReader).printAbove("Command n/a: [0m:00] cts");
}

@Test
public void listSubPlans() throws Exception {
String subPlanFilePath1 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public class ClientApiTest {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();

@Rule public final SetFlagsOss flags = new SetFlagsOss();
@Rule public final CaptureLogs captureLogs = new CaptureLogs("", /* printFailedLogs= */ true);
@Rule public final CaptureLogs captureLogs = new CaptureLogs();
@Rule public final PrintTestName printTestName = new PrintTestName();

@Bind @GlobalInternalEventBus private EventBus globalInternalEventBus;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

load("@rules_java//java:defs.bzl", "java_library")
load("//src/javatests/com/google/devtools/mobileharness/builddefs:junit_test_suites.bzl", "junit_test_suites")

package(
default_applicable_licenses = ["//:license"],
default_testonly = 1,
)

java_library(
name = "performance",
srcs = glob(["*.java"]),
runtime_deps = [
"//src/java/com/google/wireless/qa/mobileharness/shared/api:no_op_test",
],
deps = [
"//src/devtools/mobileharness/api/model/proto:job_java_proto",
"//src/devtools/mobileharness/api/model/proto:test_java_proto",
"//src/java/com/google/devtools/mobileharness/infra/client/api",
"//src/java/com/google/devtools/mobileharness/infra/client/api:annotations",
"//src/java/com/google/devtools/mobileharness/infra/client/api:module",
"//src/java/com/google/devtools/mobileharness/infra/client/api/mode/local",
"//src/java/com/google/devtools/mobileharness/shared/util/concurrent:thread_pools",
"//src/java/com/google/devtools/mobileharness/shared/util/logging:google_logger",
"//src/java/com/google/wireless/qa/mobileharness/shared/model/job",
"//src/java/com/google/wireless/qa/mobileharness/shared/proto:job_java_proto",
"//src/javatests/com/google/devtools/mobileharness/builddefs:truth",
"//src/javatests/com/google/devtools/mobileharness/shared/util/junit/rule:capture_logs",
"//src/javatests/com/google/devtools/mobileharness/shared/util/junit/rule:print_test_name",
"//src/javatests/com/google/devtools/mobileharness/shared/util/junit/rule:set_flags_oss",
"@maven//:com_google_guava_guava",
"@maven//:com_google_inject_extensions_guice_testlib",
"@maven//:com_google_inject_guice",
"@maven//:javax_inject_jsr330_api",
"@maven//:junit_junit",
],
)

junit_test_suites(
name = "gen_tests",
sizes = [
"medium",
],
deps = [":performance"],
)
Loading

0 comments on commit 11327ee

Please sign in to comment.