Skip to content

Internal change #3904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/devtools/mobileharness/api/query/proto/filter.proto
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ message StringMultimapMatchCondition {
message StringMatchCondition {
// A string matches this condition if it is in the list of expected
// values (case-insensitive).
//
// An empty list will match nothing.
message Include {
repeated string expected = 1;
}
Expand Down
37 changes: 28 additions & 9 deletions src/devtools/rbe/casviewer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,28 @@ package main
import (
"errors"
"fmt"

"flag"

log "github.com/golang/glog"

"os"

"os/signal"
"syscall"

"flag"

log "github.com/golang/glog"
"github.com/google/device-infra/src/devtools/rbe/casviewer/chunkstore"
"github.com/google/device-infra/src/devtools/rbe/casviewer/fuse"
"github.com/google/device-infra/src/devtools/rbe/casviewer/mountutil"
)

const (
version = "1.2"
version = "1.3"
)

var (
printVersion = flag.Bool("version", false, "Print version information")
indexPath = flag.String("index", "", "Path to index JSON file (required)")
chunkDir = flag.String("chunks", "", "Directory containing chunk files")
mountPoint = flag.String("mount", "", "Mount point (required)")
logDir = flag.String("log-dir", "", "Log directory path")
)

func checkFlags() error {
Expand All @@ -54,12 +52,33 @@ func checkFlags() error {
return nil
}

func logToDir(dir string) error {
// Create log directory if it doesn't exist.
if _, err := os.Stat(dir); os.IsNotExist(err) {
if err := os.MkdirAll(dir, 0755); err != nil {
return err
}
} else if err != nil {
return err
}
return flag.Set("log_dir", dir)
}

func main() {
// Parse command line arguments
flag.Set("silent_init", "true")
flag.Set("logtostderr", "true")
flag.Set("logalsotostderr", "true")
flag.Set("stderrthreshold", "INFO")
flag.Parse() // flag.Parse()

flag.Parse()

if *logDir != "" {
if err := logToDir(*logDir); err != nil {
log.Exit(err)
} else {
log.Infof("Log directory: %s", *logDir)
}
}

if *printVersion {
fmt.Printf("version: %s\n", version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ java_library(
srcs = ["Adb.java"],
visibility = [
"//:deviceinfra_all_pkg",
"//:omnilab_fusion",
],
deps = [
":annotations",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ public enum BasicErrorId implements ErrorId {
RESOLVE_FILE_MISS_PACKAGE_INFO_ERROR(32_253, ErrorType.INFRA_ISSUE),
RESOLVE_FILE_INVALID_FILE_ERROR(32_254, ErrorType.CUSTOMER_ISSUE),
RESOLVE_FILE_CACHED_EXCEPTION_ERROR(32_255, ErrorType.INFRA_ISSUE),
RESOLVE_FILE_EMPTY_FILE_PATH_ERROR(32_256, ErrorType.CUSTOMER_ISSUE),
RESOLVE_FILE_TIMEOUT(32_300, ErrorType.INFRA_ISSUE),

// GCS file resolver, 32_301 ~ 32_350
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ java_library(
srcs = ["ServerPreparer.java"],
deps = [
":annotations",
":builtin_olc_server_flags",
":server_environment_preparer",
":server_heap_dump_file_detector",
"//src/devtools/mobileharness/infra/client/longrunningservice/proto:control_service_java_proto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import com.google.common.collect.ImmutableList;

/**
* Builtin flags of OLC server for ATS console / local runner.
* Built-in flags of OLC server/ATS console/ATS local runner for ATS console/ATS local runner.
*
* <p>ATS console / local runner can also override these flags.
* <p>ATS console/ATS local runner can also override these flags.
*/
class BuiltinOlcServerFlags {
public class BuiltinOlcServerFlags {

private static final ImmutableList<String> VALUE =
ImmutableList.of(
Expand All @@ -47,7 +47,7 @@ class BuiltinOlcServerFlags {
"--set_test_harness_property=false",
"--simplified_log_format=true");

static ImmutableList<String> get() {
public static ImmutableList<String> get() {
return VALUE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ public void prepareOlcServer() throws MobileHarnessException, InterruptedExcepti
.log("OLC server environment: %s", serverEnvironment);

// Creates arguments.
FlagsString serverFlags = deviceInfraServiceFlags.addToHead(BuiltinOlcServerFlags.get());
ImmutableList<String> serverNativeArguments =
ImmutableList.of(
"-Xmx" + Flags.instance().atsConsoleOlcServerXmx.getNonNull(),
Expand All @@ -247,7 +246,7 @@ public void prepareOlcServer() throws MobileHarnessException, InterruptedExcepti
.with(IMPORTANCE, DEBUG)
.log(
"OLC server flags: %s, native arguments: %s",
serverFlags.flags(), serverNativeArguments);
deviceInfraServiceFlags.flags(), serverNativeArguments);

// Creates the command to start the server.
String serverOutputPath = Flags.instance().atsConsoleOlcServerOutputPath.getNonNull();
Expand All @@ -260,7 +259,7 @@ public void prepareOlcServer() throws MobileHarnessException, InterruptedExcepti
.createJavaCommand(
wrapPath(serverEnvironment.serverBinary().toString()),
// Treats all flags as one argument to keep escape chars.
ImmutableList.of(serverFlags.flagsString()),
ImmutableList.of(deviceInfraServiceFlags.flagsString()),
serverNativeArguments));
startOlcServerCommandBuilder.add(">" + serverOutputPath).add("2>&1").add("&");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.google.devtools.mobileharness.infra.ats.common.olcserver.Annotations.ClientId;
import com.google.devtools.mobileharness.infra.ats.common.olcserver.Annotations.DeviceInfraServiceFlags;
import com.google.devtools.mobileharness.infra.ats.common.olcserver.Annotations.ServerStub;
import com.google.devtools.mobileharness.infra.ats.common.olcserver.BuiltinOlcServerFlags;
import com.google.devtools.mobileharness.infra.ats.common.olcserver.ServerPreparer;
import com.google.devtools.mobileharness.infra.ats.console.Annotations.ConsoleLineReader;
import com.google.devtools.mobileharness.infra.ats.console.Annotations.ConsoleOutput;
Expand Down Expand Up @@ -64,6 +65,7 @@
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.wireless.qa.mobileharness.shared.MobileHarnessLogger;
import com.google.wireless.qa.mobileharness.shared.constant.DirPreparer;
import java.io.IOException;
import java.io.PrintWriter;
import java.time.Duration;
Expand Down Expand Up @@ -91,7 +93,8 @@ public class AtsConsole {

private static final String USE_TF_RETRY_ENV_VAR = "USE_TF_RETRY";

public static void main(String[] args) throws IOException, InterruptedException {
public static void main(String[] args)
throws MobileHarnessException, IOException, InterruptedException {
// Gets system properties.
ImmutableMap<String, String> systemProperties =
System.getProperties().entrySet().stream()
Expand Down Expand Up @@ -125,6 +128,9 @@ public static void main(String[] args) throws IOException, InterruptedException
AtsConsole atsConsole = injector.getInstance(AtsConsole.class);
atsConsole.injector = injector;

// Prepares dirs.
DirPreparer.prepareDirRoots();

// Initializes logger.
MobileHarnessLogger.init(
AtsConsoleDirs.getLogDir(),
Expand Down Expand Up @@ -329,6 +335,11 @@ private void onShutdown() {

private static FlagsString preprocessDeviceInfraServiceFlags(FlagsString deviceInfraServiceFlags)
throws IOException, InterruptedException {
// Adds builtin flags to the head.
FlagsString flagsWithBuiltinFlags =
deviceInfraServiceFlags.addToHead(BuiltinOlcServerFlags.get());

// Adds extra flags from environment variables to the end.
ImmutableList.Builder<String> extraFlags = ImmutableList.builder();
if (Boolean.parseBoolean(System.getenv(USE_NEW_OLC_SERVER_ENV_VAR))) {
// Generate random flags for a new OLC server
Expand All @@ -339,7 +350,7 @@ private static FlagsString preprocessDeviceInfraServiceFlags(FlagsString deviceI
String.format(
"--use_tf_retry=%s", Boolean.parseBoolean(System.getenv(USE_TF_RETRY_ENV_VAR))));
}
return deviceInfraServiceFlags.addToEnd(extraFlags.build());
return flagsWithBuiltinFlags.addToEnd(extraFlags.build());
}

private static ImmutableList<String> getRandomServerFlags()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ java_library(

java_binary(
name = "ats_console",
deploy_manifest_lines = [
"Class-Path: ats_olc_server_local_mode_deploy.jar",
],
main_class = "com.google.devtools.mobileharness.infra.ats.console.AtsConsole",
visibility = DEFAULT_VISIBILITY + [
"//src/javatests/com/google/devtools/mobileharness/shared/size:__subpackages__",
Expand All @@ -56,6 +59,7 @@ java_library(
"//src/java/com/google/devtools/mobileharness/infra/ats/common:device_infra_service_util",
"//src/java/com/google/devtools/mobileharness/infra/ats/common:flags_string",
"//src/java/com/google/devtools/mobileharness/infra/ats/common/olcserver:annotations",
"//src/java/com/google/devtools/mobileharness/infra/ats/common/olcserver:builtin_olc_server_flags",
"//src/java/com/google/devtools/mobileharness/infra/ats/common/olcserver:server_preparer",
"//src/java/com/google/devtools/mobileharness/infra/ats/console/command",
"//src/java/com/google/devtools/mobileharness/infra/ats/console/command/completer:command_completer",
Expand All @@ -80,6 +84,7 @@ java_library(
"//src/java/com/google/devtools/mobileharness/shared/util/system:system_info_printer",
"//src/java/com/google/devtools/mobileharness/shared/util/time:sleeper",
"//src/java/com/google/wireless/qa/mobileharness/shared:log",
"//src/java/com/google/wireless/qa/mobileharness/shared/constant:dir_preparer",
"@maven//:com_google_guava_guava",
"@maven//:com_google_inject_guice",
"@maven//:info_picocli_picocli",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ java_library(
"//src/java/com/google/devtools/mobileharness/infra/ats/console/command:__pkg__",
"//src/java/com/google/devtools/mobileharness/platform/android/xts/suite/retry:__pkg__",
"//src/javatests/com/google/devtools/mobileharness/infra/ats/console/command:__pkg__",
"//src/javatests/com/google/devtools/mobileharness/infra/ats/console/controller/sessionplugin:__pkg__",
"//src/javatests/com/google/devtools/mobileharness/platform/android/xts/suite/retry:__pkg__",
],
deps = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.devtools.mobileharness.infra.ats.common.DeviceInfraServiceUtil;
import com.google.devtools.mobileharness.infra.ats.common.FlagsString;
import com.google.devtools.mobileharness.infra.ats.common.olcserver.Annotations.ServerStub;
import com.google.devtools.mobileharness.infra.ats.common.olcserver.BuiltinOlcServerFlags;
import com.google.devtools.mobileharness.infra.ats.common.olcserver.ServerPreparer;
import com.google.devtools.mobileharness.infra.ats.local.proto.AtsLocalSessionPluginProto.AtsLocalSessionPluginConfig;
import com.google.devtools.mobileharness.infra.ats.local.proto.AtsLocalSessionPluginProto.AtsLocalSessionPluginOutput;
Expand Down Expand Up @@ -63,11 +64,12 @@ public class AtsLocalRunner {
public static void main(String[] args) throws InterruptedException, MobileHarnessException {
FlagsString deviceInfraServiceFlags =
DeviceInfraServiceUtil.getDeviceInfraServiceFlagsFromSystemProperty();
// Parse the system property and args
ImmutableList<String> allFlags =
ImmutableList.<String>builder().addAll(deviceInfraServiceFlags.flags()).add(args).build();
logger.atInfo().log("Device infra service flags: %s", allFlags);
DeviceInfraServiceUtil.parseFlags(allFlags);
FlagsString finalFlags =
deviceInfraServiceFlags
.addToHead(BuiltinOlcServerFlags.get())
.addToEnd(ImmutableList.copyOf(args));
logger.atInfo().log("Device infra service flags: %s", finalFlags.flags());
DeviceInfraServiceUtil.parseFlags(finalFlags.flags());

Injector injector =
Guice.createInjector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ java_library(
"//src/java/com/google/devtools/mobileharness/infra/ats/common:device_infra_service_util",
"//src/java/com/google/devtools/mobileharness/infra/ats/common:flags_string",
"//src/java/com/google/devtools/mobileharness/infra/ats/common/olcserver:annotations",
"//src/java/com/google/devtools/mobileharness/infra/ats/common/olcserver:builtin_olc_server_flags",
"//src/java/com/google/devtools/mobileharness/infra/ats/common/olcserver:server_preparer",
"//src/java/com/google/devtools/mobileharness/infra/client/longrunningservice/constant:dirs",
"//src/java/com/google/devtools/mobileharness/infra/client/longrunningservice/rpc/stub:control_stub",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ java_library(
"//src/java/com/google/devtools/mobileharness/shared/util/concurrent:more_futures",
"//src/java/com/google/devtools/mobileharness/shared/util/database:database_connections",
"//src/java/com/google/devtools/mobileharness/shared/util/database:table_lister",
"//src/java/com/google/devtools/mobileharness/shared/util/file/local",
"//src/java/com/google/devtools/mobileharness/shared/util/flags",
"//src/java/com/google/devtools/mobileharness/shared/util/logging:google_logger",
"//src/java/com/google/devtools/mobileharness/shared/util/logging/flogger:flogger_formatter",
Expand All @@ -78,7 +77,7 @@ java_library(
"//src/java/com/google/devtools/mobileharness/shared/version",
"//src/java/com/google/devtools/mobileharness/shared/version:version_util",
"//src/java/com/google/wireless/qa/mobileharness/shared:log",
"//src/java/com/google/wireless/qa/mobileharness/shared/constant:dir",
"//src/java/com/google/wireless/qa/mobileharness/shared/constant:dir_preparer",
"@io_grpc_grpc_java//core",
"@maven//:com_google_code_findbugs_jsr305",
"@maven//:com_google_guava_guava",
Expand Down
Loading