InvocationContext

public class InvocationContext
extends Object implements IInvocationContext

java.lang.Object
   ↳ com.android.tradefed.invoker.InvocationContext


Generic implementation of a IInvocationContext.

Summary

Public constructors

InvocationContext()

Creates a BuildInfo using default attribute values.

Public methods

void addAllocatedDevice(Map<String, ITestDevice> deviceWithName)

Track a map of configuration device name associated to a ITestDevice.

void addAllocatedDevice(String devicename, ITestDevice testDevice)

Add a ITestDevice to be tracked by the meta data when the device is allocated.

void addDeviceBuildInfo(String deviceName, IBuildInfo buildinfo)

Add a IBuildInfo to be tracked with the device configuration name.

void addInvocationAttribute(String attributeName, String attributeValue)

Add an Invocation attribute.

void addInvocationAttributes(UniqueMultiMap<String, String> attributesMap)

Add several invocation attributes at once through a UniqueMultiMap.

void addInvocationTimingMetric(IInvocationContext.TimingEvent timingEvent, Long durationMillis)

Add a invocation timing metric.

void addSerialsFromShard(Integer index, List<String> serials)

Add a serial to be tracked as assigned to one of the shard running some tests.

MultiMap<String, String> getAttributes()

Returns a copy of the map containing all the invocation attributes.

IBuildInfo getBuildInfo(String deviceName)

Return the IBuildInfo associated with the device configuration name provided.

IBuildInfo getBuildInfo(ITestDevice testDevice)

Return the IBuildInfo associated with the ITestDevice

List<IBuildInfo> getBuildInfos()

Return all the IBuildInfo tracked for this invocation.

ConfigurationDescriptor getConfigurationDescriptor()

Returns the descriptor associated with the test configuration that launched the invocation

ITestDevice getDevice(String deviceName)

Return the ITestDevice associated with the device configuration name provided.

Map<ITestDeviceIBuildInfo> getDeviceBuildMap()

Return the map of Device/build info association

ITestDevice getDeviceBySerial(String serial)

Returns the ITestDevice associated with the serial provided.

List<String> getDeviceConfigNames()

Return the list of device config names of the device tracked in this invocation

String getDeviceName(ITestDevice device)

Returns the name of the device set in the xml configuration from the ITestDevice.

List<ITestDevice> getDevices()

Return all the allocated device tracked for this invocation.

Map<IInvocationContext.TimingEvent, Long> getInvocationTimingMetrics()

Returns the map containing the invocation timing metrics.

IInvocationContext getModuleInvocationContext()

Returns the invocation context of module while being executed as part of a ITestSuite

int getNumDevicesAllocated()

Return the number of devices allocated for the invocation.

List<String> getSerials()

Return the list of serials of the device tracked in this invocation

Map<Integer, List<String>> getShardsSerials()

Returns the Map of all tracked serials and their shard involved in sharding.

String getTestTag()

Returns the invocation test-tag.

void lockAttributes()

Lock the context to prevent more invocation attributes to be added.

void setConfigurationDescriptor(ConfigurationDescriptor configurationDescriptor)

Sets the descriptor associated with the test configuration that launched the invocation

void setModuleInvocationContext(IInvocationContext invocationContext)

Sets the invocation context of module while being executed as part of a ITestSuite

void setRecoveryModeForAllDevices(ITestDevice.RecoveryMode mode)

Sets the ITestDevice.RecoveryMode of all the devices part of the context

void setTestTag(String testTag)

Sets the invocation test-tag.

Public constructors

InvocationContext

public InvocationContext ()

Creates a BuildInfo using default attribute values.

Public methods

addAllocatedDevice

public void addAllocatedDevice (Map<String, ITestDevice> deviceWithName)

Track a map of configuration device name associated to a ITestDevice. Doesn't clear the previous tracking before adding.

Parameters
deviceWithName Map: the Map of additional device to track

addAllocatedDevice

public void addAllocatedDevice (String devicename, 
                ITestDevice testDevice)

Add a ITestDevice to be tracked by the meta data when the device is allocated. will set the build info to null in the map.

Parameters
devicename String: the device configuration name to associate with the ITestDevice

testDevice ITestDevice: to be added to the allocated devices.

addDeviceBuildInfo

public void addDeviceBuildInfo (String deviceName, 
                IBuildInfo buildinfo)

Add a IBuildInfo to be tracked with the device configuration name.

Parameters
deviceName String: the device configuration name

buildinfo IBuildInfo: a IBuildInfo associated to the device configuration name.

addInvocationAttribute

public void addInvocationAttribute (String attributeName, 
                String attributeValue)

Add an Invocation attribute.

Parameters
attributeName String

attributeValue String

addInvocationAttributes

public void addInvocationAttributes (UniqueMultiMap<String, String> attributesMap)

Add several invocation attributes at once through a UniqueMultiMap.

Parameters
attributesMap UniqueMultiMap

addInvocationTimingMetric

public void addInvocationTimingMetric (IInvocationContext.TimingEvent timingEvent, 
                Long durationMillis)

Add a invocation timing metric.

Parameters
timingEvent IInvocationContext.TimingEvent

durationMillis Long

addSerialsFromShard

public void addSerialsFromShard (Integer index, 
                List<String> serials)

Add a serial to be tracked as assigned to one of the shard running some tests.

Parameters
index Integer: the index of the shard using the serials

serials List: The list of serials to be tracked.

getAttributes

public MultiMap<String, String> getAttributes ()

Returns a copy of the map containing all the invocation attributes.

Returns
MultiMap<String, String>

getBuildInfo

public IBuildInfo getBuildInfo (String deviceName)

Return the IBuildInfo associated with the device configuration name provided. Returns null, if the deviceName cannot be matched.

Parameters
deviceName String

Returns
IBuildInfo

getBuildInfo

public IBuildInfo getBuildInfo (ITestDevice testDevice)

Return the IBuildInfo associated with the ITestDevice

Parameters
testDevice ITestDevice

Returns
IBuildInfo

getBuildInfos

public List<IBuildInfo> getBuildInfos ()

Return all the IBuildInfo tracked for this invocation.

Returns
List<IBuildInfo>

getConfigurationDescriptor

public ConfigurationDescriptor getConfigurationDescriptor ()

Returns the descriptor associated with the test configuration that launched the invocation

Returns
ConfigurationDescriptor

getDevice

public ITestDevice getDevice (String deviceName)

Return the ITestDevice associated with the device configuration name provided.

Parameters
deviceName String

Returns
ITestDevice

getDeviceBuildMap

public Map<ITestDeviceIBuildInfo> getDeviceBuildMap ()

Return the map of Device/build info association

Returns
Map<ITestDeviceIBuildInfo>

getDeviceBySerial

public ITestDevice getDeviceBySerial (String serial)

Returns the ITestDevice associated with the serial provided. Refrain from using too much as it's not the fastest lookup.

Parameters
serial String

Returns
ITestDevice

getDeviceConfigNames

public List<String> getDeviceConfigNames ()

Return the list of device config names of the device tracked in this invocation

Returns
List<String>

getDeviceName

public String getDeviceName (ITestDevice device)

Returns the name of the device set in the xml configuration from the ITestDevice. Returns null, if ITestDevice cannot be matched.

Parameters
device ITestDevice

Returns
String

getDevices

public List<ITestDevice> getDevices ()

Return all the allocated device tracked for this invocation.

Returns
List<ITestDevice>

getInvocationTimingMetrics

public Map<IInvocationContext.TimingEvent, Long> getInvocationTimingMetrics ()

Returns the map containing the invocation timing metrics.

Returns
Map<IInvocationContext.TimingEvent, Long>

getModuleInvocationContext

public IInvocationContext getModuleInvocationContext ()

Returns the invocation context of module while being executed as part of a ITestSuite

Returns
IInvocationContext

getNumDevicesAllocated

public int getNumDevicesAllocated ()

Return the number of devices allocated for the invocation.

Returns
int

getSerials

public List<String> getSerials ()

Return the list of serials of the device tracked in this invocation

Returns
List<String>

getShardsSerials

public Map<Integer, List<String>> getShardsSerials ()

Returns the Map of all tracked serials and their shard involved in sharding. Empty if not a sharded invocation.

Returns
Map<Integer, List<String>>

getTestTag

public String getTestTag ()

Returns the invocation test-tag.

Returns
String

lockAttributes

public void lockAttributes ()

Lock the context to prevent more invocation attributes to be added.

setConfigurationDescriptor

public void setConfigurationDescriptor (ConfigurationDescriptor configurationDescriptor)

Sets the descriptor associated with the test configuration that launched the invocation

Parameters
configurationDescriptor ConfigurationDescriptor

setModuleInvocationContext

public void setModuleInvocationContext (IInvocationContext invocationContext)

Sets the invocation context of module while being executed as part of a ITestSuite

Parameters
invocationContext IInvocationContext

setRecoveryModeForAllDevices

public void setRecoveryModeForAllDevices (ITestDevice.RecoveryMode mode)

Sets the ITestDevice.RecoveryMode of all the devices part of the context

Parameters
mode ITestDevice.RecoveryMode

setTestTag

public void setTestTag (String testTag)

Sets the invocation test-tag.

Parameters
testTag String