IMetricCollector
public
interface
IMetricCollector
implements
IDisableable,
ILogSaverListener
| com.android.tradefed.device.metric.IMetricCollector
|
Known indirect subclasses
AtraceCollector, AtraceRunMetricCollector, BaseDeviceMetricCollector, BluetoothConnectionLatencyCollector, BluetoothConnectionStateCollector, BluetoothHciSnoopLogCollector, BugreportzOnFailureCollector, BugreportzOnTestCaseFailureCollector, ClangCodeCoverageCollector, CodeCoverageCollector, CountTestCasesCollector, DebugHostLogOnFailureCollector, DeviceTraceCollector, FilePullerDeviceMetricCollector, FilePullerLogCollector, and 16 others.
|
This interface will be added as a decorator when reporting tests results in order to collect
matching metrics.
This interface cannot be used as a even it extends ITestInvocationListener. The configuration checking will reject it. It must be used as a
"metrics_collector".
Collectors are not expected to keep an internal state as they may be re-used in several
places. If an internal state really must be used, then it should be cleaned on init(IInvocationContext,ITestInvocationListener).
Summary
Public methods |
default
boolean
|
captureModuleLevel()
Whether or not the collector is applicable to module level capture and should be init.
|
default
boolean
|
doesModuleContainFailure()
Returns true if current module contained any test case or test run failures.
|
default
void
|
enableDefaultMetricCollection()
Allows collectors to enable default metrics collection.
|
default
IMetricCollector.MetricCollectionLevel
|
getAlwaysOnCollectionLevel()
|
abstract
List<IBuildInfo>
|
getBuildInfos()
Returns the list of build information available in the invocation.
|
abstract
List<ITestDevice>
|
getDevices()
Returns the list of devices available in the invocation.
|
abstract
ITestInvocationListener
|
getInvocationListener()
Returns the original ITestInvocationListener where we are forwarding the results.
|
default
IMetricCollector.MetricCollectionLevel
|
getOnFailureCollectionLevel()
|
abstract
ITestInvocationListener
|
init(IInvocationContext context, ITestInvocationListener listener)
Initialization of the collector with the current context and where to forward results.
|
default
boolean
|
isDefaultMetricCollectionEnabled()
Whether the collector is collecting metrics as part of default metric collection.
|
abstract
void
|
onTestAssumptionFailure(DeviceMetricData testData, TestDescription test)
Callback when a test case fails with assumption failure.
|
abstract
void
|
onTestEnd(DeviceMetricData testData, Map<String, MetricMeasurement.Metric> currentTestCaseMetrics, TestDescription test)
Callback when a test case is ended.
|
abstract
void
|
onTestEnd(DeviceMetricData testData, Map<String, MetricMeasurement.Metric> currentTestCaseMetrics)
Callback when a test case is ended.
|
abstract
void
|
onTestFail(DeviceMetricData testData, TestDescription test)
Callback when a test case fails.
|
default
void
|
onTestModuleEnded()
Allows capturing the module ended event.
|
default
void
|
onTestModuleStarted()
Allows capturing the module started event.
|
abstract
void
|
onTestRunEnd(DeviceMetricData runData, Map<String, MetricMeasurement.Metric> currentRunMetrics)
Callback when a test run is ended.
|
abstract
void
|
onTestRunStart(DeviceMetricData runData)
Callback when a test run is started.
|
default
void
|
onTestRunStart(DeviceMetricData runData, int testCount)
Callback when a test run is started.
|
default
void
|
onTestRunStartBlocking()
Explicit callback to start a collector manually if it supports it.
|
abstract
void
|
onTestStart(DeviceMetricData testData)
Callback when a test case is started.
|
default
void
|
setAlwaysOnCollectionLevel(IMetricCollector.MetricCollectionLevel level)
Sets the level at which the collector should collect logs regardless of failures.
|
default
void
|
setModuleContainsFailure()
Sets whether the module had any failures (test case, test run).
|
default
void
|
setOnFailureCollectionLevel(IMetricCollector.MetricCollectionLevel level)
Sets the level at which the collector should collect logs during failures.
|
Public methods
captureModuleLevel
public boolean captureModuleLevel ()
Whether or not the collector is applicable to module level capture and should be init.
doesModuleContainFailure
public boolean doesModuleContainFailure ()
Returns true if current module contained any test case or test run failures.
enableDefaultMetricCollection
public void enableDefaultMetricCollection ()
Allows collectors to enable default metrics collection. When default metric collection is
enabled, the collector should only collect at the specified collection level.
getBuildInfos
public abstract List<IBuildInfo> getBuildInfos ()
Returns the list of build information available in the invocation.
getDevices
public abstract List<ITestDevice> getDevices ()
Returns the list of devices available in the invocation.
init
public abstract ITestInvocationListener init (IInvocationContext context,
ITestInvocationListener listener)
Initialization of the collector with the current context and where to forward results. Will
only be called once per instance, and the collector is expected to update its internal
context and listener. Init will never be called during a test run always before.
Do not override unless you know what you are doing.
isDefaultMetricCollectionEnabled
public boolean isDefaultMetricCollectionEnabled ()
Whether the collector is collecting metrics as part of default metric collection.
onTestAssumptionFailure
public abstract void onTestAssumptionFailure (DeviceMetricData testData,
TestDescription test)
Callback when a test case fails with assumption failure.
| Parameters |
testData |
DeviceMetricData: the DeviceMetricData holding the data for the test case. |
test |
TestDescription: the TestDescription of the test case in progress. |
onTestEnd
public abstract void onTestEnd (DeviceMetricData testData,
Map<String, MetricMeasurement.Metric> currentTestCaseMetrics,
TestDescription test)
Callback when a test case is ended. This should be the time for clean up.
onTestEnd
public abstract void onTestEnd (DeviceMetricData testData,
Map<String, MetricMeasurement.Metric> currentTestCaseMetrics)
Callback when a test case is ended. This should be the time for clean up.
onTestModuleEnded
public void onTestModuleEnded ()
Allows capturing the module ended event.
onTestModuleStarted
public void onTestModuleStarted ()
Allows capturing the module started event.
onTestRunEnd
public abstract void onTestRunEnd (DeviceMetricData runData,
Map<String, MetricMeasurement.Metric> currentRunMetrics)
Callback when a test run is ended. This should be the time for clean up.
onTestRunStart
public abstract void onTestRunStart (DeviceMetricData runData)
Callback when a test run is started.
| Parameters |
runData |
DeviceMetricData: the DeviceMetricData holding the data for the run. |
onTestRunStart
public void onTestRunStart (DeviceMetricData runData,
int testCount)
Callback when a test run is started.
| Parameters |
runData |
DeviceMetricData: the DeviceMetricData holding the data for the run. |
testCount |
int: the number of test cases in this test run. |
onTestRunStartBlocking
public void onTestRunStartBlocking ()
Explicit callback to start a collector manually if it supports it. This allows to ensure we
are out of some test lifecycle which are asynchronous.
onTestStart
public abstract void onTestStart (DeviceMetricData testData)
Callback when a test case is started.
| Parameters |
testData |
DeviceMetricData: the DeviceMetricData holding the data for the test case. |
setAlwaysOnCollectionLevel
public void setAlwaysOnCollectionLevel (IMetricCollector.MetricCollectionLevel level)
Sets the level at which the collector should collect logs regardless of failures.
NULL level will result in no collection.
| Parameters |
level |
IMetricCollector.MetricCollectionLevel: MetricCollectionLevel at which the logs will be collected. |
setModuleContainsFailure
public void setModuleContainsFailure ()
Sets whether the module had any failures (test case, test run).
setOnFailureCollectionLevel
public void setOnFailureCollectionLevel (IMetricCollector.MetricCollectionLevel level)
Sets the level at which the collector should collect logs during failures.
NULL level will result in no collection.
| Parameters |
level |
IMetricCollector.MetricCollectionLevel: MetricCollectionLevel at which the logs will be collected. |