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 @@ -175,6 +175,7 @@ public enum InfraErrorId implements ErrorId {
LAB_DEVICE_PROVIDER_GET_DEVICE_ERROR(40_478, ErrorType.INFRA_ISSUE),
LAB_DEVICE_PROVIDER_DEVICE_FEATURE_SIZE_MISMATCH(40_479, ErrorType.INFRA_ISSUE),
LAB_JOB_SYNC_CLOSE_TEST_ERROR(40_480, ErrorType.INFRA_ISSUE),
LAB_RPC_EXEC_TEST_DECOUPLING_NOT_SUPPORTED(40_481, ErrorType.INFRA_ISSUE),

// Test engine/container: 40_701 ~ 40_800
TE_CREATE_DEVICE_HELPER_CONTAINER_DOES_NOT_HAVE(40_701, ErrorType.INFRA_ISSUE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ java_library(
"//src/java/com/google/devtools/mobileharness/infra/controller/test/model:test_execution_unit",
"//src/java/com/google/devtools/mobileharness/infra/lab/controller/util:lab_file_notifier",
"//src/java/com/google/devtools/mobileharness/shared/util/logging:google_logger",
"//src/java/com/google/wireless/qa/mobileharness/shared/api/device",
"@maven//:com_google_code_findbugs_jsr305",
"@maven//:com_google_errorprone_error_prone_annotations",
"@maven//:com_google_guava_guava",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static com.google.common.base.Preconditions.checkState;

import com.google.common.collect.ImmutableList;
import com.google.common.flogger.FluentLogger;
import com.google.devtools.mobileharness.api.model.allocation.Allocation;
import com.google.devtools.mobileharness.api.model.error.InfraErrorId;
Expand All @@ -35,7 +36,9 @@
import com.google.devtools.mobileharness.infra.lab.proto.File.JobOrTestFileUnit;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.concurrent.GuardedBy;
import com.google.wireless.qa.mobileharness.shared.api.device.Device;
import java.time.Duration;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CountDownLatch;

Expand Down Expand Up @@ -86,18 +89,27 @@ public class ProxyToDirectTestRunner extends AbstractProxyTestRunner<ProxyToDire
@GuardedBy("launchProxiedTestLock")
private boolean cachedKillTimeout;

private final ImmutableList<Device> devices;

public ProxyToDirectTestRunner(
TestRunnerLauncher<? super ProxyToDirectTestRunner> launcher,
TestExecutionUnit testExecutionUnit,
Allocation allocation,
List<Device> devices,
LabFileNotifier proxiedTestLabFileNotifier,
TestEngineLocator testEngineLocator)
throws TestRunnerLauncherConnectedException {
super(launcher, testExecutionUnit, allocation);
this.devices = ImmutableList.copyOf(devices);
this.proxiedTestLabFileNotifier = proxiedTestLabFileNotifier;
this.testEngineLocator = testEngineLocator;
}

/** Gets the devices for the test. */
public ImmutableList<Device> getDevices() {
return devices;
}

@Override
public void notifyJobOrTestFile(JobOrTestFileUnit fileUnit) {
proxiedTestLabFileNotifier.notifyJobOrTestFile(fileUnit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ java_library(
name = "allocated_device_provisioning_module",
srcs = ["AllocatedDeviceProvisioningModule.java"],
visibility = [
"//:omnilab_fusion",
"//src/java/com/google/devtools/mobileharness/infra/lab:__subpackages__",
],
deps = [
Expand All @@ -85,6 +86,7 @@ java_library(
name = "local_device_provisioning_module",
srcs = ["LocalDeviceProvisioningModule.java"],
visibility = [
"//:omnilab_fusion",
"//src/java/com/google/devtools/mobileharness/infra/lab:__subpackages__",
],
deps = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ java_library(
"//src/java/com/google/devtools/mobileharness/infra/controller/test/model:test_execution_result",
"//src/java/com/google/devtools/mobileharness/shared/util/concurrent:callables",
"//src/java/com/google/devtools/mobileharness/shared/util/logging:google_logger",
"//src/java/com/google/devtools/mobileharness/shared/util/logging:tag",
"@maven//:com_google_code_findbugs_jsr305",
"@maven//:com_google_guava_guava",
],
Expand All @@ -142,3 +143,34 @@ java_library(
"//src/java/com/google/devtools/mobileharness/infra/controller/test:direct_test_runner",
],
)

java_library(
name = "thread_pool_launcher_provisioning_module",
srcs = ["ThreadPoolLauncherProvisioningModule.java"],
visibility = [
"//:omnilab_fusion",
"//src/java/com/google/devtools/mobileharness/infra/lab:__pkg__",
],
deps = [
":launcher_provider",
":test_runner_thread_pool",
":thread_pool_test_runner_launcher_provider",
"//src/java/com/google/devtools/mobileharness/shared/util/concurrent:thread_pools",
"@maven//:com_google_inject_guice",
"@maven//:javax_inject_jsr330_api",
],
)

java_library(
name = "local_device_launcher_provisioning_module",
srcs = ["LocalDeviceLauncherProvisioningModule.java"],
visibility = [
"//:omnilab_fusion",
"//src/java/com/google/devtools/mobileharness/infra/lab:__pkg__",
],
deps = [
":launcher_provider",
":local_device_test_runner_launcher_provider",
"@maven//:com_google_inject_guice",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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.
*/

package com.google.devtools.mobileharness.infra.controller.test.launcher;

import com.google.inject.AbstractModule;

/** Module for providing {@link LocalDeviceTestRunnerLauncherProvider}. */
public class LocalDeviceLauncherProvisioningModule extends AbstractModule {

@Override
protected void configure() {
bind(LauncherProvider.class).to(LocalDeviceTestRunnerLauncherProvider.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.
*/

package com.google.devtools.mobileharness.infra.controller.test.launcher;

import com.google.devtools.mobileharness.shared.util.concurrent.ThreadPools;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;

/** Module for providing {@link ThreadPoolTestRunnerLauncher}. */
public class ThreadPoolLauncherProvisioningModule extends AbstractModule {

@Override
protected void configure() {
bind(LauncherProvider.class).to(ThreadPoolTestRunnerLauncherProvider.class);
}

@Provides
@Singleton
@TestRunnerThreadPool
ExecutorService provideTestRunnerThreadPool() {
return ThreadPools.createStandardThreadPool("test-runner-thread-pool");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public Dirs getJobDirs(String jobId, String testId) throws MobileHarnessExceptio
return getProxyToDirectTestRunner(testId).getTestExecutionUnit().job().dirs();
}

private ProxyToDirectTestRunner getProxyToDirectTestRunner(String testId)
public ProxyToDirectTestRunner getProxyToDirectTestRunner(String testId)
throws MobileHarnessException {
ProxyTestRunner proxyTestRunner = getTestRunnerNonEmpty(testId);
if (proxyTestRunner.isContainerMode()) {
Expand Down
6 changes: 6 additions & 0 deletions src/java/com/google/devtools/mobileharness/infra/lab/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@ java_library(
"//src/java/com/google/devtools/mobileharness/infra/controller/device/config:api_config_file_processor",
"//src/java/com/google/devtools/mobileharness/infra/controller/device/external:external_device_manager",
"//src/java/com/google/devtools/mobileharness/infra/controller/device/external:noop_external_device_manager",
"//src/java/com/google/devtools/mobileharness/infra/controller/device/provider:allocated_device_provisioning_module",
"//src/java/com/google/devtools/mobileharness/infra/controller/device/provider:local_device_provisioning_module",
"//src/java/com/google/devtools/mobileharness/infra/controller/messaging:message_sender_finder",
"//src/java/com/google/devtools/mobileharness/infra/controller/messaging:messaging_manager",
"//src/java/com/google/devtools/mobileharness/infra/controller/messaging:messaging_manager_holder",
"//src/java/com/google/devtools/mobileharness/infra/controller/messaging:messaging_service",
"//src/java/com/google/devtools/mobileharness/infra/controller/messaging:messaging_service_module",
"//src/java/com/google/devtools/mobileharness/infra/controller/test/launcher:local_device_launcher_provisioning_module",
"//src/java/com/google/devtools/mobileharness/infra/controller/test/launcher:thread_pool_launcher_provisioning_module",
"//src/java/com/google/devtools/mobileharness/infra/controller/test/manager",
"//src/java/com/google/devtools/mobileharness/infra/controller/test/manager:lab_direct_test_runner_util",
"//src/java/com/google/devtools/mobileharness/infra/controller/test/manager:proxy_test_manager",
Expand All @@ -101,6 +105,8 @@ java_library(
"//src/java/com/google/devtools/mobileharness/infra/master/rpc/stub:lab_sync",
"//src/java/com/google/devtools/mobileharness/infra/master/rpc/stub/grpc:job_sync",
"//src/java/com/google/devtools/mobileharness/infra/master/rpc/stub/grpc:lab_sync",
"//src/java/com/google/devtools/mobileharness/service/deviceconfig/rpc/stub:annotation",
"//src/java/com/google/devtools/mobileharness/service/deviceconfig/rpc/stub:device_config_stub",
"//src/java/com/google/devtools/mobileharness/shared/constant:log_record_importance",
"//src/java/com/google/devtools/mobileharness/shared/constant/hostmanagement:host_property_constants",
"//src/java/com/google/devtools/mobileharness/shared/file/resolver:abstract_file_resolver",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@
import com.google.devtools.mobileharness.infra.controller.device.bootstrap.DetectorsAndDispatchers;
import com.google.devtools.mobileharness.infra.controller.device.external.ExternalDeviceManager;
import com.google.devtools.mobileharness.infra.controller.device.external.NoopExternalDeviceManager;
import com.google.devtools.mobileharness.infra.controller.device.provider.AllocatedDeviceProvisioningModule;
import com.google.devtools.mobileharness.infra.controller.device.provider.LocalDeviceProvisioningModule;
import com.google.devtools.mobileharness.infra.controller.messaging.MessageSenderFinder;
import com.google.devtools.mobileharness.infra.controller.messaging.MessagingManager;
import com.google.devtools.mobileharness.infra.controller.messaging.MessagingManagerHolder;
import com.google.devtools.mobileharness.infra.controller.messaging.MessagingServiceModule;
import com.google.devtools.mobileharness.infra.controller.test.launcher.LocalDeviceLauncherProvisioningModule;
import com.google.devtools.mobileharness.infra.controller.test.launcher.ThreadPoolLauncherProvisioningModule;
import com.google.devtools.mobileharness.infra.controller.test.manager.LabDirectTestRunnerUtil;
import com.google.devtools.mobileharness.infra.controller.test.manager.ProxyTestManager;
import com.google.devtools.mobileharness.infra.controller.test.manager.TestManager;
Expand All @@ -52,6 +56,7 @@
import com.google.devtools.mobileharness.shared.file.resolver.LocalFileResolver;
import com.google.devtools.mobileharness.shared.util.concurrent.ServiceModule;
import com.google.devtools.mobileharness.shared.util.file.local.LocalFileUtil;
import com.google.devtools.mobileharness.shared.util.flags.Flags;
import com.google.devtools.mobileharness.shared.util.system.SystemUtil;
import com.google.inject.AbstractModule;
import com.google.inject.Key;
Expand Down Expand Up @@ -92,6 +97,13 @@ protected void configure() {
bind(new Key<TestManager<?>>() {}).to(ProxyTestManager.class);
bind(LabDirectTestRunnerHolder.class).to(ProxyTestManager.class);
bind(EventBus.class).annotatedWith(GlobalEventBus.class).toInstance(globalInternalBus);
if (Flags.instance().enableDeviceTestDecoupling.get()) {
install(new AllocatedDeviceProvisioningModule());
install(new ThreadPoolLauncherProvisioningModule());
} else {
install(new LocalDeviceProvisioningModule());
install(new LocalDeviceLauncherProvisioningModule());
}

Multibinder<Object> subscriberBinder =
Multibinder.newSetBinder(binder(), Key.get(Object.class, GlobalEventBusSubscriber.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ java_library(
name = "prepare_test",
srcs = ["PrepareTestServiceImpl.java"],
deps = [
"//src/devtools/mobileharness/api/model/proto:job_java_proto",
"//src/devtools/mobileharness/infra/container/proto:mode_setting_java_proto",
"//src/devtools/mobileharness/infra/container/proto:test_engine_java_proto",
"//src/devtools/mobileharness/infra/lab/proto:prepare_test_service_java_proto",
Expand All @@ -53,10 +52,9 @@ java_library(
"//src/java/com/google/devtools/mobileharness/api/model/lab:locator",
"//src/java/com/google/devtools/mobileharness/infra/container/controller:proxy_test_runner",
"//src/java/com/google/devtools/mobileharness/infra/container/controller:proxy_to_direct_test_runner",
"//src/java/com/google/devtools/mobileharness/infra/controller/device:test_executor",
"//src/java/com/google/devtools/mobileharness/infra/controller/device:test_executor_provider",
"//src/java/com/google/devtools/mobileharness/infra/controller/device/provider:device_provider",
"//src/java/com/google/devtools/mobileharness/infra/controller/test:abstract_test_runner",
"//src/java/com/google/devtools/mobileharness/infra/controller/test/launcher:local_device_test_runner_launcher",
"//src/java/com/google/devtools/mobileharness/infra/controller/test/launcher:launcher_provider",
"//src/java/com/google/devtools/mobileharness/infra/controller/test/manager:proxy_test_manager",
"//src/java/com/google/devtools/mobileharness/infra/controller/test/model:test_execution_unit",
"//src/java/com/google/devtools/mobileharness/infra/lab:annotations",
Expand All @@ -77,7 +75,6 @@ java_library(
"//src/java/com/google/devtools/mobileharness/shared/version",
"//src/java/com/google/devtools/mobileharness/shared/version/checker",
"//src/java/com/google/wireless/qa/mobileharness/shared/api",
"//src/java/com/google/wireless/qa/mobileharness/shared/proto:job_java_proto",
"//src/java/com/google/wireless/qa/mobileharness/shared/util:base",
"//src/java/com/google/wireless/qa/mobileharness/shared/util:device",
"//src/java/com/google/wireless/qa/mobileharness/shared/util:net_util",
Expand All @@ -99,6 +96,7 @@ java_library(
"//src/java/com/google/devtools/mobileharness/infra/controller/test:direct_test_runner",
"//src/java/com/google/devtools/mobileharness/infra/controller/test:direct_test_runner_setting",
"//src/java/com/google/devtools/mobileharness/infra/controller/test/exception",
"//src/java/com/google/devtools/mobileharness/infra/controller/test/manager:proxy_test_manager",
"//src/java/com/google/devtools/mobileharness/infra/lab/common/env",
"//src/java/com/google/devtools/mobileharness/infra/lab/controller:file_publisher",
"//src/java/com/google/devtools/mobileharness/infra/lab/controller:forwarding_test_message_buffer",
Expand All @@ -109,6 +107,7 @@ java_library(
"//src/java/com/google/devtools/mobileharness/infra/lab/rpc/service/util:test_info_creator",
"//src/java/com/google/devtools/mobileharness/shared/util/comm/messaging/message",
"//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/message:str_pair",
"//src/java/com/google/wireless/qa/mobileharness/lab/proto:exec_test_serv_java_proto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.google.devtools.mobileharness.infra.controller.test.DirectTestRunnerSetting;
import com.google.devtools.mobileharness.infra.controller.test.TestRunnerLauncher;
import com.google.devtools.mobileharness.infra.controller.test.exception.TestRunnerLauncherConnectedException;
import com.google.devtools.mobileharness.infra.controller.test.manager.ProxyTestManager;
import com.google.devtools.mobileharness.infra.lab.common.env.UtrsEnvironments;
import com.google.devtools.mobileharness.infra.lab.controller.FilePublisher;
import com.google.devtools.mobileharness.infra.lab.controller.ForwardingTestMessageBuffer;
Expand All @@ -43,6 +44,7 @@
import com.google.devtools.mobileharness.infra.lab.rpc.service.util.TestInfoCreator;
import com.google.devtools.mobileharness.shared.util.comm.messaging.message.TestMessageInfo;
import com.google.devtools.mobileharness.shared.util.file.local.LocalFileUtil;
import com.google.devtools.mobileharness.shared.util.flags.Flags;
import com.google.devtools.mobileharness.shared.util.message.StrPairUtil;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.inject.assistedinject.Assisted;
Expand Down Expand Up @@ -70,7 +72,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import javax.inject.Inject;

Expand All @@ -86,7 +87,6 @@ public interface ExecTestServiceImplFactory {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();

private final LabDirectTestRunnerHolder testRunnerHolder;

private final DeviceHelperFactory deviceHelperFactory;

private final LabResponseProtoGenerator labResponseProtoGenerator;
Expand Down Expand Up @@ -177,10 +177,20 @@ public KickOffTestResponse kickOffTest(KickOffTestRequest req) throws MobileHarn
e);
}

// Gets DeviceHelpers.
List<Device> devices = new ArrayList<>();
for (String deviceId : req.getDeviceIdList()) {
devices.add(deviceHelperFactory.getDeviceHelper(deviceId));
List<Device> devices;
if (Flags.instance().enableDeviceTestDecoupling.get()) {
if (!(testRunnerHolder instanceof ProxyTestManager proxyTestManager)) {
throw new MobileHarnessException(
InfraErrorId.LAB_RPC_EXEC_TEST_DECOUPLING_NOT_SUPPORTED,
"Device decoupling is not supported in this environment.");
}
devices =
proxyTestManager.getProxyToDirectTestRunner(testInfo.locator().getId()).getDevices();
} else {
devices = new ArrayList<>();
for (String deviceId : req.getDeviceIdList()) {
devices.add(deviceHelperFactory.getDeviceHelper(deviceId));
}
}
List<String> deviceIds = devices.stream().map(Device::getDeviceId).collect(toImmutableList());

Expand All @@ -194,7 +204,7 @@ public KickOffTestResponse kickOffTest(KickOffTestRequest req) throws MobileHarn
devices.stream()
.map(Device::getDimensions)
.map(StrPairUtil::convertCollectionToMultimap)
.collect(Collectors.toList()));
.collect(toImmutableList()));

// Creates DirectTestRunner.
TestRunnerLauncher<? super DirectTestRunner> connectorTestRunnerLauncher =
Expand Down
Loading