From c144f80e0aa0c88d6877c36adbf1898e036f851b Mon Sep 17 00:00:00 2001 From: piotradamczyk5 <65554637+piotradamczyk5@users.noreply.github.com> Date: Fri, 26 Mar 2021 09:58:08 +0100 Subject: [PATCH] test: Add IT for large shard test suite (#1737) Fixes #1650 ## Test Plan > How do we know the code works? New IT succeed. ## Checklist - [x] Integration tests updated --- .../integration/ManyTestsOnSingleShardIT.kt | 59 +++++++++++++++++++ ...ank_android_many_tests_on_single_shard.yml | 9 +++ 2 files changed, 68 insertions(+) create mode 100644 integration_tests/src/test/kotlin/integration/ManyTestsOnSingleShardIT.kt create mode 100644 integration_tests/src/test/resources/cases/flank_android_many_tests_on_single_shard.yml diff --git a/integration_tests/src/test/kotlin/integration/ManyTestsOnSingleShardIT.kt b/integration_tests/src/test/kotlin/integration/ManyTestsOnSingleShardIT.kt new file mode 100644 index 0000000000..1de85aa16f --- /dev/null +++ b/integration_tests/src/test/kotlin/integration/ManyTestsOnSingleShardIT.kt @@ -0,0 +1,59 @@ +package integration + +import FlankCommand +import com.google.common.truth.Truth.assertThat +import org.junit.Test +import run +import utils.CONFIGS_PATH +import utils.FLANK_JAR_PATH +import utils.androidRunCommands +import utils.asOutputReport +import utils.assertCostMatches +import utils.assertCountOfFailedTests +import utils.assertCountOfSkippedTests +import utils.assertExitCode +import utils.assertTestCountMatches +import utils.findTestDirectoryFromOutput +import utils.firstTestSuiteOverview +import utils.json +import utils.loadAsTestSuite +import utils.removeUnicode +import utils.toJUnitXmlFile +import utils.toOutputReportFile + +class ManyTestsOnSingleShardIT { + + private val name = this::class.java.simpleName + + @Test + fun `return with exit code 0 and has correct output`() { + val result = FlankCommand( + flankPath = FLANK_JAR_PATH, + ymlPath = "$CONFIGS_PATH/flank_android_many_tests_on_single_shard.yml", + params = androidRunCommands + ).run("./", name) + val expectedTestCount = 60 + + assertExitCode(result, 0) + + val resOutput = result.output.removeUnicode() + val outputDirectory = resOutput.findTestDirectoryFromOutput() + + // validate JUnitReport.xml + val testSuites = outputDirectory.toJUnitXmlFile().loadAsTestSuite() + assertThat(testSuites.testSuites.first().testCases.size).isEqualTo(expectedTestCount) + (0 until expectedTestCount).forEach { testNumber -> + assertThat(testSuites.testSuites.any { it.name == "test$testNumber" }) + assertThat(testSuites.assertCountOfFailedTests(0)) + assertThat(testSuites.assertCountOfSkippedTests(0)) + } + + // validate general + val outputReport = outputDirectory.toOutputReportFile().json().asOutputReport() + outputReport.assertCostMatches() + assertThat(outputReport.testResults).isNotEmpty() + assertThat(outputReport.weblinks).isNotEmpty() + assertThat(outputReport.error).isEmpty() + outputReport.firstTestSuiteOverview.assertTestCountMatches(total = expectedTestCount) + } +} diff --git a/integration_tests/src/test/resources/cases/flank_android_many_tests_on_single_shard.yml b/integration_tests/src/test/resources/cases/flank_android_many_tests_on_single_shard.yml new file mode 100644 index 0000000000..24874163ab --- /dev/null +++ b/integration_tests/src/test/resources/cases/flank_android_many_tests_on_single_shard.yml @@ -0,0 +1,9 @@ +gcloud: + app: ../test_runner/src/test/kotlin/ftl/fixtures/tmp/apk/app_many_tests-debug.apk + test: ../test_runner/src/test/kotlin/ftl/fixtures/tmp/apk/app_many_tests-debug-androidTest.apk + +flank: + disable-sharding: true + disable-results-upload: true + disable-usage-statistics: true + output-report: json