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

Enhance simple test #3675

Merged
merged 8 commits into from
Nov 30, 2022
Merged

Enhance simple test #3675

merged 8 commits into from
Nov 30, 2022

Conversation

horizonzy
Copy link
Member

Motivation

Fixes #3670


try (ReadHandle rh = result(bk.newOpenLedgerOp().withLedgerId(wh.getId()).withDigestType(DigestType.CRC32C)
.withPassword(new byte[0]).execute())) {
rh.read(0, flags.numEntries);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you please assert the result of rh.read()?

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

@horizonzy
Copy link
Member Author

rerun failure checks

@@ -61,8 +65,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")
Copy link
Member

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.

Copy link
Member Author

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.

@@ -81,6 +83,7 @@ public SimpleTestCommand(Flags flags) {
@SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE")
protected void run(BookKeeper bk, Flags flags) throws Exception {
byte[] data = new byte[100]; // test data
Arrays.fill(data, (byte) '1');
Copy link
Member

@zymap zymap Nov 29, 2022

Choose a reason for hiding this comment

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

Fill them randomly like how we did in pulsar-perf?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fine

.withPassword(new byte[0]).execute())) {
LedgerEntries ledgerEntries = rh.read(0, flags.numEntries);
for (LedgerEntry ledgerEntry : ledgerEntries) {
assert Arrays.equals(ledgerEntry.getEntryBytes(), data);
Copy link
Member

@zymap zymap Nov 29, 2022

Choose a reason for hiding this comment

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

The assert is more likes a developer tool not for users. We need to enable it with -ea when executing the program. Does it make more sense to log errors or throw exceptions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point.

}
result(bk.newDeleteLedgerOp().withLedgerId(wh.getId()).execute());
Copy link
Member

Choose a reason for hiding this comment

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

In Finally?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fine.

@hangc0276 hangc0276 merged commit 01232c9 into apache:master Nov 30, 2022
yaalsn pushed a commit to yaalsn/bookkeeper that referenced this pull request Jan 30, 2023
@lhotari
Copy link
Member

lhotari commented Feb 8, 2024

I'm fixing the integration tests in #4197. It seems that simpletest will always fail and has never been working.

There are at least 2 problems:

  • the last entry id parameter to the read method is invalid (off by one)
  • the LAC is updated asynchronously while the ledger is open. The read could fail if the entries aren't yet confirmed.

Fixing in lhotari@6ffda5cb since I cannot get integration tests to pass without it.
This is a sign that integration tests have been broken for a very long time on apache/bookkeeper.

Ghatage pushed a commit to sijie/bookkeeper that referenced this pull request Jul 12, 2024
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.

Enhance SimpleTest command.
5 participants