Delete DeviceSideCollectorSpecification
It was an exploration attempt. Not really useful.
Test: unit tests
Bug: 145235078
Change-Id: I1e378d52f4316e632f2df6f8aeaeb6da64296d68
diff --git a/src/com/android/tradefed/config/Configuration.java b/src/com/android/tradefed/config/Configuration.java
index e081867..7a7adbf 100644
--- a/src/com/android/tradefed/config/Configuration.java
+++ b/src/com/android/tradefed/config/Configuration.java
@@ -24,7 +24,6 @@
import com.android.tradefed.device.IDeviceSelection;
import com.android.tradefed.device.TestDeviceOptions;
import com.android.tradefed.device.metric.IMetricCollector;
-import com.android.tradefed.device.metric.target.DeviceSideCollectorSpecification;
import com.android.tradefed.log.ILeveledLogOutput;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.log.StdoutLogger;
@@ -176,9 +175,6 @@
DEVICE_METRICS_COLLECTOR_TYPE_NAME,
new ObjTypeInfo(IMetricCollector.class, true));
sObjTypeMap.put(
- DEVICE_SIDE_SPEC_TYPE_NAME,
- new ObjTypeInfo(DeviceSideCollectorSpecification.class, false));
- sObjTypeMap.put(
METRIC_POST_PROCESSOR_TYPE_NAME,
new ObjTypeInfo(BasePostProcessor.class, true));
sObjTypeMap.put(SANBOX_OPTIONS_TYPE_NAME, new ObjTypeInfo(SandboxOptions.class, false));
@@ -410,13 +406,6 @@
/** {@inheritDoc} */
@Override
- public DeviceSideCollectorSpecification getDeviceSideCollectorsSpec() {
- return (DeviceSideCollectorSpecification)
- getConfigurationObject(DEVICE_SIDE_SPEC_TYPE_NAME);
- }
-
- /** {@inheritDoc} */
- @Override
public ICommandOptions getCommandOptions() {
return (ICommandOptions) getConfigurationObject(CMD_OPTIONS_TYPE_NAME);
}
@@ -748,12 +737,6 @@
/** {@inheritDoc} */
@Override
- public void setDeviceSideCollectorSpec(DeviceSideCollectorSpecification deviceCollectorSpec) {
- setConfigurationObjectNoThrow(DEVICE_SIDE_SPEC_TYPE_NAME, deviceCollectorSpec);
- }
-
- /** {@inheritDoc} */
- @Override
public void setPostProcessors(List<IPostProcessor> processors) {
setConfigurationObjectListNoThrow(METRIC_POST_PROCESSOR_TYPE_NAME, processors);
}
diff --git a/src/com/android/tradefed/config/IConfiguration.java b/src/com/android/tradefed/config/IConfiguration.java
index a2b9e96..4359d24 100644
--- a/src/com/android/tradefed/config/IConfiguration.java
+++ b/src/com/android/tradefed/config/IConfiguration.java
@@ -22,7 +22,6 @@
import com.android.tradefed.device.IDeviceSelection;
import com.android.tradefed.device.TestDeviceOptions;
import com.android.tradefed.device.metric.IMetricCollector;
-import com.android.tradefed.device.metric.target.DeviceSideCollectorSpecification;
import com.android.tradefed.log.ILeveledLogOutput;
import com.android.tradefed.postprocessor.IPostProcessor;
import com.android.tradefed.result.ILogSaver;
@@ -142,12 +141,6 @@
public List<IPostProcessor> getPostProcessors();
/**
- * Gets the {@link DeviceSideCollectorSpecification} driving the device/target-side
- * specification of the collectors and their options.
- */
- public DeviceSideCollectorSpecification getDeviceSideCollectorsSpec();
-
- /**
* Gets the {@link ICommandOptions} to use from the configuration.
*
* @return the {@link ICommandOptions} provided in the configuration.
@@ -412,9 +405,6 @@
/** Set the list of {@link IMetricCollector}s, replacing any existing values. */
public void setDeviceMetricCollectors(List<IMetricCollector> collectors);
- /** Set the {@link DeviceSideCollectorSpecification}, replacing any existing values. */
- public void setDeviceSideCollectorSpec(DeviceSideCollectorSpecification deviceCollectorSpec);
-
/** Set the list of {@link IPostProcessor}s, replacing any existing values. */
public void setPostProcessors(List<IPostProcessor> processors);
diff --git a/src/com/android/tradefed/device/metric/target/DeviceSideCollectorSpecification.java b/src/com/android/tradefed/device/metric/target/DeviceSideCollectorSpecification.java
deleted file mode 100644
index bc71c70..0000000
--- a/src/com/android/tradefed/device/metric/target/DeviceSideCollectorSpecification.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * 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
- *
- * http://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.android.tradefed.device.metric.target;
-
-import com.android.tradefed.config.Option;
-import com.android.tradefed.config.OptionClass;
-import com.android.tradefed.device.metric.BaseDeviceMetricCollector;
-import com.android.tradefed.util.MultiMap;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Tradefed object to specify a device collector defined in:
- *
- * <p>platform_testing/libraries/device-collectors. This allows to specify these objects in the
- * Tradefed xml like the host-side ones and to set their options.
- */
-@OptionClass(alias = "device-target-collector")
-public final class DeviceSideCollectorSpecification {
-
- @Option(
- name = "collectors-qualified-name",
- description =
- "The fully qualified name of each device side collector that wants to be added "
- + "to the instrumentation. Example: --collectors-qualified-name "
- + "android.device.collectors.ScreenshotListener",
- mandatory = true)
- private List<String> mCollectorQualifiedName = new ArrayList<>();
-
- @Option(
- name = "collector-options",
- description =
- "Specify device side collector's options that will be given to the "
- + "instrumentation. Can be prepended with the alias to target a "
- + "specific collector. Example: --collector-options "
- + "screenshot-collector:screenshot-quality 75"
- + "or --collector-options screenshot-quality 75 (without the alias).")
- private MultiMap<String, String> mInstrumentationArgs = new MultiMap<>();
-
- /**
- * The filtering options are part of BaseMetricListener and shared by all device side
- * collectors, so we put them on their own to make it clear. Shares its name with the base host
- * side collectors in order to easily target both host and device side groups.
- */
- @Option(
- name = BaseDeviceMetricCollector.TEST_CASE_INCLUDE_GROUP_OPTION,
- description =
- "The 'include-filter-group' to run the collector only against some methods.")
- private List<String> mIncludeGroupFilters = new ArrayList<>();
-
- @Option(
- name = BaseDeviceMetricCollector.TEST_CASE_EXCLUDE_GROUP_OPTION,
- description =
- "The 'exclude-filter-group' to run the collector only against some methods.")
- private List<String> mExcludeGroupFilters = new ArrayList<>();
-
- /**
- * Returns the {@link MultiMap} of device side collector options to be added to the
- * instrumentation.
- */
- public MultiMap<String, String> getCollectorOptions() {
- return mInstrumentationArgs;
- }
-
- /** Returns the {@link List} of collectors to be added to the instrumentation. */
- public List<String> getCollectorNames() {
- return mCollectorQualifiedName;
- }
-
- /** Returns the {@link List} of groups to be included via --include-filter-group. */
- public List<String> getIncludeGroupFilters() {
- return mIncludeGroupFilters;
- }
-
- /** Returns the {@link List} of groups to be excluded via --exclude-filter-group. */
- public List<String> getExcludeGroupFilters() {
- return mExcludeGroupFilters;
- }
-}
diff --git a/src/com/android/tradefed/guice/InvocationScopeModule.java b/src/com/android/tradefed/guice/InvocationScopeModule.java
index 5cd5a7a..c7fbe09 100644
--- a/src/com/android/tradefed/guice/InvocationScopeModule.java
+++ b/src/com/android/tradefed/guice/InvocationScopeModule.java
@@ -16,7 +16,6 @@
package com.android.tradefed.guice;
import com.android.tradefed.config.IConfiguration;
-import com.android.tradefed.device.metric.target.DeviceSideCollectorSpecification;
import com.android.tradefed.invoker.IRescheduler;
import com.google.inject.AbstractModule;
@@ -50,11 +49,6 @@
.toProvider(InvocationScope.<IConfiguration>seededKeyProvider())
.in(InvocationScoped.class);
- // DeviceSideCollectorSpecification is a supported Guice-Tradefed object.
- bind(DeviceSideCollectorSpecification.class)
- .toProvider(InvocationScope.<DeviceSideCollectorSpecification>seededKeyProvider())
- .in(InvocationScoped.class);
-
// Bind rescheduler
bind(IRescheduler.class)
.toProvider(InvocationScope.<IRescheduler>seededKeyProvider())
diff --git a/test_framework/com/android/tradefed/testtype/AndroidJUnitTest.java b/test_framework/com/android/tradefed/testtype/AndroidJUnitTest.java
index adee140..ade2e48 100644
--- a/test_framework/com/android/tradefed/testtype/AndroidJUnitTest.java
+++ b/test_framework/com/android/tradefed/testtype/AndroidJUnitTest.java
@@ -18,13 +18,11 @@
import com.android.ddmlib.testrunner.IRemoteAndroidTestRunner;
import com.android.tradefed.config.ConfigurationException;
-import com.android.tradefed.config.IConfiguration;
import com.android.tradefed.config.Option;
import com.android.tradefed.config.OptionClass;
import com.android.tradefed.config.OptionCopier;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.device.metric.target.DeviceSideCollectorSpecification;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.metrics.proto.MetricMeasurement.Metric;
import com.android.tradefed.result.ITestInvocationListener;
@@ -32,7 +30,6 @@
import com.android.tradefed.util.ListInstrumentationParser;
import com.google.common.annotations.VisibleForTesting;
-import com.google.inject.Inject;
import org.junit.runner.notification.RunListener;
@@ -43,9 +40,9 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
-import java.util.Set;
/**
* A Test that runs an instrumentation test package on given device using the
@@ -168,22 +165,11 @@
// Flag to avoid re-sharding a test that already was.
private boolean mIsSharded = false;
- // Special object that can tune some device side aspects.
- private DeviceSideCollectorSpecification mDeviceSideSpec = null;
-
public AndroidJUnitTest() {
super();
setEnforceFormat(true);
}
- /** Guice-injected object, that can influence the instrumentation args. */
- @Inject
- public void setDeviceSpec(IConfiguration spec) {
- if (spec.getDeviceSideCollectorsSpec() != null) {
- mDeviceSideSpec = spec.getDeviceSideCollectorsSpec();
- }
- }
-
/**
* {@inheritDoc}
*/
@@ -437,26 +423,6 @@
runner.addInstrumentationArg(
NEW_RUN_LISTENER_ORDER_KEY, Boolean.toString(mNewRunListenerOrderMode));
}
-
- // Load the device side configuration from Guice
- if (mDeviceSideSpec != null) {
- CLog.d("Got a DeviceSideCollectorSpecification from Guice Tradefed.");
- mExtraDeviceListeners.addAll(mDeviceSideSpec.getCollectorNames());
- for (String key : mDeviceSideSpec.getCollectorOptions().keySet()) {
- runner.addInstrumentationArg(
- key, ArrayUtil.join(",", mDeviceSideSpec.getCollectorOptions().get(key)));
- }
- if (!mDeviceSideSpec.getExcludeGroupFilters().isEmpty()) {
- runner.addInstrumentationArg(
- EXCLUDE_COLLECTOR_FILTER_KEY,
- ArrayUtil.join(",", mDeviceSideSpec.getExcludeGroupFilters()));
- }
- if (!mDeviceSideSpec.getIncludeGroupFilters().isEmpty()) {
- runner.addInstrumentationArg(
- INCLUDE_COLLECTOR_FILTER_KEY,
- ArrayUtil.join(",", mDeviceSideSpec.getIncludeGroupFilters()));
- }
- }
// Add the listeners received from Options
addDeviceListeners(mExtraDeviceListeners);
}
diff --git a/tests/src/com/android/tradefed/testtype/AndroidJUnitTestTest.java b/tests/src/com/android/tradefed/testtype/AndroidJUnitTestTest.java
index 85b8245..aeeba7b 100644
--- a/tests/src/com/android/tradefed/testtype/AndroidJUnitTestTest.java
+++ b/tests/src/com/android/tradefed/testtype/AndroidJUnitTestTest.java
@@ -26,21 +26,15 @@
import com.android.ddmlib.testrunner.IRemoteAndroidTestRunner;
import com.android.ddmlib.testrunner.TestIdentifier;
import com.android.tradefed.config.Configuration;
-import com.android.tradefed.config.IConfiguration;
import com.android.tradefed.config.OptionSetter;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.device.metric.target.DeviceSideCollectorSpecification;
import com.android.tradefed.guice.InvocationScope;
-import com.android.tradefed.guice.InvocationScopeModule;
import com.android.tradefed.metrics.proto.MetricMeasurement.Metric;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.result.ITestLifeCycleReceiver;
import com.android.tradefed.util.FileUtil;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
import org.easymock.EasyMock;
import org.junit.After;
import org.junit.Before;
@@ -502,39 +496,4 @@
assertNull(((AndroidJUnitTest) res.get(0)).split(2));
assertNull(((AndroidJUnitTest) res.get(0)).split());
}
-
- /**
- * Test that the runner can get {@link DeviceSideCollectorSpecification} from the Guice scope in
- * order to complete the instrumentation options.
- */
- @Test
- public void testSetRunnerArgs_guice() throws Exception {
- mAndroidJUnitTest =
- new AndroidJUnitTest() {
- @Override
- IRemoteAndroidTestRunner createRemoteAndroidTestRunner(
- String packageName, String runnerName, IDevice device) {
- return mMockRemoteRunner;
- }
- };
- // default to no timeout for simplicity
- mAndroidJUnitTest.setTestTimeout(TEST_TIMEOUT);
- mAndroidJUnitTest.setShellTimeout(SHELL_TIMEOUT);
-
- // Seed the Guice Scope
- DeviceSideCollectorSpecification spec = new DeviceSideCollectorSpecification();
- OptionSetter setter = new OptionSetter(spec);
- setter.setOptionValue("collectors-qualified-name", "com.test.collector");
- setter.setOptionValue("collector-options", "key", "value");
- IConfiguration config = new Configuration("test", "test");
- config.setDeviceSideCollectorSpec(spec);
- mScope.seed(IConfiguration.class, config);
-
- Injector injector = Guice.createInjector(new InvocationScopeModule(mScope));
- injector.injectMembers(mAndroidJUnitTest);
- mMockRemoteRunner.addInstrumentationArg("key", "value");
- EasyMock.replay(mMockRemoteRunner, mMockTestDevice);
- mAndroidJUnitTest.setRunnerArgs(mMockRemoteRunner);
- EasyMock.verify(mMockRemoteRunner, mMockTestDevice);
- }
}