Skip to content
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

feat: Added validation of smart-flank-gcs-path to not override different junit results #1056

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/bugs/smart_flank_upload_results_rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Smart Flank rules of validation result types

Flank trying to avoid override smart-flank-gcs-path by different JUnit report type. That's means:

1. If user select in ```smart-flank-gcs-path``` command FulJUnitResult.xml and flag ```--full-junit-result``` is not set Flank fail with the message

```txt

smart-flank-gcs-path is set with FullJUnitReport.xml but in this run --full-junit-result is disabled, please set --full-junit-result flag


```

2. If user set in ```smart-flank-gcs-path``` command JUnitResult.xml and flag ```--full-junit-result``` is set Flank fails with message

```txt

smart-flank-gcs-path is set with JUnitReport.xml but in this run --full-junit-result enabled, please turn off --full-junit-result flag


```

3. If ```smart-flank-gcs-path``` is set to a different name than ```JUnitReport.xml``` and ```FullJUnitReport.xml``` flank not validating report type

4. Flank not validating report type if flag ```--smart-flank-disable-upload``` set
14 changes: 12 additions & 2 deletions test_runner/src/main/kotlin/ftl/args/ValidateCommonArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package ftl.args

import ftl.config.Device
import ftl.config.FtlConstants
import ftl.reports.FullJUnitReport
import ftl.reports.JUnitReport
import ftl.run.exception.FlankConfigurationError
import ftl.run.exception.FlankGeneralError

Expand All @@ -26,8 +28,8 @@ private fun List<Device>.throwIfAnyMisspelt() =
private fun CommonArgs.assertProjectId() {
if (project.isEmpty()) throw FlankConfigurationError(
"The project is not set. Define GOOGLE_CLOUD_PROJECT, set project in flank.yml\n" +
"or save service account credential to ${FtlConstants.defaultCredentialPath}\n" +
" See https://github.com/GoogleCloudPlatform/google-cloud-java#specifying-a-project-id"
"or save service account credential to ${FtlConstants.defaultCredentialPath}\n" +
" See https://github.com/GoogleCloudPlatform/google-cloud-java#specifying-a-project-id"
)
}

Expand All @@ -54,5 +56,13 @@ private fun CommonArgs.assertSmartFlankGcsPath() = with(smartFlankGcsPath) {
count { it == '/' } <= 2 || endsWith(".xml").not() -> throw FlankConfigurationError(
"smart-flank-gcs-path must be in the format gs://bucket/foo.xml"
)

smartFlankDisableUpload.not() && contains("/${FullJUnitReport.fileName()}") && fullJUnitResult.not() -> throw FlankConfigurationError(
"smart-flank-gcs-path is set with ${FullJUnitReport.fileName()} but in this run --full-junit-result is disabled, please set --full-junit-result flag"
)

smartFlankDisableUpload.not() && contains("/${JUnitReport.fileName()}") && fullJUnitResult -> throw FlankConfigurationError(
"smart-flank-gcs-path is set with ${JUnitReport.fileName()} but in this run --full-junit-result enabled, please turn off --full-junit-result flag"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.google.common.truth.Truth.assertThat
import ftl.args.yml.AppTestPair
import ftl.config.Device
import ftl.config.FtlConstants
import ftl.run.exception.FlankConfigurationError
import ftl.test.util.FlankTestRunner
import org.junit.Assert.assertEquals
import org.junit.Rule
Expand Down Expand Up @@ -483,4 +484,43 @@ class AndroidRunCommandTest {

assertThat(cmd.config.common.flank.useAverageTestTimeForNewTests).isTrue()
}

@Test(expected = FlankConfigurationError::class)
fun `should throw if --full-junit-result and JUnitResult xml used`() {
val cmd = AndroidRunCommand()
CommandLine(cmd).parseArgs("--full-junit-result", "--smart-flank-gcs-path=gs://test-lab-v9cn46bb990nx-kz69ymd4nm9aq/2020-08-26_15-20-23.850738_rtGt/JUnitReport.xml")
cmd.run()
}

@Test(expected = FlankConfigurationError::class)
fun `should throw if FullJUnitResult xml used and --full-junit-result not set`() {
val cmd = AndroidRunCommand()
CommandLine(cmd).parseArgs("--smart-flank-gcs-path=gs://test-lab-v9cn46bb990nx-kz69ymd4nm9aq/2020-08-26_15-20-23.850738_rtGt/FullJUnitReport.xml")
cmd.run()
}

@Test
fun `should not throw if --full-junit-result and smart flank path different than JUnitReport xml`() {
val cmd = AndroidRunCommand()
CommandLine(cmd).parseArgs("--full-junit-result", "--smart-flank-gcs-path=gs://test-lab-v9cn46bb990nx-kz69ymd4nm9aq/2020-08-26_15-20-23.850738_rtGt/JUnitReportTest.xml")
cmd.run()
}

@Test
fun `should not throw if --full-junit-result not set and smart flank path different than JUnitReport xml`() {
val cmd = AndroidRunCommand()
CommandLine(cmd).parseArgs("--smart-flank-gcs-path=gs://test-lab-v9cn46bb990nx-kz69ymd4nm9aq/2020-08-26_15-20-23.850738_rtGt/JUnitReportTest.xml")
cmd.run()
}

@Test
fun `should not validate if smart-flank-disable-upload set`() {
val cmd = AndroidRunCommand()
CommandLine(cmd).parseArgs(
"--smart-flank-disable-upload",
"--full-junit-result",
"--smart-flank-gcs-path=gs://test-lab-v9cn46bb990nx-kz69ymd4nm9aq/2020-08-26_15-20-23.850738_rtGt/JUnitReport.xml"
)
cmd.run()
}
}