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

[FLINK-6397] MultipleProgramsTestBase does not reset ContextEnvironment #3810

Closed
wants to merge 6 commits into from

Conversation

ifndef-SleePy
Copy link
Contributor

@ifndef-SleePy ifndef-SleePy commented May 2, 2017

Reset ContextEnvironment when finished testing in MultipleProgramsTestBase.java and some other ITCases.
Remove some useless importing.
Add unsetContext method in TestEnvironment.java.

switch(mode){
case CLUSTER:
new TestEnvironment(cluster, 4).setAsContext();
testEnvironment = new TestEnvironment(cluster, 4);
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 suggest moving this into an @Before method and calling unsetAsContext in a @After method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds reasonable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zentol I just found that I can not move these codes into @before method, because it will not work with JUnit Parameterized. I proposal to keep these codes in constructor. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you try this instead: junit-team/junit4#45 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for responding. Last my comment is not correct. Actually what I want to say is that we can not move these code to @BeforeClass and @afterclass. But we can move them to @before and @after, however it will bring a little overhead since @before and @after will be called for each test method. I pushed a new commit using @before and @after.

@StephanEwen
Copy link
Contributor

I would suggest to use for TestEnvionment the same approach as in TestStreamEnvironment (a static unset method). Then you don't need to ever remember a reference to the environment, which makes the changes much smaller.

@ifndef-SleePy
Copy link
Contributor Author

@StephanEwen
I agree that a static unset method would be a much easier implementation. Do you think it's acceptable that the unset method is static but set method is not static in TestEnvironment? Or we can implement the set method as static too, but that will make more changes.

@ifndef-SleePy ifndef-SleePy changed the title [Flink-6397] MultipleProgramsTestBase does not reset ContextEnvironment [FLINK-6397] MultipleProgramsTestBase does not reset ContextEnvironment May 4, 2017
@ifndef-SleePy
Copy link
Contributor Author

I think Till has implemented a static unsetAsContext method in TestEnvironment recently. I rebased the implementation from master, and recommit the pull request.

Copy link
Contributor

@zentol zentol left a comment

Choose a reason for hiding this comment

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

Bar some minor comments this looks good to merge.

@@ -49,7 +49,7 @@ public JobExecutionResult execute(String jobName) throws Exception {
return result;
}

protected void setAsContext() {
public void setAsContext() {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we still need this change?

@@ -97,6 +105,12 @@ public MultipleProgramsTestBase(TestExecutionMode mode) {
}
}

@After
public void teardownEnvironment() {
TestEnvironment.unsetAsContext();
Copy link
Contributor

Choose a reason for hiding this comment

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

you could add another switch here, instead of calling both methods every time.

@ifndef-SleePy
Copy link
Contributor Author

Hi, I updated this review. I don't know why there is no reminding in jira and email.

@zentol
Copy link
Contributor

zentol commented May 9, 2017

We don't get notifications about pushed commits in general, only for comments and created/closed pull requests.

@ifndef-SleePy
Copy link
Contributor Author

OK, got it. Thank you for explanation. Is there any more problems with this pull request?

@zentol
Copy link
Contributor

zentol commented May 10, 2017

Not quite; the CassandraConnectorITCase was broken in the process. This test contains both batch and streaming jobs that rely on different TestEnvironments. When the batch TestEnvironment is set as the context the streaming tests will fail.

StreamExecutionEnvironment#getExecutionEnvironment() doesn't account for this case, and tries to create a LocalStreamEnvironment which however fails since no explicit environment may be create when a context environment was set.

This is more or less a problem of the cassandra test; it shouldn't actually run any jobs at all. Let me fix that, then we'll get back to this PR.

Besides that i don't see any problems right now.

@zentol
Copy link
Contributor

zentol commented May 12, 2017

I've fixed the cassandra tests, would be great if you could rebase this PR. You should be able to discard all changes to the cassandra tests in this PR.

@ifndef-SleePy
Copy link
Contributor Author

Nice work!
I have rebased master.

@zentol
Copy link
Contributor

zentol commented May 13, 2017

merging.

@asfgit asfgit closed this in 707f25f May 13, 2017
fanyon pushed a commit to fanyon/flink that referenced this pull request May 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants