-
Notifications
You must be signed in to change notification settings - Fork 38
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
Add TestRule for preserving logs #191
base: scylla-4.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.datastax.oss.driver.api.testinfra.ccm; | ||
|
||
import org.junit.rules.TestWatcher; | ||
import org.junit.runner.Description; | ||
|
||
public class PreserveLogsRule extends TestWatcher { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question - why not to make it configurable from environment variable ? So that it could be easily set for whole run. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC this was the simplest way to have the rule react only in case of failure. The goal was to skip logs of passing runs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We definitely would want to store ccm logs on test failures on cicd. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make it global flag that controls whether we keep ccm logs after the test or not. |
||
private final CcmBridge ccmBridge; | ||
|
||
public PreserveLogsRule(CcmBridge ccmBridge) { | ||
this.ccmBridge = ccmBridge; | ||
} | ||
|
||
@Override | ||
protected void failed(Throwable e, Description description) { | ||
ccmBridge.setKeepLogs(true); | ||
} | ||
} |
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.
Why is this method moved here from CustomCcmRule?
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.
Could be an accident, but this was so long ago that I need to look at it again.
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.
I think it was to allow combining new rule with all other rules. New rule needs ccmBridge to modify its state.