Skip to content

KAFKA-7210: Add a system test to verify the log compaction #5226

Merged
ijuma merged 10 commits intoapache:trunkfrom
omkreddy:TestLogClean
Aug 20, 2018
Merged

KAFKA-7210: Add a system test to verify the log compaction #5226
ijuma merged 10 commits intoapache:trunkfrom
omkreddy:TestLogClean

Conversation

@omkreddy
Copy link
Copy Markdown
Contributor

@omkreddy omkreddy commented Jun 14, 2018

  • Update TestLogCleaning tool to use Java consumer and rename as LogCompactionTester
  • Enable log compaction in System tests
  • Remove configs with values same as server defaults from "kafka.properties" template file.
  • Update the kafka.py logic to handle the duplicates between kafka.properties and server_prop_overides.

@omkreddy
Copy link
Copy Markdown
Contributor Author

omkreddy commented Jun 14, 2018

@ijuma Pls take a look. I have added a system test to verify compaction using this tool.
It will be good if we can merge this along with old consumer changes.

@omkreddy omkreddy force-pushed the TestLogClean branch 3 times, most recently from 3fd4735 to ae00322 Compare June 14, 2018 13:56
@omkreddy
Copy link
Copy Markdown
Contributor Author

retest this please

Copy link
Copy Markdown
Member

@ijuma ijuma left a comment

Choose a reason for hiding this comment

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

Thanks @omkreddy, this is very useful. @cmccabe, do you think you could review this?

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.

Why do we have to do this?

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.

"kafka.properties" template file contains default config values to populate server.properties.

Now log cleaner is enabled by default. So I have removed this property to enable it by default is tests.

"log.segment.bytes" property configured with sever default value and not updated by any of the test.

For now I reverted this change. if required we can do this cleanup later.

Also updated the logic in kafka.py to cleanup the duplicates between kafka.properties and server_prop_overides. Updated the logic to load the kafka.properties first and then override any server_prop_overides configs.

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.

I think it's good to enable the cleaner in the system tests. And if the other property is just the default, I agree we should just remove it from here.

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.

We should a subdirectory of /mnt, not directly inside /mnt

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.

Updated the code

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.

Can we just use &>> ?

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.

with "&>>" I am unable to run the command as background job. I will try again.

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's fine to leave it as-is if bash is being fiddly.

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.

This should be named LogCompactionTool. It is not a test (it is a service used by tests)

@omkreddy omkreddy force-pushed the TestLogClean branch 2 times, most recently from 8343549 to aa2288a Compare June 16, 2018 08:20
@omkreddy
Copy link
Copy Markdown
Contributor Author

omkreddy commented Jun 16, 2018

@cmccabe Thanks for the review. Addressed the review comments.

Also updated the logic in kafka.py to cleanup the duplicates between kafka.properties and server_prop_overides. We load the kafka.properties first and then override any server_prop_overides configs.

Pls take a look.

@omkreddy omkreddy force-pushed the TestLogClean branch 2 times, most recently from 744a64f to d73cce2 Compare June 17, 2018 12:00
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 should remain in the test directory right? It's similar to MiniKdc.

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.

It is similar to ReplicaVerificationTool. So i moved to src directory. This will be useful, if we want to test manually with binary distribution.

Also, adding testlibs to minikdc service classpath handled separately. not sure we want do same here.
https://github.com/apache/kafka/blob/trunk/tests/kafkatest/services/security/minikdc.py#L110MiniKdc

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.

A KIP is needed for adding new user visible tools. Personally, I don't see much value in testing the binary distribution manually.

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.

Ok.. moved tool class to test directory and retained the original name.

@omkreddy omkreddy force-pushed the TestLogClean branch 2 times, most recently from 59a529c to 46a6c30 Compare June 18, 2018 09:37
@omkreddy omkreddy changed the title MINOR: Update TestLogCleaning tool to use java consumer MINOR: Update TestLogCleaning tool to use Java consumer Jun 18, 2018
@omkreddy omkreddy force-pushed the TestLogClean branch 2 times, most recently from abbb03a to 0f6b938 Compare June 20, 2018 04:30
@omkreddy
Copy link
Copy Markdown
Contributor Author

@ijuma @cmccabe rebased the PR. Verified most of the system tests on my local machine.
Is it possible to start system test run for this branch?

@ijuma ijuma added this to the 2.1.0 milestone Jun 27, 2018
@ijuma
Copy link
Copy Markdown
Member

ijuma commented Jul 25, 2018

@cmccabe, can you please review?

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.

The should be --bootstrap-server to match how our tools work. (Some of them use nonstandard synonyms currently, but we want to converge on --bootstrap-server)

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.

Can we specify in the help text that this is the time in milliseconds?

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.

Can we use nextLong here to be more certain we won't get a collision?

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.

We should have a try/catch block here to prevent the AdminClient object from leaking.

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.

let's have a try/catch block here as well to prevent a leak.

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.

Now that we're using Java8, you can just use Files.newBufferedWriter here

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.

can you add parentheses to make this expression clearer

@cmccabe
Copy link
Copy Markdown
Contributor

cmccabe commented Jul 27, 2018

LGTM. Thanks, @omkreddy

@omkreddy
Copy link
Copy Markdown
Contributor Author

omkreddy commented Aug 6, 2018

@ijuma Can you please take a look?

Copy link
Copy Markdown
Member

@ijuma ijuma 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, it will be great to have this. I have a few comments.

Comment thread build.gradle Outdated
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.

Can you please remind me why we need to do this again?

Copy link
Copy Markdown
Contributor Author

@omkreddy omkreddy Aug 13, 2018

Choose a reason for hiding this comment

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

I am using TestUtils.waitUntilTrue() method in the test tool, which intern depends on clients/test/TestUtils.java. I added this line include client test library to system test dependent libs,

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.

Why doesn't the following do it?

from (configurations.testRuntime) {
      include('*.jar')
}

It seems like it should include every runtime dependency jar?

Copy link
Copy Markdown
Contributor Author

@omkreddy omkreddy Aug 18, 2018

Choose a reason for hiding this comment

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

current "configurations.testRuntime" does not include dependent project (clients) test jar/dependencies.

Updated build.gradle based on below link, to include dependent project test dependencies.

https://softnoise.wordpress.com/2014/09/07/gradle-sub-project-test-dependencies-in-multi-project-builds/

We can decide whether to have this commit (or) previous one line change.

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.

I'm confused about this message. Shouldn't we explain that arguments are expected or something like that?

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.

Is this used by anything?

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.

this is part of legacy tool which can be used to dump the log contents (Similar dump log tool). We can remove If we think it is not required.

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.

Yeah, if we don't have an immediate use, I'd remove it.

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.

removed the dumpOpt option

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.

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.

It would be helpful to know which topics have not been created.

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: a few unnecessary ()

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.

Can we just use Utils.utf8?

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.

There's a version that takes a ByteBuffer, so you can simplify more.

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.

These should probably be parse methods in the companion object (if they are used).

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.

added companion object. not sure, if this is what you're suggesting. Please take a look.

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.

What's the default for this?

Copy link
Copy Markdown
Contributor Author

@omkreddy omkreddy Aug 13, 2018

Choose a reason for hiding this comment

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

default is : 102400, not sure if we can remove this line

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.

I suggest we remove it.

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.

How long does this test usually take? Are we sure that 2 minutes is enough?

Copy link
Copy Markdown
Contributor Author

@omkreddy omkreddy Aug 13, 2018

Choose a reason for hiding this comment

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

For the configured system test inputs (1million small messages) it will take 60seconds to complete.

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.

OK, let's make it 180 seconds then.

@omkreddy
Copy link
Copy Markdown
Contributor Author

@ijuma Thanks for the review. Updated the review . Pls take one more look.

@omkreddy
Copy link
Copy Markdown
Contributor Author

retest this please

Copy link
Copy Markdown
Member

@ijuma ijuma 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 updates.

Copy link
Copy Markdown
Member

@ijuma ijuma Aug 18, 2018

Choose a reason for hiding this comment

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

Seems like you can do the filter here instead of forall and then the message creation below becomes simpler.

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: you can remove [Array[Byte], Array[Byte]]

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: you can remove [String, String].

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.

There's a version that takes a ByteBuffer, so you can simplify more.

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.

The idea was to call this method parse to make it clear that it's parsing the line and can fail.

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.

Is this used outside of the TestRecord.apply method? If so, I'd move it to the companion object too and give it another name (maybe parseComponents). Otherwise, I'd just inline it.

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.

Updated the code. Pls take a look.

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.

I think I'd say something about the fact that no arguments were passed, but some are expected.

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.

This line used for printing usage. next line checks for required arguments. Same pattern we are using in other tools.

Comment thread build.gradle Outdated
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.

Why doesn't the following do it?

from (configurations.testRuntime) {
      include('*.jar')
}

It seems like it should include every runtime dependency jar?

Comment thread build.gradle Outdated
}

artifacts {
testOutput jarTest
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.

Interesting. Does this create a new artifact? I think maybe we should go back to your previous solution that is limited to copyDependantTestLibs with a comment explaining why it's needed. We can consider separately whether we should move away from testCompile project(':clients').sourceSets.test.output in favour of the more complete solution across the board (we use test dependencies in multiple modules).

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.

There's also the option of just using https://plugins.gradle.org/plugin/com.github.hauner.jarTest/1.0, but it's best to discuss that in a separate PR.

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.

makes sense. reverted the last commit. Will handle this in separate PR.
For now, added a comment to explain the need for previous solution.

Copy link
Copy Markdown
Member

@ijuma ijuma 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 your patience, LGTM.

@ijuma ijuma merged commit 914ffa9 into apache:trunk Aug 20, 2018
@omkreddy omkreddy deleted the TestLogClean branch August 20, 2018 11:26
rayokota added a commit to rayokota/kafka that referenced this pull request Aug 21, 2018
This is a fix to apache#5226 to account for config properties that have an
equal char in the value.   Otherwise if there is one
equal char in the value the following error occurs:
```
dictionary update sequence element #XX has length 3; 2 is required
```
ijuma pushed a commit that referenced this pull request Aug 22, 2018
)

This is a fix to #5226 to account for config properties that have an
equal char in the value.   Otherwise if there is one
equal char in the value the following error occurs:

dictionary update sequence element #XX has length 3; 2 is required

Reviewers: Colin Patrick McCabe <colin@cmccabe.xyz>, Ismael Juma <ismael@juma.me.uk>
pengxiaolong pushed a commit to pengxiaolong/kafka that referenced this pull request Jun 14, 2019
* Updated TestLogCleaning tool to use Java consumer and rename as LogCompactionTester.
* Enabled the log cleaner in every system test.
* Removed configs from "kafka.properties" with default values and `socket.receive.buffer.bytes`
as the override did not seem necessary.
* Updated `kafka.py` logic to handle duplicates between `kafka.properties` and `server_prop_overrides`.
* Updated Gradle build so that classes from `kafka-clients` test jar can be used in
system tests.

Reviewers: Colin Patrick McCabe <colin@cmccabe.xyz>, Ismael Juma <ismael@juma.me.uk>
pengxiaolong pushed a commit to pengxiaolong/kafka that referenced this pull request Jun 14, 2019
…ache#5549)

This is a fix to apache#5226 to account for config properties that have an
equal char in the value.   Otherwise if there is one
equal char in the value the following error occurs:

dictionary update sequence element #XX has length 3; 2 is required

Reviewers: Colin Patrick McCabe <colin@cmccabe.xyz>, Ismael Juma <ismael@juma.me.uk>
kkonstantine pushed a commit to kkonstantine/kafka that referenced this pull request Jul 8, 2019
…ache#5549)

This is a fix to apache#5226 to account for config properties that have an
equal char in the value.   Otherwise if there is one
equal char in the value the following error occurs:

dictionary update sequence element #XX has length 3; 2 is required

Reviewers: Colin Patrick McCabe <colin@cmccabe.xyz>, Ismael Juma <ismael@juma.me.uk>
cmccabe pushed a commit that referenced this pull request Jul 8, 2019
) (#7042)

This is a fix to #5226 to account for config properties that have an
equal char in the value.   Otherwise if there is one
equal char in the value the following error occurs:

dictionary update sequence element #XX has length 3; 2 is required

Reviewers: Colin Patrick McCabe <colin@cmccabe.xyz>, Ismael Juma <ismael@juma.me.uk>
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.

3 participants