LaunchControlProvider

public class LaunchControlProvider
extends Object implements IBuildProvider, IConfigurationReceiver, IDiscoverDependencies, IInvocationContextReceiver, ITestLoggerReceiver

java.lang.Object
   ↳ com.google.android.tradefed.build.LaunchControlProvider


A IBuildProvider implementation that queries the Google launch control servers for a build to test.

Subclassing is discouraged. Use extra-target-downloads and --additional-files-filter to specify artifacts to download.

TODO: refactor out the launch control client and download logic, and merge it with the future "One Common Device Flasher Library To Rule Them All" (tm)

Summary

Nested classes

class LaunchControlProvider.DownloadFileDescriptor

 

Constants

String BUILD_ID_PARAM

String BUILD_NAME_PARAM

String LC_BASE_URL

String MIN_BUILD_ID_PARAM

String QUERY_TYPE_PARAM

String QUERY_WINDOW_PARAM

String TEST_TAG_PARAM

Fields

protected boolean mEnableResolveSymlinks

Public constructors

LaunchControlProvider()

Public methods

void addFileFilter(String filter)
void addOptionalFileFilter(String optionalFilter)
void addRemoteZipFilter(String fileFilter)

Add a filter of a remote zip file that can be downloaded partially.

void cleanUp(IBuildInfo info)

Clean up any temporary build files.

void clearExtraDownloads()
IFileDownloader createLaunchControlDownloader(RemoteBuildInfo remoteBuild)

Factory method for creating a downloader to use for launch control files.

void decrementTestBuild(String buildId)
IBuildInfo fetchRemoteBuild(RemoteBuildInfo remoteBuild)

Convert the launch control response into a local IBuildInfo containing all the necessary files.

void forceUseCas(boolean useCas)
Collection<String> getAdditionalFilesFilters()
String getBranch()

Get the currently specified branch to query

IBuildInfo getBuild()

Retrieve the data for build under test.

String getBuildArchivePath()

Get the path to the build artifacts archive

String getBuildFlavor()

Get the build-flavor to query

String getBuildId()

Get the build id to query

String getBuildOs()
IConfiguration getConfiguration()

Return the injected IConfiguration in use.

Set<String> getContentBasedReportingDefault()
IInvocationContext getInvocationContext()
String getLcHostname()

Get the Launch Control hostname to use in query

String getLcProtocol()

Get the Launch Control protocol to use in query

QueryType getQueryType()

Get the query type to be used

RemoteBuildInfo getRemoteBuild()

Get the launch control response without downloading all the files.

Set<String> getRemoteZipFilters()

Get a set of filters for zip files that can be downloaded partially.

boolean getReportContentBasedRollout()
boolean getReportContentInformation()
String getTestConfigOnlyZip()

Get the test only config zip.

ITestLogger getTestLogger()
String getTestTag()

Get the test tag to use in query

boolean getUseSsoClient()

Get if sso client should be used

static void handleExtraTargetDownloads(IBuildInfo build, List<Entry<String, File>> entries)

Handles files dynamically download to backfill their metadata

boolean isChunkingUncompressedDisabled()
boolean isSecondaryParallelDownload()

Whether parallel download is enabled or not.

Set<String> reportTestZipFileFilter()
void resetTestBuild()

Performs a QueryType.RESET_TEST_BUILD query to requests launch control to remove configured build from 'tested builds' set.

void resetTestBuild(String buildId)

Performs a QueryType.RESET_TEST_BUILD query to requests launch control to remove given build from 'tested builds' set.

void setAdditionalFilesFilters(Collection<String> additionalFilesFilters)
void setBranch(String branch)

Set the branch to query

void setBuildArchivePath(String buildArchivePath)

Set the path to the build artifacts archive

void setBuildFlavor(String flavor)

Set the build-flavor to query

void setBuildId(String buildId)

Set the build id to query

void setBuildOs(String os)
void setConfiguration(IConfiguration configuration)

Injects the IConfiguration in use.

void setContentBasedReportingDefault(Set<String> contentBasedReportingDefault)
void setEnableResolveSymlinks(boolean enableResolveSymlinks)
void setFetchSigned(boolean fetchSigned)
void setInvocationContext(IInvocationContext invocationContext)

void setLcHostname(String lcHostname)

Set the Launch Control hostname to use in query

void setLcProtocol(String lcProtocol)

Set the Launch Control protocol to use in query

void setMinBuildId(int minBuildId)

Set the min build id to use.

void setParallelSecondaryDownload(boolean parallel)
void setPartialDownloadForZip(boolean enableZipPartialDownload)
void setQueryType(QueryType queryType)

Set the query type to be used

void setReportContentBasedRollout(boolean reportContentBasedRollout)
void setReportContentInformation(boolean reportContentInfo)
void setSkipCloudContent(boolean skipCloudContent)
void setTestLogger(ITestLogger testLogger)

Injects the ITestLogger instance

void setTestTag(String tag)

Set the test-tag to be used.

void setUseBuildApi(boolean useBuildApi)

Sets the value to control if the build provider should use Android Build API

void setUseSsoClient(boolean useSsoClient)

Set if sso client should be used

boolean shouldFetchSigned()
boolean shouldReportContentInformation()
boolean shouldUseBuildApi()

Return if the build provider should use Android Build API

Protected methods

void convertBuildToSigned(RemoteBuildInfo remoteBuild)

Modify parameters in this RemoteBuildInfo to describe a signed build.

IHttpHelper createHttpHelper()

Factory method for creating a HttpHelper.

String createSignedParameter(String param)

Modify a single parameter to represent a signed parameter If the parameter is already in the signed format, it is returned unchanged.

void deleteCacheEntry(String remoteFilePath)

Remove the file from the cache in case it is corrupted.

void downloadAdditionalFiles(RemoteBuildInfo remoteBuild, IFileDownloader downloader, IBuildInfo localBuild)
IBuildInfo downloadBuildFiles(RemoteBuildInfo remoteBuild, String testTargetName, String buildName, IFileDownloader downloader)

Download the necessary file keys as configured in --download-build-key from the remoteBuild, and store them in a IBuildInfo.

final List<Entry<LaunchControlProvider.DownloadFileDescriptor, File>> downloadFilesNonBlocking(IFileDownloader downloader, List<LaunchControlProvider.DownloadFileDescriptor> toBeDownloaded)

Download the set of file paths and enforce them if they are mandatory.

AndroidBuildArtifactHelper getBuildArtifactHelper()
MultiMap<String, File> getExtraDownloadMap()

Returns the map of extra downloaded targets.

Set<String> getGlobalDownloadExclusionPatterns()
final File getWorkFolder()

Returns the current invocation workfolder.

final File handleDirectoryDownload(File downloadedFile)
RemoteBuildInfo performBuildApiQuery()
void performValidityCheckForBuildApi()
RemoteBuildInfo queryForBuild(MultiMap<String, String> params)

Perform the launch control query, retrying multiple times in case of error.

RemoteBuildInfo queryForBuild()

Perform the launch control query, retrying multiple times in case of error.

RemoteBuildInfo queryForBuildWithBuildApi()

Performs the build query against build API.

void replaceParamWithSigned(RemoteBuildInfo buildInfo, RemoteBuildInfo.BuildAttributeKey key)
boolean useCasDefaultRollout()

Constants

BUILD_ID_PARAM

protected static final String BUILD_ID_PARAM

Constant Value: "bid"

BUILD_NAME_PARAM

protected static final String BUILD_NAME_PARAM

Constant Value: "id"

LC_BASE_URL

protected static final String LC_BASE_URL

Constant Value: "%s://%s/buildbot-update"

MIN_BUILD_ID_PARAM

protected static final String MIN_BUILD_ID_PARAM

Constant Value: "min_build_id"

QUERY_TYPE_PARAM

protected static final String QUERY_TYPE_PARAM

Constant Value: "op"

QUERY_WINDOW_PARAM

protected static final String QUERY_WINDOW_PARAM

Constant Value: "query_window"

TEST_TAG_PARAM

protected static final String TEST_TAG_PARAM

Constant Value: "test_tag"

Fields

protected boolean mEnableResolveSymlinks

Public constructors

LaunchControlProvider

public LaunchControlProvider ()

Public methods

addFileFilter

public void addFileFilter (String filter)

Parameters
filter String

addOptionalFileFilter

public void addOptionalFileFilter (String optionalFilter)

Parameters
optionalFilter String

addRemoteZipFilter

public void addRemoteZipFilter (String fileFilter)

Add a filter of a remote zip file that can be downloaded partially.

Parameters
fileFilter String

cleanUp

public void cleanUp (IBuildInfo info)

Clean up any temporary build files.

Parameters
info IBuildInfo

clearExtraDownloads

public void clearExtraDownloads ()

createLaunchControlDownloader

public IFileDownloader createLaunchControlDownloader (RemoteBuildInfo remoteBuild)

Factory method for creating a downloader to use for launch control files.

Parameters
remoteBuild RemoteBuildInfo

Returns
IFileDownloader

decrementTestBuild

public void decrementTestBuild (String buildId)

Parameters
buildId String

fetchRemoteBuild

public IBuildInfo fetchRemoteBuild (RemoteBuildInfo remoteBuild)

Convert the launch control response into a local IBuildInfo containing all the necessary files.

Made public so specializations outside of this package can use it directly. Normally getBuild() should be used instead.

Parameters
remoteBuild RemoteBuildInfo: the launch control server response

Returns
IBuildInfo the IBuildInfo populated with local versions of build files

Throws
BuildRetrievalError if build files could not be downloaded

forceUseCas

public void forceUseCas (boolean useCas)

Parameters
useCas boolean

getAdditionalFilesFilters

public Collection<String> getAdditionalFilesFilters ()

Returns
Collection<String>

getBranch

public String getBranch ()

Get the currently specified branch to query

Returns
String the branch

getBuild

public IBuildInfo getBuild ()

Retrieve the data for build under test.

Returns
IBuildInfo the IBuildInfo for build under test or null if no build is available for testing

Throws
BuildRetrievalError

getBuildArchivePath

public String getBuildArchivePath ()

Get the path to the build artifacts archive

Returns
String

getBuildFlavor

public String getBuildFlavor ()

Get the build-flavor to query

Returns
String

getBuildId

public String getBuildId ()

Get the build id to query

Returns
String

getBuildOs

public String getBuildOs ()

Returns
String

getConfiguration

public IConfiguration getConfiguration ()

Return the injected IConfiguration in use.

Returns
IConfiguration

getContentBasedReportingDefault

public Set<String> getContentBasedReportingDefault ()

Returns
Set<String>

getInvocationContext

public IInvocationContext getInvocationContext ()

Returns
IInvocationContext

getLcHostname

public String getLcHostname ()

Get the Launch Control hostname to use in query

Returns
String

getLcProtocol

public String getLcProtocol ()

Get the Launch Control protocol to use in query

Returns
String

getQueryType

public QueryType getQueryType ()

Get the query type to be used

Returns
QueryType

getRemoteBuild

public RemoteBuildInfo getRemoteBuild ()

Get the launch control response without downloading all the files.

Made public so specializations outside of this package can use it directly. Normally getBuild() should be used instead.

Returns
RemoteBuildInfo the RemoteBuildInfo response from launch control

Throws
BuildRetrievalError if build info failed to be retrieved due to an unexpected error

getRemoteZipFilters

public Set<String> getRemoteZipFilters ()

Get a set of filters for zip files that can be downloaded partially.

Returns
Set<String>

getReportContentBasedRollout

public boolean getReportContentBasedRollout ()

Returns
boolean

getReportContentInformation

public boolean getReportContentInformation ()

Returns
boolean

getTestConfigOnlyZip

public String getTestConfigOnlyZip ()

Get the test only config zip.

Returns
String

getTestLogger

public ITestLogger getTestLogger ()

Returns
ITestLogger

getTestTag

public String getTestTag ()

Get the test tag to use in query

Returns
String

getUseSsoClient

public boolean getUseSsoClient ()

Get if sso client should be used

Returns
boolean

handleExtraTargetDownloads

public static void handleExtraTargetDownloads (IBuildInfo build, 
                List<Entry<String, File>> entries)

Handles files dynamically download to backfill their metadata

Parameters
build IBuildInfo

entries List

Throws
BuildRetrievalError

isChunkingUncompressedDisabled

public boolean isChunkingUncompressedDisabled ()

Returns
boolean

isSecondaryParallelDownload

public boolean isSecondaryParallelDownload ()

Whether parallel download is enabled or not.

Returns
boolean

reportTestZipFileFilter

public Set<String> reportTestZipFileFilter ()

Returns
Set<String>

resetTestBuild

public void resetTestBuild ()

Performs a QueryType.RESET_TEST_BUILD query to requests launch control to remove configured build from 'tested builds' set.

Has limited error handling and retry mechanisms Deprecated as LCProxy has sunsetted.

resetTestBuild

public void resetTestBuild (String buildId)

Performs a QueryType.RESET_TEST_BUILD query to requests launch control to remove given build from 'tested builds' set.

Has limited error handling and retry mechanisms Deprecated as LCProxy is sunsetted.

Parameters
buildId String: the build id to reset

setAdditionalFilesFilters

public void setAdditionalFilesFilters (Collection<String> additionalFilesFilters)

Parameters
additionalFilesFilters Collection

setBranch

public void setBranch (String branch)

Set the branch to query

setBuildArchivePath

public void setBuildArchivePath (String buildArchivePath)

Set the path to the build artifacts archive

setBuildFlavor

public void setBuildFlavor (String flavor)

Set the build-flavor to query

setBuildId

public void setBuildId (String buildId)

Set the build id to query

setBuildOs

public void setBuildOs (String os)

Parameters
os String

setConfiguration

public void setConfiguration (IConfiguration configuration)

Injects the IConfiguration in use.

Parameters
configuration IConfiguration

setContentBasedReportingDefault

public void setContentBasedReportingDefault (Set<String> contentBasedReportingDefault)

Parameters
contentBasedReportingDefault Set

setEnableResolveSymlinks

public void setEnableResolveSymlinks (boolean enableResolveSymlinks)

Parameters
enableResolveSymlinks boolean

setFetchSigned

public void setFetchSigned (boolean fetchSigned)

Parameters
fetchSigned boolean

setInvocationContext

public void setInvocationContext (IInvocationContext invocationContext)

Parameters
invocationContext IInvocationContext

setLcHostname

public void setLcHostname (String lcHostname)

Set the Launch Control hostname to use in query

Parameters
lcHostname String

setLcProtocol

public void setLcProtocol (String lcProtocol)

Set the Launch Control protocol to use in query

setMinBuildId

public void setMinBuildId (int minBuildId)

Set the min build id to use.

Parameters
minBuildId int

setParallelSecondaryDownload

public void setParallelSecondaryDownload (boolean parallel)

Parameters
parallel boolean

setPartialDownloadForZip

public void setPartialDownloadForZip (boolean enableZipPartialDownload)

Parameters
enableZipPartialDownload boolean

setQueryType

public void setQueryType (QueryType queryType)

Set the query type to be used

setReportContentBasedRollout

public void setReportContentBasedRollout (boolean reportContentBasedRollout)

Parameters
reportContentBasedRollout boolean

setReportContentInformation

public void setReportContentInformation (boolean reportContentInfo)

Parameters
reportContentInfo boolean

setSkipCloudContent

public void setSkipCloudContent (boolean skipCloudContent)

Parameters
skipCloudContent boolean

setTestLogger

public void setTestLogger (ITestLogger testLogger)

Injects the ITestLogger instance

Parameters
testLogger ITestLogger

setTestTag

public void setTestTag (String tag)

Set the test-tag to be used.

Parameters
tag String

setUseBuildApi

public void setUseBuildApi (boolean useBuildApi)

Sets the value to control if the build provider should use Android Build API

Parameters
useBuildApi boolean

setUseSsoClient

public void setUseSsoClient (boolean useSsoClient)

Set if sso client should be used

Parameters
useSsoClient boolean

shouldFetchSigned

public boolean shouldFetchSigned ()

Returns
boolean

shouldReportContentInformation

public boolean shouldReportContentInformation ()

Returns
boolean

shouldUseBuildApi

public boolean shouldUseBuildApi ()

Return if the build provider should use Android Build API

Returns
boolean

Protected methods

convertBuildToSigned

protected void convertBuildToSigned (RemoteBuildInfo remoteBuild)

Modify parameters in this RemoteBuildInfo to describe a signed build.

Parameters
remoteBuild RemoteBuildInfo: the RemoteBuildInfo to modify

Throws
com.android.tradefed.build.BuildRetrievalError
BuildRetrievalError

createHttpHelper

protected IHttpHelper createHttpHelper ()

Factory method for creating a HttpHelper.

Exposed so it can be mocked for unit testing.

Returns
IHttpHelper

createSignedParameter

protected String createSignedParameter (String param)

Modify a single parameter to represent a signed parameter If the parameter is already in the signed format, it is returned unchanged.

Parameters
param String: the initial parameter (can be unsigned or already signed)

Returns
String the signed parameter

Throws
BuildRetrievalError if the parameter is malformed and cannot be processed

deleteCacheEntry

protected void deleteCacheEntry (String remoteFilePath)

Remove the file from the cache in case it is corrupted.

Parameters
remoteFilePath String: Same remote file as specified in IFileDownloader.downloadFile(String).

downloadAdditionalFiles

protected void downloadAdditionalFiles (RemoteBuildInfo remoteBuild, 
                IFileDownloader downloader, 
                IBuildInfo localBuild)

Parameters
remoteBuild RemoteBuildInfo

downloader IFileDownloader

localBuild IBuildInfo

Throws
BuildRetrievalError

downloadBuildFiles

protected IBuildInfo downloadBuildFiles (RemoteBuildInfo remoteBuild, 
                String testTargetName, 
                String buildName, 
                IFileDownloader downloader)

Download the necessary file keys as configured in --download-build-key from the remoteBuild, and store them in a IBuildInfo.

Parameters
remoteBuild RemoteBuildInfo: the launch control server response

testTargetName String: the test target name

buildName String: the name of the build, as defined by launch control

downloader IFileDownloader: the IFileDownloader to use to download build files

Returns
IBuildInfo the IBuildInfo populated with local versions of build files

Throws
BuildRetrievalError if build files could not be downloaded

downloadFilesNonBlocking

protected final List<Entry<LaunchControlProvider.DownloadFileDescriptor, File>> downloadFilesNonBlocking (IFileDownloader downloader, 
                List<LaunchControlProvider.DownloadFileDescriptor> toBeDownloaded)

Download the set of file paths and enforce them if they are mandatory.

Parameters
downloader IFileDownloader

toBeDownloaded List

Returns
List<Entry<LaunchControlProvider.DownloadFileDescriptor, File>>

Throws
BuildRetrievalError

getBuildArtifactHelper

protected AndroidBuildArtifactHelper getBuildArtifactHelper ()

Returns
AndroidBuildArtifactHelper

Throws
BuildRetrievalError

getExtraDownloadMap

protected MultiMap<String, File> getExtraDownloadMap ()

Returns the map of extra downloaded targets.

Returns
MultiMap<String, File>

getGlobalDownloadExclusionPatterns

protected Set<String> getGlobalDownloadExclusionPatterns ()

Returns
Set<String>

getWorkFolder

protected final File getWorkFolder ()

Returns the current invocation workfolder.

Returns
File

handleDirectoryDownload

protected final File handleDirectoryDownload (File downloadedFile)

Parameters
downloadedFile File

Returns
File

performBuildApiQuery

protected RemoteBuildInfo performBuildApiQuery ()

Returns
RemoteBuildInfo

Throws
BuildRetrievalError

performValidityCheckForBuildApi

protected void performValidityCheckForBuildApi ()

queryForBuild

protected RemoteBuildInfo queryForBuild (MultiMap<String, String> params)

Perform the launch control query, retrying multiple times in case of error.

Parameters
params MultiMap: parameters for launch control

Returns
RemoteBuildInfo the RemoteBuildInfo retrieved from launch control

Throws
BuildRetrievalError

queryForBuild

protected RemoteBuildInfo queryForBuild ()

Perform the launch control query, retrying multiple times in case of error.

Returns
RemoteBuildInfo the RemoteBuildInfo retrieved from launch control

Throws
BuildRetrievalError

queryForBuildWithBuildApi

protected RemoteBuildInfo queryForBuildWithBuildApi ()

Performs the build query against build API.

Note: the input params are implied by various class scoped variables

Returns
RemoteBuildInfo The RemoteBuildInfo parsed from the response.

Throws
com.android.tradefed.build.BuildRetrievalError
BuildRetrievalError

replaceParamWithSigned

protected void replaceParamWithSigned (RemoteBuildInfo buildInfo, 
                RemoteBuildInfo.BuildAttributeKey key)

Parameters
buildInfo RemoteBuildInfo

key RemoteBuildInfo.BuildAttributeKey

Throws
BuildRetrievalError

useCasDefaultRollout

protected boolean useCasDefaultRollout ()

Returns
boolean