Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ java_library(
srcs = glob(["*.java"]),
deps = [
"//src/devtools/mobileharness/fe/v6/service/proto/host:host_resources_java_proto",
"//src/java/com/google/devtools/mobileharness/fe/v6/service/util",
"//src/java/com/google/devtools/mobileharness/shared/util/auto:auto_value",
"@maven//:com_google_guava_guava",
"@maven//:javax_inject_jsr330_api",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,78 @@

import com.google.common.util.concurrent.ListenableFuture;
import com.google.devtools.mobileharness.fe.v6.service.proto.host.DiagnosticLink;
import com.google.devtools.mobileharness.fe.v6.service.util.UniverseScope;
import java.util.List;
import java.util.Optional;

/** Provides auxiliary information about hosts, such as release info and pass-through flags. */
public interface HostAuxiliaryInfoProvider {

/** Fetches release information and host attributes from internal services. */
ListenableFuture<Optional<HostReleaseInfo>> getHostReleaseInfo(String hostName);
ListenableFuture<Optional<HostReleaseInfo>> getHostReleaseInfo(
String hostName, UniverseScope universe);

/**
* @deprecated Use {@link #getHostReleaseInfo(String, UniverseScope)} instead. TODO: Remove after
* all callers are migrated to UniverseScope.
*/
@Deprecated
default ListenableFuture<Optional<HostReleaseInfo>> getHostReleaseInfo(
String hostName, String universe) {
return getHostReleaseInfo(hostName, UniverseScope.fromString(universe));
}

/**
* @deprecated Use {@link #getHostReleaseInfo(String, UniverseScope)} instead. TODO: Remove after
* all callers are migrated to UniverseScope.
*/
@Deprecated
default ListenableFuture<Optional<HostReleaseInfo>> getHostReleaseInfo(String hostName) {
return getHostReleaseInfo(hostName, new UniverseScope.SelfUniverse());
}

/** Fetches the legacy pass-through flags for the lab server. */
ListenableFuture<Optional<String>> getPassThroughFlags(String hostName);
ListenableFuture<Optional<String>> getPassThroughFlags(String hostName, UniverseScope universe);

/**
* @deprecated Use {@link #getPassThroughFlags(String, UniverseScope)} instead. TODO: Remove after
* all callers are migrated to UniverseScope.
*/
@Deprecated
default ListenableFuture<Optional<String>> getPassThroughFlags(String hostName, String universe) {
return getPassThroughFlags(hostName, UniverseScope.fromString(universe));
}

/**
* @deprecated Use {@link #getPassThroughFlags(String, UniverseScope)} instead. TODO: Remove after
* all callers are migrated to UniverseScope.
*/
@Deprecated
default ListenableFuture<Optional<String>> getPassThroughFlags(String hostName) {
return getPassThroughFlags(hostName, new UniverseScope.SelfUniverse());
}

/** Fetches the diagnostic links for the host. */
ListenableFuture<List<DiagnosticLink>> getDiagnosticLinks(
String hostName, Optional<String> labType);
String hostName, Optional<String> labType, UniverseScope universe);

/**
* @deprecated Use {@link #getDiagnosticLinks(String, Optional, UniverseScope)} instead. TODO:
* Remove after all callers are migrated to UniverseScope.
*/
@Deprecated
default ListenableFuture<List<DiagnosticLink>> getDiagnosticLinks(
String hostName, Optional<String> labType, String universe) {
return getDiagnosticLinks(hostName, labType, UniverseScope.fromString(universe));
}

/**
* @deprecated Use {@link #getDiagnosticLinks(String, Optional, UniverseScope)} instead. TODO:
* Remove after all callers are migrated to UniverseScope.
*/
@Deprecated
default ListenableFuture<List<DiagnosticLink>> getDiagnosticLinks(
String hostName, Optional<String> labType) {
return getDiagnosticLinks(hostName, labType, new UniverseScope.SelfUniverse());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.devtools.mobileharness.fe.v6.service.proto.host.DiagnosticLink;
import com.google.devtools.mobileharness.fe.v6.service.util.UniverseScope;
import java.util.List;
import java.util.Optional;
import javax.inject.Inject;
Expand All @@ -32,18 +33,20 @@ public class OssHostAuxiliaryInfoProviderImpl implements HostAuxiliaryInfoProvid
OssHostAuxiliaryInfoProviderImpl() {}

@Override
public ListenableFuture<Optional<HostReleaseInfo>> getHostReleaseInfo(String hostName) {
public ListenableFuture<Optional<HostReleaseInfo>> getHostReleaseInfo(
String hostName, UniverseScope universe) {
return immediateFuture(Optional.empty());
}

@Override
public ListenableFuture<Optional<String>> getPassThroughFlags(String hostName) {
public ListenableFuture<Optional<String>> getPassThroughFlags(
String hostName, UniverseScope universe) {
return immediateFuture(Optional.empty());
}

@Override
public ListenableFuture<List<DiagnosticLink>> getDiagnosticLinks(
String hostName, Optional<String> labType) {
String hostName, Optional<String> labType, UniverseScope universe) {
return immediateFuture(ImmutableList.of());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ java_library(
srcs = glob(["*.java"]),
deps = [
"//src/java/com/google/devtools/mobileharness/fe/v6/service/host/provider",
"//src/java/com/google/devtools/mobileharness/fe/v6/service/util",
"//src/javatests/com/google/devtools/mobileharness/builddefs:truth",
"@maven//:junit_junit",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static com.google.common.truth.Truth.assertThat;

import com.google.devtools.mobileharness.fe.v6.service.util.UniverseScope;
import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -36,17 +37,28 @@ public void setUp() {

@Test
public void getHostReleaseInfo_returnsEmpty() throws Exception {
assertThat(ossHostAuxiliaryInfoProviderImpl.getHostReleaseInfo("host").get()).isEmpty();
assertThat(
ossHostAuxiliaryInfoProviderImpl
.getHostReleaseInfo("host", new UniverseScope.SelfUniverse())
.get())
.isEmpty();
}

@Test
public void getPassThroughFlags_returnsEmpty() throws Exception {
assertThat(ossHostAuxiliaryInfoProviderImpl.getPassThroughFlags("host").get()).isEmpty();
assertThat(
ossHostAuxiliaryInfoProviderImpl
.getPassThroughFlags("host", new UniverseScope.SelfUniverse())
.get())
.isEmpty();
}

@Test
public void getDiagnosticLinks_returnsEmpty() throws Exception {
assertThat(ossHostAuxiliaryInfoProviderImpl.getDiagnosticLinks("host", Optional.empty()).get())
assertThat(
ossHostAuxiliaryInfoProviderImpl
.getDiagnosticLinks("host", Optional.empty(), new UniverseScope.SelfUniverse())
.get())
.isEmpty();
}
}
Loading