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 copy logs to circle in finally #384

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

pnepywoda
Copy link

@pnepywoda pnepywoda commented Oct 22, 2019

call after() (exactly 1 time)

@changelog-app
Copy link

changelog-app bot commented Oct 22, 2019

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

always copy logs to circle in finally

doesnt work - jupiter always calls after anyway

Check the box to generate changelog(s)

  • Generate changelog entry

@pnepywoda
Copy link
Author

pnepywoda commented Oct 22, 2019

Running DockerComposeExtensionIntegrationTestWithFailingCommand results in:

[main] ERROR com.palantir.docker.compose.reporting.RunRecorder - EnhancedDockerComposeRule has failed in after()
com.palantir.logsafe.exceptions.SafeIllegalArgumentException: Some required fields have not been set: {missingFields=[startTime]}
	at com.palantir.docker.compose.report.DockerComposeRun.validateFields(DockerComposeRun.java:174)
	at com.palantir.docker.compose.report.DockerComposeRun.<init>(DockerComposeRun.java:49)
	at com.palantir.docker.compose.report.DockerComposeRun.<init>(DockerComposeRun.java:24)
	at com.palantir.docker.compose.report.DockerComposeRun$Builder.build(DockerComposeRun.java:306)
	at com.palantir.docker.compose.reporting.RunRecorder.after(RunRecorder.java:73)
	at com.palantir.docker.compose.DockerComposeManager.after(DockerComposeManager.java:269)
	at com.palantir.docker.compose.DockerComposeExtension.afterAll(DockerComposeExtension.java:45)

because we reset the runRecorder in after

@pnepywoda pnepywoda closed this Oct 22, 2019
@pnepywoda pnepywoda reopened this Oct 22, 2019
@CRogers
Copy link
Contributor

CRogers commented Oct 29, 2019

We should make sure calling after() multiple times is ok. I think the easiest way to do this to either record a boolean flag for whether after has been called before (and then not run it again) or use a memoised supplier to just run the code in after once.

Comment on lines 35 to 40
try {
before();
} catch (RuntimeException e) {
after();
throw e;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would avoid having behaviour like this in junit5 version only. Instead this should live in DockerComposeManager.before() so both junit4 and 5 have the same behaviour

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I've just seen the junit4 code has something similar but needs to be slightly different as it uses the Statement style - this could stay. A little worried about the rethrowing the exception meaning this piece of code is missing in the stacktrace (perhaps addSupressed could help here by appending on an extra exception, if we need to keep the existing exception for backcompat reasons).

@pnepywoda
Copy link
Author

@CRogers I can do the call-after-once fix you suggested but do you know why the current integration test isn't failing here? I guess it's not running my new DockerComposeExtensionIntegrationTestWithFailingCommand ?

@@ -30,14 +30,24 @@
public abstract class DockerComposeExtension extends DockerComposeManager
implements BeforeAllCallback, AfterAllCallback {

private boolean hasCalledAfterMethod;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should live in DockerComposeManager, not DockerComposeExtension that way DockerComposeRule gets this behaviour too.

@pnepywoda pnepywoda force-pushed the pnepywoda/alwaysAfter branch from f1a80e3 to 3d98783 Compare November 14, 2019 23:41
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