-
Notifications
You must be signed in to change notification settings - Fork 909
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
Enhance simple test #3675
Enhance simple test #3675
Changes from 2 commits
b82c960
aa5b58b
4245a9e
686c7af
c94e2d1
2fa3165
76c8b71
aac0516
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
import lombok.experimental.Accessors; | ||
import org.apache.bookkeeper.client.api.BookKeeper; | ||
import org.apache.bookkeeper.client.api.DigestType; | ||
import org.apache.bookkeeper.client.api.ReadHandle; | ||
import org.apache.bookkeeper.client.api.WriteHandle; | ||
import org.apache.bookkeeper.tools.cli.commands.client.SimpleTestCommand.Flags; | ||
import org.apache.bookkeeper.tools.cli.helpers.ClientCommand; | ||
|
@@ -61,8 +62,6 @@ public static class Flags extends CliFlags { | |
private int ackQuorumSize = 2; | ||
@Parameter(names = { "-n", "--num-entries" }, description = "Entries to write (default 100)") | ||
private int numEntries = 100; | ||
@Parameter(names = { "-c", "--clean-up" }, description = "Clean up ledger created after simple test") | ||
private boolean cleanup = false; | ||
|
||
} | ||
public SimpleTestCommand() { | ||
|
@@ -102,10 +101,12 @@ protected void run(BookKeeper bk, Flags flags) throws Exception { | |
} | ||
} | ||
LOG.info("{} entries written to ledger {}", flags.numEntries, wh.getId()); | ||
if (flags.cleanup) { | ||
LOG.info("Cleaning up the ledger {}", wh.getId()); | ||
result(bk.newDeleteLedgerOp().withLedgerId(wh.getId()).execute()); | ||
|
||
try (ReadHandle rh = result(bk.newOpenLedgerOp().withLedgerId(wh.getId()).withDigestType(DigestType.CRC32C) | ||
.withPassword(new byte[0]).execute())) { | ||
rh.read(0, flags.numEntries); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you please assert the result of rh.read()? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fine, the write data is an empty array. I will change the written data and verify it. |
||
} | ||
result(bk.newDeleteLedgerOp().withLedgerId(wh.getId()).execute()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Finally? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fine. |
||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an easily way to generate a ledger. I am not sure if it should be deleted automatically. If we delete it automatically, the only way to get a ledger is writing a program, it looks very inconvenient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command is for testing the bookkeeper to create a ledger and read the ledger. If already cover the user's case.
If users want to test by themselves, they should create a new one and read it, not support the ledger generated by SimpleTestCommand.