Skip to content

KAFKA-3607: Close KStreamTestDriver upon completing#1258

Closed
guozhangwang wants to merge 6 commits into
apache:trunkfrom
guozhangwang:K3607
Closed

KAFKA-3607: Close KStreamTestDriver upon completing#1258
guozhangwang wants to merge 6 commits into
apache:trunkfrom
guozhangwang:K3607

Conversation

@guozhangwang
Copy link
Copy Markdown
Contributor

No description provided.

@guozhangwang guozhangwang changed the title [WIP]KAFKA-3607: Close KStreamTestDriver upon completing KAFKA-3607: Close KStreamTestDriver upon completing Apr 24, 2016
@guozhangwang
Copy link
Copy Markdown
Contributor Author

@ijuma @enothereska @miguno for reviews.

  1. Add a close() function in KStreamTestDriver, which closes the state stores in the topology, so that RocksDB will not be destroyed by static deconstrutor.
  2. Use @Rule for temporary folder, which will be deleted after the test; and remove the finally block for deleting the folder.

Ran the branch on Jenkins for 15+ rounds, and do not see the virtual method issue again.

driver.close();
}
driver = null;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This code seems to be repeated in a lot of tests. Is there a reason why we don't introduce a superclass for initialisation and clean-up of KStreamTestDriver?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could also make KStreamTestDriver a JUnit ExternalResource so that the shutdown is done automatically.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ExternalResource: +1 (assuming it'll work that way)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ijuma @miguno I thought about that. But one tricky thing is that KStreamTestDriver usually needs to be constructed within the test case since its construction parameters are dynamic, and hence cannot define it outside the test case. Suggestions welcomed.

Copy link
Copy Markdown
Contributor

@miguno miguno Apr 25, 2016

Choose a reason for hiding this comment

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

Edit: Ah, I think you mean that we need to pass builder to the constructor of KStreamTestDriver, which (in this case, unfortunately) is being mutated by subsequent calls such as builder.stream() or stream.branch() before we pass it to the driver constructor?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps @dguy has an idea whether it's possible to use KStreamTestDriver as an ExternalResource even though, for constructing an instance of the former, we need to pass a test case specific parameter (here: builder aka KStreamBuilder instance) to it for each test.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It is possible, but you'd need to make a few changes to KStreamTestDriver , i.e., everything currently in the constructor would need to be moved into a method that can be called from the tests. So you'd end up having an overloaded initiliaze method instead of the various constructors.

@enothereska
Copy link
Copy Markdown
Contributor

enothereska commented Apr 24, 2016

LGTM modulo @ijuma 's comments. Tests ran locally fine.

@guozhangwang
Copy link
Copy Markdown
Contributor Author

@ijuma Please review again.

I did not make KStreamTestDriver extending ExternalResource and keep the @After process. If we want to make that change I'd prefer do it in a separate PR.

public void run() {
Utils.delete(file);
}
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't need this for files, right? Just for directories (because of file.deleteOnExit)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ack.

@miguno
Copy link
Copy Markdown
Contributor

miguno commented Apr 25, 2016

@guozhangwang: Do we want to update KStreamTestDriver so that it's usable as an ExternalResource?

@guozhangwang
Copy link
Copy Markdown
Contributor Author

@miguno As I mentioned above, I'd prefer to do it in a separate PR.

@guozhangwang
Copy link
Copy Markdown
Contributor Author

@ijuma Could you take another look?

}
})
f
org.apache.kafka.test.TestUtils.tempDirectory(parentFile.toPath, "kafka-");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would it not be better to use kafka- as the prefix by default in o.a.k.t.TestUtils.tempDirectory?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ack. Changing kafka to kafka-.

@ijuma
Copy link
Copy Markdown
Member

ijuma commented Apr 26, 2016

@guozhangwang Generally, it would be better not to introduce technical debt and then fix it in cases where the fix is straightforward. However, this helps with test stability, so I am OK for this to be merged before we do KAFKA-3623 if you address the two minor comments I left and you edit the PR description to mention that the duplication will be handled as part of KAFKA-3623 (no additional review is needed).

@asfgit asfgit closed this in 1a73629 Apr 26, 2016
@guozhangwang guozhangwang deleted the K3607 branch May 11, 2016 23:58
@guozhangwang guozhangwang restored the K3607 branch May 11, 2016 23:58
gfodor pushed a commit to AltspaceVR/kafka that referenced this pull request Jun 3, 2016
…to be tracked in KAFKA-3623

Author: Guozhang Wang <wangguoz@gmail.com>

Reviewers: Eno Thereska, Michael G. Noll, Ismael Juma

Closes apache#1258 from guozhangwang/K3607
@guozhangwang guozhangwang deleted the K3607 branch October 7, 2016 21:44
efeg pushed a commit to efeg/kafka that referenced this pull request May 29, 2024
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.

5 participants