Log orphaned attachments action for tests#2940
Conversation
labkey-tchad
left a comment
There was a problem hiding this comment.
I'd be happy to have this check run after every test.
| @Test | ||
| public void testOrphanedAttachments() | ||
| { | ||
| int orphanCount = AttachmentHelper.logOrphanedAttachments(); | ||
| if (orphanCount > 0) | ||
| log("Orphaned attachments: " + orphanCount); | ||
| } | ||
|
|
There was a problem hiding this comment.
The test runner always forces BasicTest to run first so this won't catch anything on TeamCity. I'd suggest adding this check to BaseWebDriverTest.doPostamble, around where we run the crawler (checkLinks) and check for CSP warnings (checkNewCspWarnings).
It should also throw an error if any orphaned attachments are found, otherwise we won't ever notice them.
There was a problem hiding this comment.
Actually, I didn't notice that the logOrphanedAttachments action will make ERROR logs. Those will already cause the test to fail so there's no need to add the extra fail case from the orphaned attachment check itself.
There was a problem hiding this comment.
I can remove the check from BasicTest. The product still checks and logs errors for orphaned attachments before every container delete, so will doPostamble check anything that delete container won't?
There was a problem hiding this comment.
Oh. Yeah, adding the check to doPostamble wouldn't accomplish much in that case. I thought the existing orphaned attachment check happened after container deletion and that we were adding an extra check for items that are cleaned up by container deletion but might be orphaned by other means.
labkey-tchad
left a comment
There was a problem hiding this comment.
Maybe add testOrphanedAttachments to DatabaseDiagnosticsTest instead. It's in a lot of suites and is always the final test of a suite.
Rationale
AttachmentHelper.logOrphanedAttachments()gives the tests a way to proactively check for orphaned attachmentsRelated Pull Requests