Skip to content

Commit cda89fa

Browse files
committed
Revert "last fixes"
This reverts commit 8081566.
1 parent 8081566 commit cda89fa

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

maestro-cli/src/main/java/maestro/cli/command/TestCommand.kt

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,7 @@ class TestCommand : Callable<Int> {
194194
}
195195

196196
private fun handleSessions(debugOutputPath: Path, plan: ExecutionPlan): Int = runBlocking(Dispatchers.IO) {
197-
val requestedShards = shardSplit ?: shardAll ?: 1
198-
if (requestedShards > 1 && plan.sequence.flows.isNotEmpty()) {
199-
error("Cannot run sharded tests with sequential execution")
200-
}
201-
197+
val shards = shardSplit ?: shardAll ?: 1
202198
val onlySequenceFlows = plan.sequence.flows.isNotEmpty() && plan.flowsToRun.isEmpty() // An edge case
203199

204200
runCatching {
@@ -217,10 +213,15 @@ class TestCommand : Callable<Int> {
217213
}.toMutableSet())
218214

219215
val availableDevices = if (deviceIds.isNotEmpty()) deviceIds.size else initialActiveDevices.size
220-
val effectiveShards = if (onlySequenceFlows) 1 else requestedShards.coerceAtMost(plan.flowsToRun.size)
216+
val effectiveShards = if (onlySequenceFlows) 1 else shards.coerceAtMost(plan.flowsToRun.size)
217+
val sharded = effectiveShards > 1
221218

222-
if (requestedShards > plan.flowsToRun.size) {
223-
PrintUtils.warn("Requested $requestedShards shards, but it cannot be higher than the number of flows (${plan.flowsToRun.size}). Will use $effectiveShards shards instead.")
219+
if (shards > plan.flowsToRun.size) {
220+
PrintUtils.warn("Requested $shards shards, but it cannot be higher than the number of flows (${plan.flowsToRun.size}). Will use $effectiveShards shards instead.")
221+
}
222+
223+
if (sharded && plan.sequence.flows.isNotEmpty()) {
224+
error("Cannot run sharded tests with sequential execution")
224225
}
225226

226227
val chunkPlans: List<ExecutionPlan> = if (onlySequenceFlows) {
@@ -254,7 +255,7 @@ class TestCommand : Callable<Int> {
254255
"Will split $flowCount flows across $effectiveShards shards (${prefix}$flowsPerShard flows per shard)"
255256
}
256257

257-
else -> "Will run $flowCount flows in a single shard"
258+
else -> "Will run $flowCount in a single shard"
258259
}
259260

260261
appendLine(message)
@@ -277,13 +278,9 @@ class TestCommand : Callable<Int> {
277278

278279
val results = (0 until effectiveShards).map { shardIndex ->
279280
async(Dispatchers.IO) {
280-
val driverHostPort = if (effectiveShards == 1) {
281-
parent?.port ?: 7001
282-
} else {
283-
(7001..7128).shuffled().find { port ->
284-
usedPorts.putIfAbsent(port, true) == null
285-
} ?: error("No available ports found")
286-
}
281+
val driverHostPort = if (!sharded) parent?.port ?: 7001 else (7001..7128).shuffled().find { port ->
282+
usedPorts.putIfAbsent(port, true) == null
283+
} ?: error("No available ports found")
287284

288285
// Acquire lock to execute device creation block
289286
deviceCreationSemaphore.acquire()
@@ -383,7 +380,7 @@ class TestCommand : Callable<Int> {
383380

384381
suites.mergeSummaries()?.saveReport()
385382

386-
if (effectiveShards > 1) printShardsMessage(passed, total, suites)
383+
if (sharded) printShardsMessage(passed, total, suites)
387384
if (passed == total) 0 else 1
388385
}.onFailure {
389386
PrintUtils.message("❌ Error: ${it.message}")

0 commit comments

Comments
 (0)