Skip to content

Commit 0a55dc5

Browse files
committed
Add sharding option
1 parent 240cbcc commit 0a55dc5

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ If you get the **Build already exists** error, it is because you have more than
4848

4949
## 🧩 Get started
5050

51-
Add this step directly to your workflow in the [Bitrise Workflow Editor](https://devcenter.bitrise.io/steps-and-workflows/steps-and-workflows-index/).
51+
Add this step directly to your workflow in the [Bitrise Workflow Editor](https://docs.bitrise.io/en/bitrise-ci/workflows-and-pipelines/steps/adding-steps-to-a-workflow.html).
5252

5353
You can also run this step directly with [Bitrise CLI](https://github.com/bitrise-io/bitrise).
5454

@@ -67,6 +67,7 @@ You can also run this step directly with [Bitrise CLI](https://github.com/bitris
6767
| `inst_test_runner_class` | The fully-qualified Java class name of the instrumentation test runner (leave empty to use the last name extracted from the APK manifest). | | |
6868
| `inst_test_targets` | A list of one or more instrumentation test targets to be run (default: all targets). Each target must be fully qualified with the package name or class name, in one of these formats: - `package package_name` - `class package_name.class_name` - `class package_name.class_name#method_name` For example: `class com.my.company.app.MyTargetClass,class com.my.company.app.MyOtherTargetClass` | | |
6969
| `inst_use_orchestrator` | The option of whether running each test within its own invocation of instrumentation with Android Test Orchestrator or not. | required | `false` |
70+
| `inst_uniform_shards` | The number of shards across which to distribute test cases. The shards are run in parallel on separate devices. A value between 1 and 50. For example, if your test execution contains 20 test cases and you specify four shards, the instrumentation command passes arguments of `-e numShards 4` to `AndroidJUnitRunner` and each shard executes about five test cases. Based on the sharding mechanism `AndroidJUnitRunner` uses, there is no guarantee that test cases will be distributed with perfect uniformity. If zero is specified then no uniform sharding is applied and all test cases run on a single device. | | |
7071
| `robo_initial_activity` | The initial activity used to start the app during a robo test. (leave empty to get it extracted from the APK manifest) | | |
7172
| `robo_max_depth` | The maximum depth of the traversal stack a robo test can explore. Needs to be at least 2 to make Robo explore the app beyond the first activity(leave empty to use the default value: `50`) | | |
7273
| `robo_max_steps` | The maximum number of steps/actions a robo test can execute(leave empty to use the default value: `no limit`). | | |
@@ -102,9 +103,8 @@ You can also run this step directly with [Bitrise CLI](https://github.com/bitris
102103

103104
We welcome [pull requests](https://github.com/bitrise-steplib/steps-virtual-device-testing-for-android/pulls) and [issues](https://github.com/bitrise-steplib/steps-virtual-device-testing-for-android/issues) against this repository.
104105

105-
For pull requests, work on your changes in a forked repository and use the Bitrise CLI to [run step tests locally](https://devcenter.bitrise.io/bitrise-cli/run-your-first-build/).
106+
For pull requests, work on your changes in a forked repository and use the Bitrise CLI to [run step tests locally](https://docs.bitrise.io/en/bitrise-ci/bitrise-cli/running-your-first-local-build-with-the-cli.html).
106107

107108
Learn more about developing steps:
108109

109-
- [Create your own step](https://devcenter.bitrise.io/contributors/create-your-own-step/)
110-
- [Testing your Step](https://devcenter.bitrise.io/contributors/testing-and-versioning-your-steps/)
110+
- [Create your own step](https://docs.bitrise.io/en/bitrise-ci/workflows-and-pipelines/developing-your-own-bitrise-step/developing-a-new-step.html)

config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ type ConfigsModel struct {
5858
InstTestRunnerClass string `env:"inst_test_runner_class"`
5959
InstTestTargets string `env:"inst_test_targets"`
6060
UseOrchestrator bool `env:"inst_use_orchestrator,opt[true,false]"`
61+
NumberOfUniformShards int `env:"inst_num_uniform_shards,range[0..50]"`
6162
QuarantinedTests string `env:"quarantined_tests"`
6263
QuarantinedTestTargets []string
6364

@@ -117,6 +118,7 @@ func (configs *ConfigsModel) print() {
117118
log.Printf("- InstTestRunnerClass: %s", configs.InstTestRunnerClass)
118119
log.Printf("- InstTestTargets: %s", configs.InstTestTargets)
119120
log.Printf("- UseOrchestrator: %t", configs.UseOrchestrator)
121+
log.Printf("- NumberOfUniformShards: %d", configs.NumberOfUniformShards)
120122
log.Printf("- QuarantinedTests: %s", configs.QuarantinedTests)
121123
}
122124

step.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,16 @@ inputs:
191191
value_options:
192192
- "false"
193193
- "true"
194+
- inst_uniform_shards:
195+
opts:
196+
title: Number of shards
197+
summary: |
198+
The number of shards across which to distribute test cases. The shards are run in parallel on separate devices.
199+
description: |
200+
The number of shards across which to distribute test cases. The shards are run in parallel on separate devices.
201+
202+
A value between 1 and 50. For example, if your test execution contains 20 test cases and you specify four shards, the instrumentation command passes arguments of `-e numShards 4` to `AndroidJUnitRunner` and each shard executes about five test cases. Based on the sharding mechanism `AndroidJUnitRunner` uses, there is no guarantee that test cases will be distributed with perfect uniformity.
203+
If zero is specified then no uniform sharding is applied and all test cases run on a single device.
194204
- robo_initial_activity:
195205
opts:
196206
category: Robo Test

test_api.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,13 @@ func startTestRun(configs ConfigsModel, testAssets TestAssetsAndroid) error {
209209
} else {
210210
testModel.TestSpecification.AndroidInstrumentationTest.OrchestratorOption = "DO_NOT_USE_ORCHESTRATOR"
211211
}
212+
if int64(configs.NumberOfUniformShards) > 0 {
213+
testModel.TestSpecification.AndroidInstrumentationTest.ShardingOption = &testing.ShardingOption{
214+
UniformSharding: &testing.UniformSharding{
215+
NumShards: int64(configs.NumberOfUniformShards),
216+
},
217+
}
218+
}
212219
if len(configs.QuarantinedTestTargets) > 0 {
213220
testModel.TestSpecification.AndroidInstrumentationTest.TestTargets = configs.QuarantinedTestTargets
214221
}

0 commit comments

Comments
 (0)