Skip to content

add sync API characterization tests - #211

Open
harunugurlu wants to merge 5 commits into
aimdb-dev:mainfrom
harunugurlu:feat/198-non-blocking-api-characterization-tests
Open

add sync API characterization tests#211
harunugurlu wants to merge 5 commits into
aimdb-dev:mainfrom
harunugurlu:feat/198-non-blocking-api-characterization-tests

Conversation

@harunugurlu

Copy link
Copy Markdown
Collaborator

Summary

  • characterize blocking get() wake-up behavior
  • characterize timeout and successful get_with_timeout() behavior
  • characterize empty and pending try_get() behavior
  • verify ordering and no loss across repeated blocking gets
  • verify blocked consumers return RuntimeShutdown during detach

Verification

  • cargo fmt --all -- --check
  • cargo clippy --package aimdb-sync --all-targets -- -D warnings
  • cargo test -p aimdb-sync
  • make check

Closes #198

@harunugurlu
harunugurlu requested a review from lxsaah as a code owner August 8, 2026 13:52
@harunugurlu

Copy link
Copy Markdown
Collaborator Author

@lxsaah Hi, I'm sorry that it took this long for me to do the work. Been extremely busy with my full-time work. I am waiting for your review, thanks!!

@lxsaah

lxsaah commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

@lxsaah Hi, I'm sorry that it took this long for me to do the work. Been extremely busy with my full-time work. I am waiting for your review, thanks!!

@harunugurlu, don't worry. Thanks a lot for your contribution! I'll have a look as soon as #208 lands. Meanwhile please ensure the the workflows are running successfully. make fmt should fix it!

@lxsaah lxsaah left a comment

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 rest holds up, the mpsc handshake is the right answer to the issue's "no sleep-and-hope" constraint. It also passes unmodified against pre-#208, which makes it evidence the rewrite preserved the blocking semantics. Happy to approve once the two items are in.

});

// Join producer thread
producer_handle.join().unwrap();

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 producer thread is joined before the consumer thread is spawned, so all ten values are already buffered and every get() returns immediately. Issue #198 asks for ordering and no-loss on the blocking path. Let's spawn the consumer first and produce afterwards, using the same ready-signal handshake as the other tests.

.expect("Failed to create consumer");

// Create consumer thread and try get the value
let consumer_no_val_handler = thread::spawn(move || consumer_no_val.try_get());

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.

Both halves of test_consumer_try_get only check the returned value, so a try_get that regressed into get_with_timeout(Duration::from_secs(5)) would still pass. Wrap the empty-buffer call in Instant::now() and assert a loose upper bound (~250 ms) to pin the property the issue actually names.

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.

aimdb-sync: characterization tests for the blocking API

2 participants