Skip to content

Instantly share code, notes, and snippets.

View Malinskiy's full-sized avatar

Anton Malinski Malinskiy

View GitHub Profile
abstract class Actor<in T>(parent: Job? = null,
val context: CoroutineContext) : SendChannel<T>, CoroutineScope {
override suspend fun send(element: T) = delegate.send(element)
protected abstract suspend fun receive(msg: T)
...
}
class NoRetryStrategy : RetryStrategy {
override fun process(devicePoolId: DevicePoolId, tests: Collection<TestResult>, testShard: TestShard): List<TestResult> {
return emptyList()
}
}
class IsolateBatchingStrategy : BatchingStrategy {
override fun process(queue: Queue<Test>, analytics: Analytics): TestBatch = TestBatch(listOf(queue.poll()))
}
class ExecutionTimeSortingStrategy(val percentile: Double,
val timeLimit: Instant) : SortingStrategy {
override fun process(metricsProvider: MetricsProvider): Comparator<Test> =
Comparator.comparingDouble<Test> {
val expectedDuration = metricsProvider.executionTime(it, percentile, timeLimit)
expectedDuration
}.reversed()
}
interface SortingStrategy {
fun process(metricsProvider: MetricsProvider): Comparator<Test>
}
interface SortingStrategy {
fun process(metricsProvider: MetricsProvider): Comparator<Test>
}
class ProbabilityBasedFlakinessStrategy(val minSuccessRate: Double,
val maxCount: Int,
val timeLimit: Instant) : FlakinessStrategy {
override fun process(testShard: TestShard,
metricsProvider: MetricsProvider): TestShard {
val tests = testShard.tests
val output = mutableListOf<Test>()
tests.forEach {
val successRate = metricsProvider.successRate(it, timeLimit)
interface ShardingStrategy {
fun createShard(tests: Collection<Test>): TestShard
}
class OperatingSystemVersionPoolingStrategy : PoolingStrategy {
override fun associate(device: Device) = DevicePoolId(device.operatingSystem.version)
}
class CountShardingStrategy(val count: Int) : ShardingStrategy {
override fun createShard(tests: Collection<Test>): TestShard {
return TestShard(tests.flatMap { test ->
(0 until count).map { test }
})
}
...
}