aboutsummaryrefslogtreecommitdiff
path: root/src/com/android/tradefed/invoker
diff options
context:
space:
mode:
authorjdesprez <jdesprez@google.com>2017-04-05 16:51:13 -0700
committerJulien Desprez <jdesprez@google.com>2017-04-05 23:53:26 +0000
commit8ba3346bfdf0b37f826a270aabb604922513774b (patch)
tree010bb29bfd1a0acca6cd486a2e96b62a663afdc2 /src/com/android/tradefed/invoker
parent3fca17a6054f2dae5d5861ce70133ddcf1a758e1 (diff)
downloadtradefederation-8ba3346bfdf0b37f826a270aabb604922513774b.tar.gz
Ensure that Status checker are not shared by shard
When using legacy sharding, ensure that system checker (that are stateful) are not shared between shards. Test: local unit tests Bug: 36776549 Change-Id: I59a3091734efd581b99ead5c42145383ce684f66
Diffstat (limited to 'src/com/android/tradefed/invoker')
-rw-r--r--src/com/android/tradefed/invoker/ShardHelper.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/com/android/tradefed/invoker/ShardHelper.java b/src/com/android/tradefed/invoker/ShardHelper.java
index dd70dbce7..760ceb697 100644
--- a/src/com/android/tradefed/invoker/ShardHelper.java
+++ b/src/com/android/tradefed/invoker/ShardHelper.java
@@ -18,12 +18,15 @@ package com.android.tradefed.invoker;
import com.android.tradefed.build.ExistingBuildProvider;
import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.config.ConfigurationException;
+import com.android.tradefed.config.ConfigurationFactory;
import com.android.tradefed.config.IConfiguration;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.result.IShardableListener;
import com.android.tradefed.result.ITestInvocationListener;
+import com.android.tradefed.suite.checker.ISystemStatusChecker;
import com.android.tradefed.testtype.IRemoteTest;
import com.android.tradefed.testtype.IShardableTest;
+import com.android.tradefed.util.QuotationAwareTokenizer;
import java.util.ArrayList;
import java.util.Collection;
@@ -71,6 +74,7 @@ public class ShardHelper {
CLog.i("Rescheduling sharded config...");
IConfiguration shardConfig = config.clone();
shardConfig.setTest(testShard);
+ cloneStatusChecker(config, shardConfig);
cloneBuildInfos(config, shardConfig, context);
@@ -92,6 +96,23 @@ public class ShardHelper {
}
/**
+ * Helper to clone {@link ISystemStatusChecker}s from the original config to the clonedConfig.
+ */
+ private static void cloneStatusChecker(IConfiguration oriConfig, IConfiguration clonedConfig) {
+ try {
+ IConfiguration deepCopy =
+ ConfigurationFactory.getInstance()
+ .createConfigurationFromArgs(
+ QuotationAwareTokenizer.tokenizeLine(
+ oriConfig.getCommandLine()));
+ clonedConfig.setSystemStatusCheckers(deepCopy.getSystemStatusCheckers());
+ } catch (ConfigurationException e) {
+ // should not happen
+ throw new RuntimeException("failed to deep copy a configuration", e);
+ }
+ }
+
+ /**
* Attempt to shard given {@link IRemoteTest}.
*
* @param shardableTests the list of {@link IRemoteTest}s to add to