-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
887 Update sharding limit #915
Conversation
@@ -39,3 +40,10 @@ fun Map<String, String>.asDevice(android: Boolean) = | |||
orientation = getOrDefault("orientation", version) | |||
) | |||
} | |||
|
|||
fun Device.isVirtual(projectId: String) = if (this.isVirtual == null) AndroidCatalog.isVirtualDevice(model, projectId).takeIf { it }?.apply { | |||
isVirtual = this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this
is Boolean
in current scope so i guess also
fits better then apply
.
} ?: false | ||
else this.isVirtual ?: false | ||
|
||
fun List<Device>.check(projectId: String) = forEach { it.isVirtual(projectId) }.let { this } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fun List<Device>.check(projectId: String) = forEach { it.isVirtual(projectId) }.let { this } | |
fun List<Device>.check(projectId: String) = apply { forEach { it.isVirtual(projectId) } } |
fun Device.isVirtual(projectId: String) = if (this.isVirtual == null) AndroidCatalog.isVirtualDevice(model, projectId).takeIf { it }?.apply { | ||
isVirtual = this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fun Device.isVirtual(projectId: String) = if (this.isVirtual == null) AndroidCatalog.isVirtualDevice(model, projectId).takeIf { it }?.apply { | |
isVirtual = this | |
fun Device.isVirtual(projectId: String) = if (this.isVirtual == null) AndroidCatalog.isVirtualDevice(model, projectId).takeIf { it }?.also { | |
isVirtual = it |
} | ||
return@withTimeoutOrNull this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason for returning CoroutineScope?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is redundant I should remove it. Thanks!
val testMatrices = mutableListOf<Deferred<TestMatrix>>() | ||
val allTestShardChunks = mutableListOf<List<String>>() | ||
val ignoredTestsShardChunks = mutableListOf<List<String>>() | ||
|
||
val history = GcToolResults.createToolResultsHistory(args) | ||
val otherGcsFiles = args.uploadOtherFiles(runGcsPath) | ||
val additionalApks = args.uploadAdditionalApks(runGcsPath) | ||
val argsList = if (args.shouldSplitRuns()) args.splitConfigurationByDeviceType() else listOf(args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
argsList
is a little bit generic in this context maybe deviceConfigurations
or deviceArgs
will fits better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deviceArgs
fits great, thanks!
a191b78
to
4cbfff1
Compare
} | ||
|
||
@Test(expected = FlankFatalError::class) | ||
fun `should throw when physical devices and maximum test shards limit exceed`() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fun `should throw when physical devices and maximum test shards limit exceed`() { | |
fun `should throw when maximum test shards for physical devices limit exceeded`() { |
} | ||
|
||
@Test(expected = FlankFatalError::class) | ||
fun `should throw when virtual devices and maximum test shards limit exceed`() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fun `should throw when virtual devices and maximum test shards limit exceed`() { | |
fun `should throw when maximum test shards for virtual devices limit exceeded`() { |
isVirtual = it | ||
} else isVirtual ?: false | ||
|
||
fun List<Device>.check(projectId: String) = apply { forEach { it.isVirtual(projectId) } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fun List<Device>.check(projectId: String) = apply { forEach { it.isVirtual(projectId) } } | |
fun List<Device>.resolve(projectId: String) = apply { forEach { it.isVirtual(projectId) } } |
@@ -23,6 +25,7 @@ data class AndroidArgs( | |||
) : IArgs by commonArgs { | |||
companion object : AndroidArgsCompanion() | |||
|
|||
// override val maxTestShards: Int = calculateMaxTestShards(commonArgs.maxTestShards) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete if unused
xctestrunZip = gcloud.test!!.processFilePath("from test"), | ||
xctestrunFile = gcloud.xctestrunFile!!.processFilePath("from xctestrun-file"), | ||
xcodeVersion = gcloud.xcodeVersion, | ||
testTargets = flank.testTargets!!.filterNotNull() | ||
) | ||
|
||
private fun convertToShardCount(inputValue: Int): Int = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about single line without : Int
?
if (!inVirtualRange) throwMaxTestShardsLimitExceeded() | ||
} | ||
|
||
private fun AndroidArgs.throwMaxTestShardsLimitExceeded() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return type could be Nothing
for self documentation
@@ -83,3 +86,17 @@ val AndroidArgs.isInstrumentationTest | |||
val AndroidArgs.isRoboTest | |||
get() = appApk != null && | |||
(roboDirectives.isNotEmpty() || roboScript != null) | |||
|
|||
fun AndroidArgs.containsVirtualDevices() = devices.any { it.isVirtual!! } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it.isVirtual ?: false
is safer call. WDYT?
|
||
fun AndroidArgs.containsPhysicalDevices() = devices.any { !it.isVirtual!! } | ||
|
||
fun AndroidArgs.shouldSplitRuns() = containsPhysicalDevices() && maxTestShards > 50 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should not we use AVAILABLE_PHYSICAL_SHARD_COUNT_RANGE.last
?
flank: | ||
disable-sharding: false | ||
max-test-shards: 40 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 empty line could be skipped ;) please check other config files
@@ -1,6 +1,8 @@ | |||
package ftl.args | |||
|
|||
import ftl.args.yml.AppTestPair | |||
import ftl.config.resolve | |||
import ftl.config.isVirtual |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that these imports are unused
@@ -12,9 +12,9 @@ data class Device( | |||
val model: String, | |||
val version: String, | |||
val locale: String = defaultLocale, | |||
val orientation: String = defaultOrientation | |||
val orientation: String = defaultOrientation, | |||
val isVirtual: Boolean? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isVirtual
shouldn't be nullable. We don't need nulls in later calculations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright! Changed! 👍
…een virtual and physical devices
…fix tests, detekt
… virtual devices configured
48bc561
to
09c1664
Compare
Fixes #887
Test Plan
For virtual devices, the limit should be set to 250.
For physical devices, the limit should be still 50.
In case when we have a virtual and physical device and shards limit set over the physical device limit, firebase returns an exception
Solution
If the limit exceeds the physical limit and we have physical and virtual devices we split matrices by device type. This solution allows us to use the maximum limit on every device type.
Checklist