1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.tradefed.command; 18 19 import com.android.tradefed.device.metric.AutoLogCollector; 20 import com.android.tradefed.util.UniqueMultiMap; 21 22 import java.io.File; 23 import java.time.Duration; 24 import java.util.List; 25 import java.util.Map; 26 import java.util.Set; 27 28 /** 29 * Container for execution options for commands. 30 */ 31 public interface ICommandOptions { 32 33 /** 34 * Returns <code>true</code> if abbreviated help mode has been requested 35 */ isHelpMode()36 public boolean isHelpMode(); 37 38 /** 39 * Returns <code>true</code> if full detailed help mode has been requested 40 */ isFullHelpMode()41 public boolean isFullHelpMode(); 42 43 /** 44 * Return <code>true</code> if we should <emph>skip</emph> adding this command to the queue. 45 */ isDryRunMode()46 public boolean isDryRunMode(); 47 48 /** 49 * Return <code>true</code> if we should print the command out to the console before we 50 * <emph>skip</emph> adding it to the queue. 51 */ isNoisyDryRunMode()52 public boolean isNoisyDryRunMode(); 53 54 /** 55 * Return the loop mode for the config. 56 */ isLoopMode()57 public boolean isLoopMode(); 58 59 /** 60 * Get the time to wait before re-scheduling this command. 61 * @return time in ms 62 */ getLoopTime()63 public long getLoopTime(); 64 65 /** 66 * Sets the loop mode for the command 67 * 68 * @param loopMode 69 */ setLoopMode(boolean loopMode)70 public void setLoopMode(boolean loopMode); 71 72 /** 73 * Return the test-tag for the invocation. Default is 'stub' if unspecified. 74 */ getTestTag()75 public String getTestTag(); 76 77 /** 78 * Sets the test-tag for the invocation. 79 * 80 * @param testTag 81 */ setTestTag(String testTag)82 public void setTestTag(String testTag); 83 84 /** 85 * Return the test-tag suffix, appended to test-tag to represents some variants of one test. 86 */ getTestTagSuffix()87 public String getTestTagSuffix(); 88 89 /** 90 * Creates a copy of the {@link ICommandOptions} object. 91 */ clone()92 public ICommandOptions clone(); 93 94 /** 95 * Return true if command should run on all devices. 96 */ runOnAllDevices()97 public boolean runOnAllDevices(); 98 99 /** 100 * Return true if a bugreport should be taken when the test invocation has ended. 101 */ takeBugreportOnInvocationEnded()102 public boolean takeBugreportOnInvocationEnded(); 103 104 /** Sets whether or not to capture a bugreport at the end of the invocation. */ setBugreportOnInvocationEnded(boolean takeBugreport)105 public void setBugreportOnInvocationEnded(boolean takeBugreport); 106 107 /** 108 * Return true if a bugreportz should be taken instead of bugreport during the test invocation 109 * final bugreport. 110 */ takeBugreportzOnInvocationEnded()111 public boolean takeBugreportzOnInvocationEnded(); 112 113 /** Sets whether or not to capture a bugreportz at the end of the invocation. */ setBugreportzOnInvocationEnded(boolean takeBugreportz)114 public void setBugreportzOnInvocationEnded(boolean takeBugreportz); 115 116 /** Returns whether or not conditional bugreport is disabled */ isConditionalBugreportDisabled()117 public boolean isConditionalBugreportDisabled(); 118 119 /** 120 * Return the invocation timeout specified. 0 if no timeout to be used. 121 */ getInvocationTimeout()122 public long getInvocationTimeout(); 123 124 /** 125 * Set the invocation timeout. 0 if no timeout to be used. 126 */ setInvocationTimeout(Long mInvocationTimeout)127 public void setInvocationTimeout(Long mInvocationTimeout); 128 129 130 /** Returns true if we should optimize the list of test modules for mainline test. */ getOptimizeMainlineTest()131 public boolean getOptimizeMainlineTest(); 132 133 /** 134 * Return the total shard count for the command. 135 */ getShardCount()136 public Integer getShardCount(); 137 138 /** 139 * Sets the shard count for the command. 140 */ setShardCount(Integer shardCount)141 public void setShardCount(Integer shardCount); 142 143 /** 144 * Return the shard index for the command. 145 */ getShardIndex()146 public Integer getShardIndex(); 147 148 /** 149 * Sets the shard index for the command. 150 */ setShardIndex(Integer shardIndex)151 public void setShardIndex(Integer shardIndex); 152 153 /** Whether or not sharding should use the token support. */ shouldUseTokenSharding()154 public boolean shouldUseTokenSharding(); 155 156 /** Returns if we should use dynamic sharding or not */ shouldUseDynamicSharding()157 public boolean shouldUseDynamicSharding(); 158 159 /** Returns the data passed to the invocation to describe it */ getInvocationData()160 public UniqueMultiMap<String, String> getInvocationData(); 161 162 /** Returns the list of remote files configured. */ getRemoteFiles()163 public Set<String> getRemoteFiles(); 164 165 /** Returns true if we should use Tf containers to run the invocation */ shouldUseSandboxing()166 public boolean shouldUseSandboxing(); 167 168 /** Sets whether or not we should use TF containers */ setShouldUseSandboxing(boolean use)169 public void setShouldUseSandboxing(boolean use); 170 171 /** Returns true if we should use the Tf sandbox in a test mode. */ shouldUseSandboxTestMode()172 public boolean shouldUseSandboxTestMode(); 173 174 /** Sets whether or not we should use the TF sandbox test mode. */ setUseSandboxTestMode(boolean use)175 public void setUseSandboxTestMode(boolean use); 176 177 /** Whether or not to use sandbox mode in remote invocation. */ shouldUseRemoteSandboxMode()178 public boolean shouldUseRemoteSandboxMode(); 179 180 /** Whether or not to trigger a deviceless remote invocation. */ isRemoteInvocationDeviceless()181 public boolean isRemoteInvocationDeviceless(); 182 183 /** Returns the set of auto log collectors to be added for an invocation */ getAutoLogCollectors()184 public Set<AutoLogCollector> getAutoLogCollectors(); 185 186 /** Sets the set of auto log collectors that should be added to an invocation. */ setAutoLogCollectors(Set<AutoLogCollector> autoLogCollectors)187 public void setAutoLogCollectors(Set<AutoLogCollector> autoLogCollectors); 188 189 /** Whether or not to enable experiments through experimental flags. */ isExperimentEnabled()190 public boolean isExperimentEnabled(); 191 192 /** Returns the experimental flags map, that can be used to feature gate projects. */ getExperimentalFlags()193 public Map<String, String> getExperimentalFlags(); 194 195 /** Whether or not to capture a screenshot on test case failure */ captureScreenshotOnFailure()196 public boolean captureScreenshotOnFailure(); 197 198 /** Whether or not to capture a logcat on test case failure */ captureLogcatOnFailure()199 public boolean captureLogcatOnFailure(); 200 201 /** Returns the suffix to append to the Tradefed host_log or null if no prefix. */ getHostLogSuffix()202 public String getHostLogSuffix(); 203 204 /** Sets the suffix to append to Tradefed host_log. */ setHostLogSuffix(String suffix)205 public void setHostLogSuffix(String suffix); 206 207 /** Whether or not to attempt parallel setup of the remote devices. */ shouldUseParallelRemoteSetup()208 public boolean shouldUseParallelRemoteSetup(); 209 210 /** Return whether to execute pre-invocation setup in parallel. */ shouldUseParallelPreInvocationSetup()211 public boolean shouldUseParallelPreInvocationSetup(); 212 213 /** Return the timeout for parallel pre-invocation setup. */ getParallelPreInvocationSetupTimeout()214 public Duration getParallelPreInvocationSetupTimeout(); 215 216 /** Whether or not to attempt parallel setup. */ shouldUseParallelSetup()217 public boolean shouldUseParallelSetup(); 218 219 /** Returns the timeout to use during parallel setups. */ getParallelSetupTimeout()220 public Duration getParallelSetupTimeout(); 221 222 /** Whether or not to use replicated setup for all the remote devices. */ shouldUseReplicateSetup()223 public boolean shouldUseReplicateSetup(); 224 225 /** Set whether or not to use replicated setup. */ setReplicateSetup(boolean replicate)226 public void setReplicateSetup(boolean replicate); 227 228 /** Whether or not to report progression of remote invocation at module level. */ shouldReportModuleProgression()229 public boolean shouldReportModuleProgression(); 230 231 /** Whether or not to start extra instances in the remote VM in postsubmit. */ getExtraRemotePostsubmitInstance()232 public int getExtraRemotePostsubmitInstance(); 233 234 /** Whether or not to release the device early when done with it. */ earlyDeviceRelease()235 public boolean earlyDeviceRelease(); 236 237 /** Whether or not to release the device early in delegated mode. */ delegatedEarlyDeviceRelease()238 public boolean delegatedEarlyDeviceRelease(); 239 240 /** Set whether or not to release the device early in delegated mode. */ setDelegatedEarlyDeviceRelease(boolean earlyRelease)241 public void setDelegatedEarlyDeviceRelease(boolean earlyRelease); 242 243 /** Returns the map of args to pass to the dynamic download query. */ getDynamicDownloadArgs()244 public Map<String, String> getDynamicDownloadArgs(); 245 246 /** Whether or not to report the number of test cases per test types. */ reportTestCaseCount()247 public boolean reportTestCaseCount(); 248 249 /** Set whether or not to report test cases count per test types. */ setReportTestCaseCount(boolean report)250 public void setReportTestCaseCount(boolean report); 251 252 /** Whether or not to report passed test cases. */ reportPassedTests()253 public boolean reportPassedTests(); 254 255 /** Whether or not to filters previous passed test cases from previous attempt. */ filterPreviousPassedTests()256 public boolean filterPreviousPassedTests(); 257 258 /** whether or not to report the logs until invocationComplete. */ reportInvocationComplete()259 public boolean reportInvocationComplete(); 260 261 /** Set whether or not to report the logs until invocationComplete */ setReportInvocationComplete(boolean reportInvocationCompleteLogs)262 public void setReportInvocationComplete(boolean reportInvocationCompleteLogs); 263 264 /** 265 * Returns the maximum number of times to scheduled the command. Has no effect if isLoopMode is 266 * false. 267 */ getMaxLoopCount()268 public long getMaxLoopCount(); 269 270 /** List of tags used for reporting related to the invocation. */ reportingTags()271 public List<String> reportingTags(); 272 273 /** Whether or not to disable pre-invocaiton setup and post-invocation teardown. */ shouldDisableInvocationSetupAndTeardown()274 public boolean shouldDisableInvocationSetupAndTeardown(); 275 276 /** Return the number of devices for multi-device tests. */ getMultiDeviceCount()277 public Integer getMultiDeviceCount(); 278 279 /** Sets the number of expected devices for multi-device tests. */ setMultiDeviceCount(int count)280 public void setMultiDeviceCount(int count); 281 282 /** Returns whether or not invocation tracing is enabled. */ isTracingEnabled()283 public boolean isTracingEnabled(); 284 285 /** Returns the jdk folder to use when forking execution in a subprocess. */ getJdkFolderForSubprocess()286 public File getJdkFolderForSubprocess(); 287 288 /** Returns whether to use remote dynamic sharding server or not */ shouldRemoteDynamicShard()289 public boolean shouldRemoteDynamicShard(); 290 291 /** Sets whether to use remote dynamic sharding server or not */ setShouldRemoteDynamicShard(boolean shouldRemoteDynamicShard)292 public void setShouldRemoteDynamicShard(boolean shouldRemoteDynamicShard); 293 294 /** Returns whether to attempt to distribute number of modules evenly across shards */ shouldUseEvenModuleSharding()295 public boolean shouldUseEvenModuleSharding(); 296 297 /** Set whether to attempt to distribute number of modules evenly across shards */ setShouldUseEvenModuleSharding(boolean useEvenModuleSharding)298 public void setShouldUseEvenModuleSharding(boolean useEvenModuleSharding); 299 } 300