Skip to content

Commit

Permalink
Hooked everything together
Browse files Browse the repository at this point in the history
  • Loading branch information
csessa committed Nov 16, 2018
1 parent 0257d14 commit c383718
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
14 changes: 9 additions & 5 deletions test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import ftl.config.FtlConstants.useMock
import ftl.filter.TestFilters
import ftl.gc.GcStorage
import ftl.reports.xml.model.JUnitTestResult
import ftl.reports.xml.parseIosXml
import ftl.shard.Shard
import ftl.util.Utils
import kotlinx.coroutines.runBlocking
import java.nio.file.Files
import java.nio.file.Path
import kotlin.system.measureNanoTime

// set default values, init properties, etc.
class AndroidArgs(
Expand Down Expand Up @@ -79,12 +79,16 @@ class AndroidArgs(
val filteredTests = getTestMethods(testLocalApk)

if (true) {
var result = emptyList<List<String>>()
val shardCreationTime = measureNanoTime {
result = convertShards(Shard.calculateShardsByTime(filteredTests, JUnitTestResult(null), testShards))
}

val oldXmlPath = GcStorage.downloadJunitXml(this)
val oldTestResult = if (oldXmlPath.isNotEmpty()) parseIosXml(oldXmlPath) else JUnitTestResult(mutableListOf())

val start = System.nanoTime()
val result = convertShards(Shard.calculateShardsByTime(filteredTests, oldTestResult, testShards))
val shardCreationTime = System.nanoTime() - start

println("Shard calculation took: $shardCreationTime")

result
} else {
calculateShards(
Expand Down
4 changes: 3 additions & 1 deletion test_runner/src/main/kotlin/ftl/args/ArgsHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ object ArgsHelper {
}

fun convertShards(shards: List<TestShard>): List<List<String>> {
return emptyList()
return shards.map { shard ->
shard.testMethods.map { it.name }
}
}
}
17 changes: 16 additions & 1 deletion test_runner/src/test/kotlin/ftl/args/ArgsHelperTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import com.google.common.truth.Truth.assertThat
import ftl.args.ArgsHelper.assertFileExists
import ftl.args.ArgsHelper.assertGcsFileExists
import ftl.args.ArgsHelper.calculateShards
import ftl.args.ArgsHelper.convertShards
import ftl.args.ArgsHelper.createGcsBucket
import ftl.args.ArgsHelper.mergeYmlMaps
import ftl.args.ArgsHelper.validateTestMethods
import ftl.args.yml.GcloudYml
import ftl.args.yml.IosGcloudYml
import ftl.shard.TestMethod
import ftl.shard.TestShard
import ftl.test.util.FlankTestRunner
import org.junit.Rule
import org.junit.Test
Expand Down Expand Up @@ -164,6 +167,18 @@ class ArgsHelperTest {

@Test
fun convertShardsTest() {
// TODO
val shards = listOf(
TestShard(3.0, mutableListOf(TestMethod("a", 1.0), TestMethod("b", 2.0))),
TestShard(4.0, mutableListOf(TestMethod("c", 4.0))),
TestShard(5.0, mutableListOf(TestMethod("d", 2.0), TestMethod("e", 3.0)))
)

val expected = listOf(
listOf("a", "b"),
listOf("c"),
listOf("d", "e")
)

assertThat(convertShards(shards)).isEqualTo(expected)
}
}

0 comments on commit c383718

Please sign in to comment.