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 package com.android.tradefed.testtype; 17 18 import com.android.tradefed.device.ITestDevice; 19 20 import java.util.Collection; 21 22 /** 23 * A {@link IRemoteTest} that can be split into separately executable sub-tests. The splitting into 24 * sub-tests is expected to be deterministic and each sub-test should be independent in order to 25 * allow for execution of different shards on different hosts. 26 */ 27 public interface IShardableTest extends IRemoteTest { 28 29 /** 30 * Shard the test into separately runnable chunks. 31 * 32 * <p>This must be deterministic and always return the same list of {@link IRemoteTest}s for the 33 * same input. 34 * 35 * <p>This will be called before test execution, so injected dependencies (such as the {@link 36 * ITestDevice} for {@link IDeviceTest}s) may be null. 37 * 38 * @return a collection of subtests to be executed separately or <code>null</code> if test is 39 * not currently shardable 40 */ split()41 public default Collection<IRemoteTest> split() { 42 return null; 43 } 44 45 /** 46 * Alternative version of {@link #split()} which also provides the shardCount that is attempted 47 * to be run. This is useful for some test runner that cannot arbitrarly decide sometimes. 48 * 49 * @param shardCountHint the attempted shard count. 50 * @return a collection of subtests to be executed separately or <code>null</code> if test is 51 * not currently shardable 52 */ split(int shardCountHint)53 public default Collection<IRemoteTest> split(int shardCountHint) { 54 return split(); 55 } 56 } 57