-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix(compute-samples): fixed flaky firewall rule deletion #6609
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
Conversation
| Assert.assertEquals(500, client.get(PROJECT_ID, FIREWALL_RULE_CREATE).getPriority()); | ||
| stdOut.close(); | ||
| System.setOut(null); | ||
| ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); |
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.
nit: a more consistent way would be to execute this in a before or beforeAll method.
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.
beforeAll() has the mechanism to clear stdout before every function.
testPatchFirewallRule() needed this as it is called from setUp() directly (to test before GCE Enforcer renders this test invalid).
| // Clear system output to not affect other tests. | ||
| // Refrain from setting out to null as it will throw NullPointer in the subsequent tests. | ||
| stdOut.close(); | ||
| System.setOut(new PrintStream(new ByteArrayOutputStream())); |
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.
nit: a safer way is to save stdout and then set to previous stdout
Line 307 in 1cdb592
| PrintStream standardOut = System.out; |
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.
Thanks Averi. Will include this change.
* fix(compute-samples): fixed flaky firewall rule deletion * fix(compute-samples): fixed flaky firewall rule deletion * fix(compute-samples): fixed NullPointer caused by Sysout set to null * docs(compute-samples): included review comments * docs(compute-samples): included review comments * docs(compute-samples): lint fix
Fixes #6608
pom.xmlparent set to latestshared-configurationmvn clean verifyrequiredmvn -P lint checkstyle:checkrequiredmvn -P lint clean compile pmd:cpd-check spotbugs:checkadvisory only