1 /*
2  * Copyright (C) 2015 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.compatibility.common.tradefed.testtype;
17 
18 import com.android.tradefed.build.IBuildInfo;
19 import com.android.tradefed.testtype.IAbi;
20 
21 import java.io.File;
22 import java.util.List;
23 import java.util.Map;
24 import java.util.Set;
25 
26 /**
27  * Interface for accessing tests from the Compatibility repository.
28  */
29 public interface IModuleRepo {
30 
31     /**
32      * @return true if this repository has been initialized.
33      */
isInitialized()34     boolean isInitialized();
35 
36     /**
37      * Initializes the repository.
38      */
initialize(int shards, File testsDir, Set<IAbi> abis, List<String> deviceTokens, List<String> testArgs, List<String> moduleArgs, List<String> mIncludeFilters, List<String> mExcludeFilters, IBuildInfo buildInfo)39     void initialize(int shards, File testsDir, Set<IAbi> abis, List<String> deviceTokens,
40             List<String> testArgs, List<String> moduleArgs, List<String> mIncludeFilters,
41             List<String> mExcludeFilters, IBuildInfo buildInfo);
42 
43     /**
44      * @return a {@link Map} of all modules to run on the device referenced by the given serial.
45      */
getModules(String serial)46     List<IModuleDef> getModules(String serial);
47 
48     /**
49      * @return the number of shards this repo is initialized for.
50      */
getNumberOfShards()51     int getNumberOfShards();
52 
53     /**
54      * @return the maximum number of modules a shard will run.
55      */
getModulesPerShard()56     int getModulesPerShard();
57 
58     /**
59      * @return the {@link Map} of device serials to tokens.
60      */
getDeviceTokens()61     Map<String, Set<String>> getDeviceTokens();
62 
63     /**
64      * @return the {@link Set} of device serials that have taken their workload.
65      */
getSerials()66     Set<String> getSerials();
67 
68     /**
69      * @return the small modules that don't have tokens but have not been assigned to a device.
70      */
getSmallModules()71     List<IModuleDef> getSmallModules();
72 
73     /**
74      * @return the medium modules that don't have tokens but have not been assigned to a device.
75      */
getMediumModules()76     List<IModuleDef> getMediumModules();
77 
78     /**
79      * @return the large modules that don't have tokens but have not been assigned to a device.
80      */
getLargeModules()81     List<IModuleDef> getLargeModules();
82 
83     /**
84      * @return the modules which have token and have not been assigned to a device.
85      */
getTokenModules()86     List<IModuleDef> getTokenModules();
87 
88     /**
89      * @return An array of all module ids in the repo.
90      */
getModuleIds()91     String[] getModuleIds();
92 }
93