Skip to content

MINOR: Pass a streams config to replace the single state dir#4714

Merged
guozhangwang merged 12 commits intoapache:trunkfrom
guozhangwang:KMinor-use-property-file-for-system-tests
Mar 19, 2018
Merged

MINOR: Pass a streams config to replace the single state dir#4714
guozhangwang merged 12 commits intoapache:trunkfrom
guozhangwang:KMinor-use-property-file-for-system-tests

Conversation

@guozhangwang
Copy link
Copy Markdown
Contributor

@guozhangwang guozhangwang commented Mar 14, 2018

This is a general change and is re-requisite to allow streams benchmark test with different streams tests. For the streams benchmark itself I will have a separate PR for switching configs. Details:

  1. Create a "streams.properties" file under PERSISTENT_ROOT before all the streams test. For now it will only contain a single config of state.dir pointing to PERSISTENT_ROOT.
  2. For all the system test related code, replace the main function parameter of state.dir with propsFilename, then inside the function load the props from the file and apply overrides if necessary.
  3. Minor fixes.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@guozhangwang
Copy link
Copy Markdown
Contributor Author

guozhangwang commented Mar 14, 2018

@mjsax @bbejeck @vvcephei @dguy for reviews.

@mjsax mjsax changed the title MIOR: pass a streams config to replace the single state dir MINOR: pass a streams config to replace the single state dir Mar 14, 2018
@mjsax mjsax added the streams label Mar 14, 2018
@mjsax mjsax requested review from dguy and mjsax March 14, 2018 22:36
@bbejeck
Copy link
Copy Markdown
Member

bbejeck commented Mar 14, 2018

@guozhangwang failures are related, unused import

@guozhangwang
Copy link
Copy Markdown
Contributor Author

Yup, I'm fixing.

@guozhangwang guozhangwang changed the title MINOR: pass a streams config to replace the single state dir MINOR: Pass a streams config to replace the single state dir Mar 15, 2018
@guozhangwang
Copy link
Copy Markdown
Contributor Author

guozhangwang commented Mar 15, 2018

Triggered system tests: https://jenkins.confluent.io/job/system-test-kafka-branch-builder/1471 Succeeded.

stateDir.mkdir();

final Properties streamsProperties = new Properties();
final Properties streamsProperties = Utils.loadProps(propFileName);
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.

propFileName could be null, do a null check here?

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.

I will consider adding the check within the function.

final Serde<String> stringSerde = Serdes.String();

final Properties streamsProperties = new Properties();
final Properties streamsProperties = Utils.loadProps(propFileName);
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.

same here, check for null propFileName

final String propFileName = args.length > 1 ? args[1] : null;
final String command = args.length > 2 ? args[2] : null;

final Properties streamsProperties = Utils.loadProps(propFileName);
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.

same here


final Properties streamsProperties = new Properties();
streamsProperties.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, kafka);
final Properties streamsProperties = Utils.loadProps(propFileName);
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.

as above

@bbejeck
Copy link
Copy Markdown
Member

bbejeck commented Mar 16, 2018

Thanks @guozhangwang left a few minor comments, otherwise LGTM.

One general question and sorry if I missed something, but where do we supply our own properties file or edit the existing one to add additional settings?

@guozhangwang
Copy link
Copy Markdown
Contributor Author

One general question and sorry if I missed something, but where do we supply our own properties file or edit the existing one to add additional settings?

Thanks for the comments. For your question, the file is added here:

https://github.com/apache/kafka/pull/4714/files#diff-1dcacbd6daa49466dc7cb89022929dfbR143

that will only encode the state dir for now. In the follow-up PR I will modify simple benchmark python code to allow for other config overridden and remove the hard-coded ones in the java code. Does that make sense?

Copy link
Copy Markdown
Member

@mjsax mjsax left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Looks good overall. Couple of minor comments.

Can you also run streams system test before we merge this. Thx.

props.load(propStream);

if (filename != null) {
try (InputStream propStream = new FileInputStream(filename)) {
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.

Should we log something for this case?


final Properties props = Utils.loadProps(propFileName);

String stateDirStr;
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.

nit: add final

benchmark.run();
}

public Properties setStreamProperties(final String applicationId) {
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.

should we change the return type to void?

private boolean uncaughtException = false;

public SmokeTestClient(File stateDir, String kafka) {
public SmokeTestClient(Properties streamsProperties, String 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.

nit: add final to cleanup code


private static KafkaStreams createKafkaStreams(File stateDir, String kafka) {
final Properties props = new Properties();
private static KafkaStreams createKafkaStreams(Properties props, String 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.

nit: add final

System.out.println("numThreads=" + numThreads);

SimpleBenchmark benchmark = new SimpleBenchmark(stateDir, kafka, loadPhase, testName, numRecords, numThreads);
SimpleBenchmark benchmark = new SimpleBenchmark(props, kafka, loadPhase, testName, numRecords, numThreads);
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.

should we put kafka and numThread directly into props and reduce number of parameters here (would also simplify all the "passing through" code.

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.

Yes, in my follow-up PR I've done that, just for its scope I tend to keep its changes more focused.

String kafka = args[0];
String stateDir = args.length > 1 ? args[1] : null;
String command = args.length > 2 ? args[2] : null;
public static void main(String[] args) throws InterruptedException, IOException {
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.

nit: add final

public class StreamsStandByReplicaTest {

public static void main(String[] args) {
public static void main(String[] args) throws IOException {
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.

nit: add final

@guozhangwang
Copy link
Copy Markdown
Contributor Author

Can you also run streams system test before we merge this. Thx.

Yeah I have triggered a couple streams system test, the first successful one is https://jenkins.confluent.io/job/system-test-kafka-branch-builder/1471

@guozhangwang
Copy link
Copy Markdown
Contributor Author

Copy link
Copy Markdown
Member

@mjsax mjsax left a comment

Choose a reason for hiding this comment

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

LGTM.

Is there already a follow up PR that address the pending comments?

@guozhangwang
Copy link
Copy Markdown
Contributor Author

I'll create the follow-up PR once I rebased this one, there are a sequence of them on my local repo :)

@guozhangwang guozhangwang merged commit 0f364cd into apache:trunk Mar 19, 2018
@guozhangwang guozhangwang deleted the KMinor-use-property-file-for-system-tests branch April 24, 2020 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants