-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
debug: use human readable dates for filenames and improve the tests #10806
Conversation
460477f
to
6f5698b
Compare
fs.WithFile("metrics.json", "", fs.MatchAnyFileContent), | ||
fs.WithFile("consul.log", "", fs.MatchFileContent(validLogFile)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another possible improvement here might be to ensure the files contain at least one line. We may need to run a goroutine to perform some operations to ensure that some logs and metrics are emitted.
Metrics in particular are difficult to capture because we'd have to wait the 10s interval window, which makes the test a bit slower to run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good, but one question about timestamps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for cleaning this up @dnephin !!
I have a question about the time precision and a suggested cosmetic change.
22bbd7c
to
26ef0df
Compare
Use the new WriteJsonFile function to write index.json Remove .String() from time.local() since that is done by %s Remove an unused field.
6f5698b
to
f8b36d0
Compare
f8b36d0
to
bf97e89
Compare
The unix timestamps that were used make the debug data a little bit more difficult to consume. By using human readable dates we can easily see when the profile data was collected. This commit also improves the test coverage. Two test cases are removed and the assertions from those cases are moved to TestDebugCommand. Now TestDebugCommand is able to validate the contents of all files. This change reduces the test runtime of the command/debug package by almost 50%. It also makes much more strict assertions about the contents by using gotest.tools/v3/fs.
bf97e89
to
797ee06
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
🍒 If backport labels were added before merging, cherry-picking will start automatically. To retroactively trigger a backport after merging, add backport labels and re-run https://circleci.com/gh/hashicorp/consul/430133. |
Branched from #10804
The unix timestamps that were used previously make the debug data a little bit more difficult to consume. By using human readable dates we can easily see when the profile data was collected.
Also moves
profile.prof
,trace.out
,consul.log
, andmetrics.json
out of the sub-directories. There is only one of each of these, so we can put them in the top-level directory.Also improves the test coverage. Two test cases are removed and the assertions from those cases are moved to
TestDebugCommand
.Now
TestDebugCommand
is able to validate the contents of all files. This change reduces the test runtime of the command/debug package by almost 50%, while also improving the test coverage by making much more strict assertions about the files and their contents.