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

Fix bug in terratest-log-parser that mixes result lines #899

Merged
merged 1 commit into from
May 14, 2021

Conversation

yorinasub17
Copy link
Contributor

This fixes two bugs in terratest-log-parser:

  • terratest-log-parser was incorrectly handling result lines such that they leaked into the wrong test. You can see this behavior in the modifications made to the test fixtures.
  • With newer go versions, the assertion failures were being reported before the fail result line. This change was previously not handled well, resulting in the error traces being ignored and not making it to any split out log file. This now properly feeds those lines to the right test file.

@yorinasub17 yorinasub17 requested a review from brikis98 as a code owner May 13, 2021 23:27
@yorinasub17
Copy link
Contributor Author

NOTE: build is failing because of #898

@@ -140,6 +140,7 @@ func parseAndStoreTestOutput(

case isStatusLine(data):
testName := getTestNameFromStatusLine(data)
previousTestName = testName
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the fix for the lost error trace. The error trace line was happening right after a === CONT TESTNAME line, which is a status line. Now we roll up any unmarked test lines that show up after a status line to the test that relates to the status line.

@@ -164,13 +164,15 @@ func parseAndStoreTestOutput(
previousTestName = "summary"
logWriter.writeLog(logger, "summary", data)

case isResultLine(data):
// We ignore result lines, because that is handled specially below.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes the bug where the results lines leak into unrelated test logs. The result lines were ending up in the base case right below this because there was no case guard that handled the result lines separately.

case previousTestName != "":
// Base case: roll up to the previous test line, if it exists.
// Handles case where terratest log has entries with newlines in them.
logWriter.writeLog(logger, previousTestName, data)

case !isResultLine(data):
// Result Lines are handled below
default:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The previous logic didn't make sense, so this was switched to default which makes more sense.

case isIndented && previousTestName != "summary":
// In a test result block, so collect the line into all the test results we have seen so far.
// Note that previousTestName would only be set to summary if we saw a panic line.
case isIndented && isResultLine(data):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a more direct case guard for the specific case that this is trying to capture.

brikis98
brikis98 previously approved these changes May 14, 2021
Copy link
Member

@brikis98 brikis98 left a comment

Choose a reason for hiding this comment

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

LGTM!

@yorinasub17
Copy link
Contributor Author

UPDATE: Rebased on master to trigger build with fix branch so we get some regression testing.

@yorinasub17
Copy link
Contributor Author

@brikis98 Can I get another approval now that the build is passing on the rebase?

@yorinasub17
Copy link
Contributor Author

Thanks for review! Merging this in now!

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.

2 participants