TradefedSandbox
public
class
TradefedSandbox
extends Object
implements
ISandbox
| java.lang.Object | |
| ↳ | com.android.tradefed.sandbox.TradefedSandbox |
Sandbox container that can run a Trade Federation invocation. TODO: Allow Options to be passed to the sandbox.
Summary
Constants | |
|---|---|
String |
EXTRA_TARGET_LAB
|
String |
GENERAL_TESTS_ZIP
|
String |
SANDBOX_ENABLED
|
Public constructors | |
|---|---|
TradefedSandbox()
|
|
Public methods | |
|---|---|
String
|
createClasspath(File workingDir)
Create a classpath based on the environment and the working directory returned by |
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. |
File
|
getTradefedSandboxEnvironment(IInvocationContext context, IConfiguration nonVersionedConfig, ITestLogger logger, String[] args)
|
static
Set<String>
|
matchSandboxExtraBuildTargetByConfigName(String configName)
Given the test config name, match the extra build targets from Sandbox's extra build targets. |
Exception
|
prepareEnvironment(IInvocationContext context, IConfiguration config, ITestInvocationListener listener)
Prepare the environment for the sandbox to run properly. |
static
String[]
|
removeIncompatibleFlags(String[] args)
|
CommandResult
|
run(TestInformation info, IConfiguration config, ITestLogger logger)
Run the sandbox with the environment that was set. |
void
|
tearDown()
Clean up any states, files or environment that may have been changed. |
Protected methods | |
|---|---|
File
|
dumpGlobalConfig(IConfiguration config, Set<String> exclusionPatterns)
Dump the global configuration filtered from some objects. |
String
|
getJava()
|
Exception
|
prepareConfiguration(IInvocationContext context, IConfiguration config, ITestInvocationListener listener)
Prepare the |
File
|
prepareContext(IInvocationContext context, IConfiguration config)
Prepare and serialize the |
Constants
EXTRA_TARGET_LAB
public static final String EXTRA_TARGET_LAB
Constant Value: "lab"
GENERAL_TESTS_ZIP
public static final String GENERAL_TESTS_ZIP
Constant Value: "general-tests.zip"
SANDBOX_ENABLED
public static final String SANDBOX_ENABLED
Constant Value: "SANDBOX_ENABLED"
Public constructors
TradefedSandbox
public TradefedSandbox ()
Public methods
createClasspath
public String createClasspath (File workingDir)
Create a classpath based on the environment and the working directory returned by getTradefedSandboxEnvironment(IInvocationContext,IConfiguration,String[]).
| Parameters | |
|---|---|
workingDir |
File: the current working directory for the sandbox. |
| Returns | |
|---|---|
String |
The classpath to be use. |
| Throws | |
|---|---|
ConfigurationException |
|
createThinLauncherConfig
public 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. |
getTradefedSandboxEnvironment
public File getTradefedSandboxEnvironment (IInvocationContext context, IConfiguration nonVersionedConfig, ITestLogger logger, String[] args)
| Parameters | |
|---|---|
context |
IInvocationContext |
nonVersionedConfig |
IConfiguration |
logger |
ITestLogger |
args |
String |
| Returns | |
|---|---|
File |
|
| Throws | |
|---|---|
Exception |
|
matchSandboxExtraBuildTargetByConfigName
public static Set<String> matchSandboxExtraBuildTargetByConfigName (String configName)
Given the test config name, match the extra build targets from Sandbox's extra build targets.
| Parameters | |
|---|---|
configName |
String |
| Returns | |
|---|---|
Set<String> |
|
prepareEnvironment
public Exception prepareEnvironment (IInvocationContext context, IConfiguration config, ITestInvocationListener listener)
Prepare the environment for the sandbox to run properly.
| Parameters | |
|---|---|
context |
IInvocationContext: the current invocation IInvocationContext. |
config |
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. |
removeIncompatibleFlags
public static String[] removeIncompatibleFlags (String[] args)
| Parameters | |
|---|---|
args |
String |
| Returns | |
|---|---|
String[] |
|
run
public CommandResult run (TestInformation info, IConfiguration config, ITestLogger logger)
Run the sandbox with the environment that was set.
| Parameters | |
|---|---|
info |
TestInformation: the TestInformation describing the invocation |
config |
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. |
| Throws | |
|---|---|
Throwable |
|
tearDown
public void tearDown ()
Clean up any states, files or environment that may have been changed.
Protected methods
dumpGlobalConfig
protected File dumpGlobalConfig (IConfiguration config, Set<String> exclusionPatterns)
Dump the global configuration filtered from some objects.
| Parameters | |
|---|---|
config |
IConfiguration |
exclusionPatterns |
Set |
| Returns | |
|---|---|
File |
|
| Throws | |
|---|---|
ConfigurationException |
|
IOException |
|
getJava
protected String getJava ()
| Returns | |
|---|---|
String |
|
prepareConfiguration
protected Exception prepareConfiguration (IInvocationContext context, IConfiguration config, ITestInvocationListener listener)
Prepare the IConfiguration that will be passed to the subprocess and will drive the
container execution.
| Parameters | |
|---|---|
context |
IInvocationContext: The current IInvocationContext. |
config |
IConfiguration: the IConfiguration to be prepared. |
listener |
ITestInvocationListener: The current invocation ITestInvocationListener. |
| Returns | |
|---|---|
Exception |
an Exception if anything went wrong, null otherwise. |
prepareContext
protected File prepareContext (IInvocationContext context, IConfiguration config)
Prepare and serialize the IInvocationContext.
| Parameters | |
|---|---|
context |
IInvocationContext: the IInvocationContext to be prepared. |
config |
IConfiguration: The IConfiguration of the sandbox. |
| Returns | |
|---|---|
File |
the serialized IInvocationContext. |
| Throws | |
|---|---|
|
java.io.IOException |
IOException |
|