Skip to content

Conversation

adiholden
Copy link
Contributor

  1. Add test utility class that will add suspension to transaction execution.
  2. Add test for locked keys in transaction

1. add test utility class that will add suspension to transaction
   execution.
2. add test for locked keys in transaction

Signed-off-by: adi_holden <[email protected]>
Signed-off-by: adi_holden <[email protected]>
@adiholden adiholden requested review from chakaz and dranikpg August 8, 2023 19:27
dranikpg
dranikpg previously approved these changes Aug 8, 2023
Copy link
Contributor

@dranikpg dranikpg left a comment

Choose a reason for hiding this comment

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

Great, I imagined it in a similar way.

Just as an idea: For other tests to use it it'd be convenient if the TransactionSuspension would itself start a fiber and loops, so you could do

auto lock_check = CheckWillBeLocked("key", ...) // starts fiber and lets go once locks are rightly acquired
Run(mycmd)

But as the only user (or not?) are cluster tests its all open for you to decide 🙂


void TransactionSuspension::Start() {
CommandId cid{"TEST", CO::WRITE | CO::GLOBAL_TRANS, -1, 0, 0, 0};
transaction_.reset(new dfly::Transaction{&cid});
Copy link
Contributor

Choose a reason for hiding this comment

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

Use make_unique() 🙏

Comment on lines 820 to 825
for (int i = 0; i < 1000; ++i) {
if (service_->IsLocked(0, "key1") && service_->IsLocked(0, "key2")) {
break;
}
ThisFiber::SleepFor(1ms);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We use this hack in many places, maybe move ExpectConditionWithinTimeout to test_utils.h and use it here?

Copy link
Contributor

Choose a reason for hiding this comment

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

This has the advantage of failing the test in the case of a timeout, because right now even if TransactionSuspension does nothing, the test will still pass

Signed-off-by: adi_holden <[email protected]>
chakaz
chakaz previously approved these changes Aug 9, 2023
Signed-off-by: adi_holden <[email protected]>
chakaz
chakaz previously approved these changes Aug 9, 2023
@adiholden adiholden enabled auto-merge (squash) August 9, 2023 12:07
Signed-off-by: adi_holden <[email protected]>
Comment on lines +106 to +108
./dragonfly_test
./multi_test --multi_exec_mode=1
./multi_test --multi_exec_mode=3
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider moving these to the daily instead

@adiholden adiholden merged commit f9a3e28 into main Aug 9, 2023
@adiholden adiholden deleted the tx_suspension_test branch August 9, 2023 12:52
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.

4 participants