• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 to skip experiments for TRYBOT runs. */
skipTrybotExperiment()196     public boolean skipTrybotExperiment();
197 
198     /** Whether or not to capture a screenshot on test case failure */
captureScreenshotOnFailure()199     public boolean captureScreenshotOnFailure();
200 
201     /** Whether or not to capture a logcat on test case failure */
captureLogcatOnFailure()202     public boolean captureLogcatOnFailure();
203 
204     /** Returns the suffix to append to the Tradefed host_log or null if no prefix. */
getHostLogSuffix()205     public String getHostLogSuffix();
206 
207     /** Sets the suffix to append to Tradefed host_log. */
setHostLogSuffix(String suffix)208     public void setHostLogSuffix(String suffix);
209 
210     /** Whether or not to attempt parallel setup of the remote devices. */
shouldUseParallelRemoteSetup()211     public boolean shouldUseParallelRemoteSetup();
212 
213     /** Return whether to execute pre-invocation setup in parallel. */
shouldUseParallelPreInvocationSetup()214     public boolean shouldUseParallelPreInvocationSetup();
215 
216     /** Return the timeout for parallel pre-invocation setup. */
getParallelPreInvocationSetupTimeout()217     public Duration getParallelPreInvocationSetupTimeout();
218 
219     /** Whether or not to attempt parallel setup. */
shouldUseParallelSetup()220     public boolean shouldUseParallelSetup();
221 
222     /** Returns the timeout to use during parallel setups. */
getParallelSetupTimeout()223     public Duration getParallelSetupTimeout();
224 
225     /** Whether or not to use replicated setup for all the remote devices. */
shouldUseReplicateSetup()226     public boolean shouldUseReplicateSetup();
227 
228     /** Set whether or not to use replicated setup. */
setReplicateSetup(boolean replicate)229     public void setReplicateSetup(boolean replicate);
230 
231     /** Whether or not to report progression of remote invocation at module level. */
shouldReportModuleProgression()232     public boolean shouldReportModuleProgression();
233 
234     /** Whether or not to start extra instances in the remote VM in postsubmit. */
getExtraRemotePostsubmitInstance()235     public int getExtraRemotePostsubmitInstance();
236 
237     /** Whether or not to release the device early when done with it. */
earlyDeviceRelease()238     public boolean earlyDeviceRelease();
239 
240     /** Whether or not to release the device early in delegated mode. */
delegatedEarlyDeviceRelease()241     public boolean delegatedEarlyDeviceRelease();
242 
243     /** Set whether or not to release the device early in delegated mode. */
setDelegatedEarlyDeviceRelease(boolean earlyRelease)244     public void setDelegatedEarlyDeviceRelease(boolean earlyRelease);
245 
246     /** Returns the map of args to pass to the dynamic download query. */
getDynamicDownloadArgs()247     public Map<String, String> getDynamicDownloadArgs();
248 
249     /** Whether or not to report the number of test cases per test types. */
reportTestCaseCount()250     public boolean reportTestCaseCount();
251 
252     /** Set whether or not to report test cases count per test types. */
setReportTestCaseCount(boolean report)253     public void setReportTestCaseCount(boolean report);
254 
255     /** Whether or not to report passed test cases. */
reportPassedTests()256     public boolean reportPassedTests();
257 
258     /** Whether or not to filters previous passed test cases from previous attempt. */
filterPreviousPassedTests()259     public boolean filterPreviousPassedTests();
260 
261     /** whether or not to report the logs until invocationComplete. */
reportInvocationComplete()262     public boolean reportInvocationComplete();
263 
264     /** Set whether or not to report the logs until invocationComplete */
setReportInvocationComplete(boolean reportInvocationCompleteLogs)265     public void setReportInvocationComplete(boolean reportInvocationCompleteLogs);
266 
267     /**
268      * Returns the maximum number of times to scheduled the command. Has no effect if isLoopMode is
269      * false.
270      */
getMaxLoopCount()271     public long getMaxLoopCount();
272 
273     /** List of tags used for reporting related to the invocation. */
reportingTags()274     public List<String> reportingTags();
275 
276     /** Whether or not to disable pre-invocaiton setup and post-invocation teardown. */
shouldDisableInvocationSetupAndTeardown()277     public boolean shouldDisableInvocationSetupAndTeardown();
278 
279     /** Return the number of devices for multi-device tests. */
getMultiDeviceCount()280     public Integer getMultiDeviceCount();
281 
282     /** Sets the number of expected devices for multi-device tests. */
setMultiDeviceCount(int count)283     public void setMultiDeviceCount(int count);
284 
285     /** Returns whether or not invocation tracing is enabled. */
isTracingEnabled()286     public boolean isTracingEnabled();
287 
288     /** Returns the jdk folder to use when forking execution in a subprocess. */
getJdkFolderForSubprocess()289     public File getJdkFolderForSubprocess();
290 
291     /** Returns whether to use remote dynamic sharding server or not */
shouldRemoteDynamicShard()292     public boolean shouldRemoteDynamicShard();
293 
294     /** Sets whether to use remote dynamic sharding server or not */
setShouldRemoteDynamicShard(boolean shouldRemoteDynamicShard)295     public void setShouldRemoteDynamicShard(boolean shouldRemoteDynamicShard);
296 
297     /** Returns whether to attempt to distribute number of modules evenly across shards */
shouldUseEvenModuleSharding()298     public boolean shouldUseEvenModuleSharding();
299 
300     /** Set whether to attempt to distribute number of modules evenly across shards */
setShouldUseEvenModuleSharding(boolean useEvenModuleSharding)301     public void setShouldUseEvenModuleSharding(boolean useEvenModuleSharding);
302 
303     /** Returns the name of the instance used to handle remote caching. */
getRemoteCacheInstanceName()304     public String getRemoteCacheInstanceName();
305 
306     /** Returns true if we should capture the results in the cache. */
shouldUploadCacheResults()307     public boolean shouldUploadCacheResults();
308 
309     /** Returns true if we should report cache results when available. */
reportCacheResults()310     public boolean reportCacheResults();
311 
312     /** Returns true if we should report cache results when available in presubmit. */
reportCacheResultsInPresubmit()313     public boolean reportCacheResultsInPresubmit();
314 
315     /** Returns true if we should capture the invocation results in the cache. */
shouldUploadInvocationCacheResults()316     public boolean shouldUploadInvocationCacheResults();
317 
318     /** Returns true if we should report invocation cache results when available in presubmit. */
reportInvocationCacheResultsInPresubmit()319     public boolean reportInvocationCacheResultsInPresubmit();
320 }
321