IInvocationContext

public interface IInvocationContext

com.android.tradefed.invoker.IInvocationContext


Holds information about the Invocation for the tests to access if needed. Tests should not modify the context contained here so only getters will be available, except for the context attributes for reporting purpose.

Summary

Constants

String INVOCATION_ID

Key used for storing associated invocation ID.

Public methods

abstract void addAllocatedDevice( deviceWithName)

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

abstract void addAllocatedDevice(String deviceName, ITestDevice testDevice)

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

abstract void addDeviceBuildInfo(String deviceName, IBuildInfo buildinfo)

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

abstract void addInvocationAttribute(String attributeName, String attributeValue)

Add an Invocation attribute.

abstract void addInvocationAttributes(MultiMap<String, String> attributesMap)

Add several invocation attributes at once through a UniqueMultiMap.

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

Add a invocation timing metric.

abstract void addSerialsFromShard(Integer index, serials)

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

default String getAttribute(String key)

A convenient method for retrieving invocation context attribute as a single key-value pair.

abstract MultiMap<String, String> getAttributes()

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

abstract IBuildInfo getBuildInfo(String deviceName)

Return the IBuildInfo associated with the device configuration name provided.

abstract IBuildInfo getBuildInfo(ITestDevice testDevice)

Return the IBuildInfo associated with the ITestDevice

abstract String getBuildInfoName(IBuildInfo info)

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

abstract getBuildInfos()

Return all the IBuildInfo tracked for this invocation.

abstract ConfigurationDescriptor getConfigurationDescriptor()

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

abstract ITestDevice getDevice(String deviceName)

Return the ITestDevice associated with the device configuration name provided.

abstract getDeviceBuildMap()

Return the map of Device/build info association

abstract ITestDevice getDeviceBySerial(String serial)

Returns the ITestDevice associated with the serial provided.

abstract getDeviceConfigNames()

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

abstract String getDeviceName(ITestDevice device)

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

abstract getDevices()

Return all the allocated device tracked for this invocation.

abstract String getInvocationId()
default getInvocationTimingMetrics()

Returns the map containing the invocation timing metrics.

abstract IInvocationContext getModuleInvocationContext()

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

abstract int getNumDevicesAllocated()

Return the number of devices allocated for the invocation.

abstract getSerials()

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

abstract getShardsSerials()

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

abstract String getTestTag()

Returns the invocation test-tag.

abstract void markReleasedEarly()

Mark the devices are getting released early.

abstract void setConfigurationDescriptor(ConfigurationDescriptor configurationDescriptor)

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

abstract void setModuleInvocationContext(IInvocationContext invocationContext)

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

abstract void setRecoveryModeForAllDevices(ITestDevice.RecoveryMode mode)

Sets the RecoveryMode of all the devices part of the context

abstract void setTestTag(String testTag)

Sets the invocation test-tag.

abstract InvocationContext.Context toProto()

Serialize a the context instance into a protobuf.

abstract boolean wasReleasedEarly()

Returns whether or not the devices were released early and won't be used anymore.

Constants

INVOCATION_ID

public static final String INVOCATION_ID

Key used for storing associated invocation ID.

Constant Value: "invocation-id"

Public methods

addAllocatedDevice

public abstract void addAllocatedDevice ( deviceWithName)

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

Parameters
deviceWithName : the ERROR(/Map) of additional device to track

addAllocatedDevice

public abstract 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 abstract 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 abstract void addInvocationAttribute (String attributeName, 
                String attributeValue)

Add an Invocation attribute.

Parameters
attributeName String

attributeValue String

addInvocationAttributes

public abstract void addInvocationAttributes (MultiMap<String, String> attributesMap)

Add several invocation attributes at once through a UniqueMultiMap.

Parameters
attributesMap MultiMap

addInvocationTimingMetric

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

Add a invocation timing metric.

Parameters
timingEvent IInvocationContext.TimingEvent

durationMillis Long

addSerialsFromShard

public abstract void addSerialsFromShard (Integer index, 
                 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 : The list of serials to be tracked.

getAttribute

public String getAttribute (String key)

A convenient method for retrieving invocation context attribute as a single key-value pair. Never return null.

Parameters
key String

Returns
String empty string when key doesn't exist, the value otherwise.

getAttributes

public abstract MultiMap<String, String> getAttributes ()

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

Returns
MultiMap<String, String>

getBuildInfo

public abstract 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 abstract IBuildInfo getBuildInfo (ITestDevice testDevice)

Return the IBuildInfo associated with the ITestDevice

Parameters
testDevice ITestDevice

Returns
IBuildInfo

getBuildInfoName

public abstract String getBuildInfoName (IBuildInfo info)

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

Parameters
info IBuildInfo

Returns
String

getBuildInfos

public abstract  getBuildInfos ()

Return all the IBuildInfo tracked for this invocation.

Returns

getConfigurationDescriptor

public abstract ConfigurationDescriptor getConfigurationDescriptor ()

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

Returns
ConfigurationDescriptor

getDevice

public abstract ITestDevice getDevice (String deviceName)

Return the ITestDevice associated with the device configuration name provided.

Parameters
deviceName String

Returns
ITestDevice

getDeviceBuildMap

public abstract  getDeviceBuildMap ()

Return the map of Device/build info association

Returns

getDeviceBySerial

public abstract 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 abstract  getDeviceConfigNames ()

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

Returns

getDeviceName

public abstract 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 abstract  getDevices ()

Return all the allocated device tracked for this invocation.

Returns

getInvocationId

public abstract String getInvocationId ()

Returns
String associated invocation ID or null if not linked to an invocation

getInvocationTimingMetrics

public  getInvocationTimingMetrics ()

Returns the map containing the invocation timing metrics.

Returns

getModuleInvocationContext

public abstract IInvocationContext getModuleInvocationContext ()

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

Returns
IInvocationContext

getNumDevicesAllocated

public abstract int getNumDevicesAllocated ()

Return the number of devices allocated for the invocation.

Returns
int

getSerials

public abstract  getSerials ()

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

Returns

getShardsSerials

public abstract  getShardsSerials ()

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

Returns

getTestTag

public abstract String getTestTag ()

Returns the invocation test-tag.

Returns
String

markReleasedEarly

public abstract void markReleasedEarly ()

Mark the devices are getting released early.

setConfigurationDescriptor

public abstract void setConfigurationDescriptor (ConfigurationDescriptor configurationDescriptor)

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

Parameters
configurationDescriptor ConfigurationDescriptor

setModuleInvocationContext

public abstract void setModuleInvocationContext (IInvocationContext invocationContext)

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

Parameters
invocationContext IInvocationContext

setRecoveryModeForAllDevices

public abstract void setRecoveryModeForAllDevices (ITestDevice.RecoveryMode mode)

Sets the RecoveryMode of all the devices part of the context

Parameters
mode ITestDevice.RecoveryMode

setTestTag

public abstract void setTestTag (String testTag)

Sets the invocation test-tag.

Parameters
testTag String

toProto

public abstract InvocationContext.Context toProto ()

Serialize a the context instance into a protobuf.

Returns
InvocationContext.Context

wasReleasedEarly

public abstract boolean wasReleasedEarly ()

Returns whether or not the devices were released early and won't be used anymore.

Returns
boolean