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

#870 Added --directories-to-pull validation and avoid making request with empty toolStepResult #876

Merged
merged 5 commits into from
Jul 6, 2020

Conversation

piotradamczyk5
Copy link
Contributor

@piotradamczyk5 piotradamczyk5 commented Jul 2, 2020

Fixes #870

Test Plan

How do we know the code works?

NPE with missing toolStepResult was caused because we try to get results for an invalid matrix. Matrix was invalid because FTL rejects the request with invalid --directories-to-pull value.
To avoid this issue correct validation of this parameter was introduced, as well as filtering getting results for empty toolStepResult.
Gcloud policies were applied to --directories-to-pull:

  • the path must start with /sdcard or /data/local/tmp
  • the path must contain only characters a-zA-Z0-9_-./+

In order to test this issue, please use --directories-to-pull value which does not meet this 2 criteria.

Checklist

  • Documented
  • Unit tested
  • release_notes.md updated

@piotradamczyk5 piotradamczyk5 self-assigned this Jul 2, 2020
@adamfilipow92
Copy link
Contributor

adamfilipow92 commented Jul 3, 2020

I noticed some differnces on master and your branche.

We have multiple-success yml

gcloud:
  app: ./src/test/kotlin/ftl/fixtures/tmp/apk/app-debug.apk
  test: ./src/test/kotlin/ftl/fixtures/tmp/apk/app-multiple-success-debug-androidTest.apk
  environment-variables: 
    coverage: true
    coverageFilePath: /sdcard/
    clearPackageData: true
  directories-to-pull: 
    - /sdcard/
  use-orchestrator: false

flank:
  disable-sharding: false
  max-test-shards: 2
  files-to-download:
    - .*/sdcard/[^/]+\.ec$


  1. When I run this config on master its working
  2. When I run this config with your changes its failing with message

Invalid value for [directories-to-pull]: Invalid path [/sdcard/].
Path must be absolute paths under /sdcard or /data/local/tmp (for example, --directories-to-pull /sdcard/tempDir1,/data/local/tmp/tempDir2).
Path names are restricted to the characters [a-zA-Z0-9_-./+]. 

Process finished with exit code 2

FIXED

@adamfilipow92 adamfilipow92 self-assigned this Jul 3, 2020
@@ -7,6 +7,7 @@ internal fun List<TestExecution>.createJUnitTestResult(
withStackTraces: Boolean = false
) = JUnitTestResult(
testsuites = this
.filterNullToolResultsStep()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I wonder why FTL is returning null for toolResultsStep?
  2. Can we reproduce this error?
  3. Its safe to skip some tests execution and get correct results?
  4. Maybe flank should display proper warning about some unexpected behaviour?

Copy link
Contributor Author

@piotradamczyk5 piotradamczyk5 Jul 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I wonder why FTL is returning null for toolResultsStep?
  2. Can we reproduce this error?
  3. Its safe to skip some tests execution and get correct results?
  4. Maybe flank should display proper warning about some unexpected behaviour?

AD 1. If matrix is invalid FTL returns null as toolResultsStep
AD 2. This is more to avoid crashing flank in the future, so far, for now, I do not know how to reproduce this issue
AD 3. This is safe because tests results are based on a request made with toolResultsStep which will not succeed without toolResultsStep
AD 4. Ideally, we should not trigger INVALID matrix request, but for now, we do not know which settings will cause matrix invalid (see point 2)

jan-goral
jan-goral previously approved these changes Jul 6, 2020
@@ -169,8 +169,7 @@ fun withGlobalExceptionHandling(block: () -> Int) {
}

private fun SavedMatrix.logError() {
println("More details are available at [${this.webLink}]")
println(this.asPrintableTable())
println("Matrix is $state")
Copy link
Contributor

@jan-goral jan-goral Jul 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be no table output if flank throw FTLError before MatrixResultsReport?

Copy link
Contributor Author

@piotradamczyk5 piotradamczyk5 Jul 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTLError is thrown after printing table


listOf(
    CostReport,
    MatrixResultsReport
).map {
    it.run(matrices, testSuite, printToStdout = true, args = args)  >>>>>>>>>>>>> PRINTING TABLE
}
if (!matrices.allSuccessful()) {
    listOf(
        HtmlErrorReport
    ).map { it.run(matrices, testSuite, printToStdout = false, args = args) }
}
JUnitReport.run(matrices, testSuite?.apply {
    if (ignoredTestCases.isNotEmpty()) {
        testsuites?.add(ignoredTestCases.toJunitTestsResults())
    }
}, printToStdout = false, args = args)
when {
    args.fullJUnitResult -> processFullJunitResult(args, matrices, testShardChunks)
    args.useLegacyJUnitResult -> processJunitXml(testSuite, args, testShardChunks)
}
matrices.validateMatrices(args.ignoreFailedTests) >>>>>>>>>>> FTLError

@piotradamczyk5 piotradamczyk5 merged commit aded032 into master Jul 6, 2020
@piotradamczyk5 piotradamczyk5 deleted the #870-added-directories-to-pull-validation branch July 6, 2020 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IllegalStateException: toolResultsStep must not be null
3 participants