StrictShardHelper

public class StrictShardHelper
extends ShardHelper

java.lang.Object
   ↳ com.android.tradefed.invoker.shard.ShardHelper
     ↳ com.android.tradefed.invoker.shard.StrictShardHelper


Sharding strategy to create strict shards that do not report together,

Summary

Public constructors

StrictShardHelper()

Public methods

boolean shardConfig(IConfiguration config, IInvocationContext context, IRescheduler rescheduler)

Attempt to shard the configuration into sub-configurations, to be re-scheduled to run on multiple resources in parallel.

Protected methods

List<List<IRemoteTest>> splitTests(List<IRemoteTest> fullList, int shardCount)

Split the list of tests to run however the implementation see fit.

Public constructors

StrictShardHelper

public StrictShardHelper ()

Public methods

shardConfig

public boolean shardConfig (IConfiguration config, 
                IInvocationContext context, 
                IRescheduler rescheduler)

Attempt to shard the configuration into sub-configurations, to be re-scheduled to run on multiple resources in parallel.

A successful shard action renders the current config empty, and invocation should not proceed.

Parameters
config IConfiguration: the current IConfiguration.

context IInvocationContext: the IInvocationContext holding the tests information.

rescheduler IRescheduler: the IRescheduler

Returns
boolean true if test was sharded. Otherwise return false

Protected methods

splitTests

protected List<List<IRemoteTest>> splitTests (List<IRemoteTest> fullList, 
                int shardCount)

Split the list of tests to run however the implementation see fit. Sharding needs to be consistent. It is acceptable to return an empty list if no tests can be run in the shard.

Implement this in order to provide a test suite specific sharding. The default implementation attempts to balance the number of IRemoteTest per shards as much as possible as a first step, then use a minor criteria or run-hint to adjust the lists a bit more.

Parameters
fullList List: the initial full list of IRemoteTest containing all the tests that need to run.

shardCount int: the total number of shard that need to run.

Returns
List<List<IRemoteTest>> a list of list IRemoteTests that have been assigned to each shard. The list size will be the shardCount.