GranularRetriableTestWrapper

public class GranularRetriableTestWrapper
extends Object implements IRemoteTest

java.lang.Object
   ↳ com.android.tradefed.testtype.suite.GranularRetriableTestWrapper


A wrapper class works on the IRemoteTest to granulate the IRemoteTest in testcase level. An IRemoteTest can contain multiple testcases. Previously, these testcases are treated as a whole: When IRemoteTest runs, all testcases will run. Some IRemoteTest (The ones that implements ITestFilterReceiver) can accept a whitelist of testcases and only run those testcases. This class takes advantage of the existing feature and provides a more flexible way to run test suite.

  • Single testcase can be retried multiple times (within the same IRemoteTest run) to reduce the non-test-error failure rates.
  • The retried testcases are dynamically collected from previous run failures.

Note:

  • The prerequisite to run a subset of test cases is that the test type should implement the interface ITestFilterReceiver.
  • X is customized max retry number.

Summary

Public constructors

GranularRetriableTestWrapper(IRemoteTest test, TestFailureListener failureListener, List<ITestInvocationListener> moduleLevelListeners, int maxRunLimit)

Public methods

TestRunResult getFinalTestRunResult()

Get the merged TestRunResults from each IRemoteTest run.

int getNumIndividualTests()

Calculate the number of testcases in the IRemoteTest.

boolean hasFailed()

Check if any testRunResult has ever failed.

void run(ITestInvocationListener listener)

Schedule a series of IRemoteTest "run".

void setInvocationContext(IInvocationContext moduleInvocationContext)

Set the IInvocationContext as a GranularRetriableTestWrapper attribute.

void setLogSaver(ILogSaver logSaver)

Set the Module's ILogSaver as a GranularRetriableTestWrapper attribute.

void setMarkTestsSkipped(boolean skipTestCases)

Set the ModuleDefinition RunStrategy as a GranularRetriableTestWrapper attribute.

void setMetricCollectors(List<IMetricCollector> runMetricCollectors)

Set the ModuleDefinition's runMetricCollector as a GranularRetriableTestWrapper attribute.

void setModuleConfig(IConfiguration moduleConfiguration)

Set the ModuleDefinition's ModuleConfig as a GranularRetriableTestWrapper attribute.

void setModuleId(String moduleId)

Set the ModuleDefinition name as a GranularRetriableTestWrapper attribute.

Public constructors

GranularRetriableTestWrapper

public GranularRetriableTestWrapper (IRemoteTest test, 
                TestFailureListener failureListener, 
                List<ITestInvocationListener> moduleLevelListeners, 
                int maxRunLimit)

Parameters
test IRemoteTest

failureListener TestFailureListener

moduleLevelListeners List

maxRunLimit int

Public methods

getFinalTestRunResult

public TestRunResult getFinalTestRunResult ()

Get the merged TestRunResults from each IRemoteTest run.

Returns
TestRunResult

getNumIndividualTests

public int getNumIndividualTests ()

Calculate the number of testcases in the IRemoteTest. This value distincts the same testcases that are rescheduled multiple times.

Returns
int

hasFailed

public boolean hasFailed ()

Check if any testRunResult has ever failed.

Returns
boolean

run

public void run (ITestInvocationListener listener)

Schedule a series of IRemoteTest "run". TODO: Customize the retry strategy; Each run is granularized to a subset of the whole testcases.

Parameters
listener ITestInvocationListener: The ResultForwarder listener which contains a new moduleListener for each run.

Throws
DeviceNotAvailableException

setInvocationContext

public void setInvocationContext (IInvocationContext moduleInvocationContext)

Set the IInvocationContext as a GranularRetriableTestWrapper attribute.

Parameters
moduleInvocationContext IInvocationContext: The wrapper uses the InvocationContext to initialize the MetricCollector when necessary.

setLogSaver

public void setLogSaver (ILogSaver logSaver)

Set the Module's ILogSaver as a GranularRetriableTestWrapper attribute.

Parameters
logSaver ILogSaver: The listeners for each test run should save the logs.

setMarkTestsSkipped

public void setMarkTestsSkipped (boolean skipTestCases)

Set the ModuleDefinition RunStrategy as a GranularRetriableTestWrapper attribute.

Parameters
skipTestCases boolean: whether the testcases should be skipped.

setMetricCollectors

public void setMetricCollectors (List<IMetricCollector> runMetricCollectors)

Set the ModuleDefinition's runMetricCollector as a GranularRetriableTestWrapper attribute.

Parameters
runMetricCollectors List: A list of MetricCollector for the module.

setModuleConfig

public void setModuleConfig (IConfiguration moduleConfiguration)

Set the ModuleDefinition's ModuleConfig as a GranularRetriableTestWrapper attribute.

Parameters
moduleConfiguration IConfiguration: Provide the module metrics.

setModuleId

public void setModuleId (String moduleId)

Set the ModuleDefinition name as a GranularRetriableTestWrapper attribute.

Parameters
moduleId String: the name of the moduleDefinition.