ISandbox

public interface ISandbox

com.android.tradefed.sandbox.ISandbox


Interface defining a sandbox that can be used to run an invocation.

Summary

Public methods

abstract String createClasspath(File workingDir)

Create a classpath based on the environment and the working directory returned by getTradefedSandboxEnvironment(com.android.tradefed.invoker.IInvocationContext, com.android.tradefed.config.IConfiguration, String[]).

abstract IConfiguration createThinLauncherConfig(String[] args, IKeyStoreClient keyStoreClient, IRunUtil runUtil, File globalConfig)

Special mode disconnected from main run: When a configuration does not appear to exists in the parent, we fallback to thin launcher where we attempt to setup the sandbox with currently known informations and fill up the working directory to create the config fully in the versioned dir.

default discoverTests(IInvocationContext context, IConfiguration configuration)

A sub-step of prepareEnvironment(com.android.tradefed.invoker.IInvocationContext, com.android.tradefed.config.IConfiguration, com.android.tradefed.result.ITestInvocationListener) which discovers tests if SandboxOptions.shouldUseTestDiscovery() is enabled.

default discoverTests(IInvocationContext context, IConfiguration configuration, ITestLogger logger)
default IFolderBuildInfo fetchSandboxExtraArtifacts(IInvocationContext context, IConfiguration configuration, String[] args)

Sub-step of prepareEnvironment(com.android.tradefed.invoker.IInvocationContext, com.android.tradefed.config.IConfiguration, com.android.tradefed.result.ITestInvocationListener) which fetch additional files needed for the sandbox.

default File getTradefedSandboxEnvironment(IInvocationContext context, IConfiguration nonVersionedConfig, String[] args)

Returns the sandbox environment TF to be used based on the command line arguments.

default File getTradefedSandboxEnvironment(IInvocationContext context, IConfiguration nonVersionedConfig, ITestLogger logger, String[] args)
abstract Exception prepareEnvironment(IInvocationContext context, IConfiguration configuration, ITestInvocationListener listener)

Prepare the environment for the sandbox to run properly.

abstract CommandResult run(TestInformation info, IConfiguration configuration, ITestLogger logger)

Run the sandbox with the environment that was set.

abstract void tearDown()

Clean up any states, files or environment that may have been changed.

Public methods

createClasspath

public abstract String createClasspath (File workingDir)

Create a classpath based on the environment and the working directory returned by getTradefedSandboxEnvironment(com.android.tradefed.invoker.IInvocationContext, com.android.tradefed.config.IConfiguration, String[]).

Parameters
workingDir File: the current working directory for the sandbox.

Returns
String The classpath to be use.

Throws
ConfigurationException

createThinLauncherConfig

public abstract IConfiguration createThinLauncherConfig (String[] args, 
                IKeyStoreClient keyStoreClient, 
                IRunUtil runUtil, 
                File globalConfig)

Special mode disconnected from main run: When a configuration does not appear to exists in the parent, we fallback to thin launcher where we attempt to setup the sandbox with currently known informations and fill up the working directory to create the config fully in the versioned dir.

Parameters
args String: The original command line args.

keyStoreClient IKeyStoreClient: the current keystore client to use to create configurations.

runUtil IRunUtil: the current IRunUtil to run host commands.

globalConfig File: The global configuration to use to run subprocesses of TF.

Returns
IConfiguration a File pointing to the configuration XML of TF for NON_VERSIONED objects. Returns null if no thin launcher config could be created.

discoverTests

public  discoverTests (IInvocationContext context, 
                IConfiguration configuration)

A sub-step of prepareEnvironment(com.android.tradefed.invoker.IInvocationContext, com.android.tradefed.config.IConfiguration, com.android.tradefed.result.ITestInvocationListener) which discovers tests if SandboxOptions.shouldUseTestDiscovery() is enabled.

Parameters
context IInvocationContext: the current invocation IInvocationContext.

configuration IConfiguration: the IConfiguration for the command to run.

Returns
The map of discovered tests or null if unsupported or failed.

discoverTests

public  discoverTests (IInvocationContext context, 
                IConfiguration configuration, 
                ITestLogger logger)

Parameters
context IInvocationContext

configuration IConfiguration

logger ITestLogger

Returns

fetchSandboxExtraArtifacts

public IFolderBuildInfo fetchSandboxExtraArtifacts (IInvocationContext context, 
                IConfiguration configuration, 
                String[] args)

Sub-step of prepareEnvironment(com.android.tradefed.invoker.IInvocationContext, com.android.tradefed.config.IConfiguration, com.android.tradefed.result.ITestInvocationListener) which fetch additional files needed for the sandbox.

Parameters
context IInvocationContext: the current invocation IInvocationContext.

configuration IConfiguration: the IConfiguration for the command to run.

args String: the command line arguments.

Returns
IFolderBuildInfo the fetched build for the additional sandboxed files.

Throws
com.android.tradefed.build.BuildRetrievalError
com.android.tradefed.config.ConfigurationException
IOException
BuildRetrievalError
ConfigurationException

getTradefedSandboxEnvironment

public File getTradefedSandboxEnvironment (IInvocationContext context, 
                IConfiguration nonVersionedConfig, 
                String[] args)

Returns the sandbox environment TF to be used based on the command line arguments.

Parameters
context IInvocationContext: the IInvocationContext of the parent.

nonVersionedConfig IConfiguration: the IConfiguration representing the non versioned objects.

args String: the command line arguments.

Returns
File a ERROR(/File) directory containing the TF sandbox environment jars.

getTradefedSandboxEnvironment

public File getTradefedSandboxEnvironment (IInvocationContext context, 
                IConfiguration nonVersionedConfig, 
                ITestLogger logger, 
                String[] args)

Parameters
context IInvocationContext

nonVersionedConfig IConfiguration

logger ITestLogger

args String

Returns
File

prepareEnvironment

public abstract Exception prepareEnvironment (IInvocationContext context, 
                IConfiguration configuration, 
                ITestInvocationListener listener)

Prepare the environment for the sandbox to run properly.

Parameters
context IInvocationContext: the current invocation IInvocationContext.

configuration IConfiguration: the IConfiguration for the command to run.

listener ITestInvocationListener: the current invocation ITestInvocationListener where final results should be piped.

Returns
Exception an Exception containing the failure. or Null if successful.

run

public abstract CommandResult run (TestInformation info, 
                IConfiguration configuration, 
                ITestLogger logger)

Run the sandbox with the environment that was set.

Parameters
info TestInformation: the TestInformation describing the invocation

configuration IConfiguration: the IConfiguration for the command to run.

logger ITestLogger: an ITestLogger where we can log files.

Returns
CommandResult a CommandResult with the status of the sandbox run and logs.

tearDown

public abstract void tearDown ()

Clean up any states, files or environment that may have been changed.