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

Always make available trace logs #557

Merged
merged 1 commit into from
Nov 28, 2023
Merged

Conversation

LukeButters
Copy link
Contributor

Background

We always recorded trace logs to file, this PR changes the tests so that those trace logs are always available.

This means:

  • On teamcity if a test times out and never reaches a tear down, we can still see trace logs.
  • Locally we can view trace logs.

This test will also print the location of the trace log for easy debugging.

How to review this PR

Quality ✔️

Pre-requisites

  • I have read How we use GitHub Issues for help deciding when and where it's appropriate to make an issue.
  • I have considered informing or consulting the right people, according to the ownership map.
  • I have considered appropriate testing for my change.

// Best effort clean-up, but we don't want to
// fail the test because we couldn't delete this file
}
cancellationTokenSource.Cancel();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need to delete the log file.

but we do await the writing of logs, since we really want to know if writing logs doesn't work.

@LukeButters LukeButters marked this pull request as ready for review November 27, 2023 00:21
@LukeButters LukeButters requested a review from a team as a code owner November 27, 2023 00:21
@LukeButters LukeButters changed the title Always record trace logs Always make available trace logs Nov 27, 2023
Copy link
Contributor

@acodrington acodrington left a comment

Choose a reason for hiding this comment

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

Nice one, thanks! 👍🏻

}

public bool CopyLogFileToArtifacts()
public static DirectoryInfo LogFileDirectory()
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this doesn't need to be public anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah probably

Logger = new SerilogLoggerBuilder()
.SetTraceLogFileLogger(traceLogFileLogger)
.Build()
.ForContext(GetType());

Logger.Information("Trace log file {LogFile}", traceLogFileLogger.logFilePath);
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for this bit, I've got some WIP code to associate the TeamCity artifact with the test run so the trace log file can be accessed in-line in the build log, but there's still some TeamCity black magic I need to figure out to get it to work.

This will help in the meantime!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah nice!

I also like this message for local development, since when the test is run the first line is "here is more info if you need it"

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, it was on my to-do list for that exact reason, but got distracted by the TeamCity black magic and it didn't make it to a PR.

@LukeButters LukeButters merged commit 3c6786e into main Nov 28, 2023
15 checks passed
@LukeButters LukeButters deleted the sast/always-record-trace-logs branch November 28, 2023 21:59
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