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

Update tracing setup and add more integration tests #50

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

ndelvalle
Copy link
Owner

This PR adds:

  • Run integration tests sequentially
  • Update incrby/decrby response
  • Update mget null response type
  • Gracefully handle server startup by managing global tracing setup
  • Add more integration tests

src/lib.rs Show resolved Hide resolved
tracing::subscriber::set_global_default(subscriber)?;
let _ = tracing_subscriber::fmt()
.try_init()
.map_err(|e| debug!("Failed to initialize global tracing: {}", e));
Copy link
Owner Author

Choose a reason for hiding this comment

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

We had an issue where tests couldn’t run in parallel (Multiple calls to this run fn) because the global tracing subscriber was already set. This fix checks if the global config is already set and only sets it if it hasn’t been initialized.

assert_eq!(our_response, their_response);
}

#[tokio::test]
#[serial]
Copy link
Owner Author

Choose a reason for hiding this comment

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

I think we should run all these tests one after the other and always make sure the databases are clean before each test. That way, commands like keys will give more accurate results. In the future, we could also consider using a different DB for each test, though I’m not sure if it’s worth it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like the idea of a different DB. For Redis side we could use different virtual DBs on the same instance, for Rustdis we could spin up different "instances" on different ports. Wdyt?

// p.cmd("SET")
// .arg("incr_by_key_4")
// .arg("234293482390480948029348230948");
// p.cmd("INCRBY").arg("incr_by_key_4").arg(1);
Copy link
Owner Author

Choose a reason for hiding this comment

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

@gillchristian I know you don't like commented code but I don't want to deal with these errors right now. We are returning the correct error message but the formats are a bit different. I can uncomment this and make it fail.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, not a fan of commented-out code. I would much rather have the test fail as a TODO that we have to fix.

Copy link
Collaborator

@gillchristian gillchristian left a comment

Choose a reason for hiding this comment

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

Let's use Vec<Value>. The tuples don't provide any benefits, it does still fail on run time if the member count doesn't match the actual values returned.

Comment on lines +294 to +307
type Response = (
Value,
Value,
Value,
Value,
Value,
Value,
Value,
Value,
Value,
Value,
);

test_compare::<Response>(|p| {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
type Response = (
Value,
Value,
Value,
Value,
Value,
Value,
Value,
Value,
Value,
Value,
);
test_compare::<Response>(|p| {
test_compare::<Vec<Value>>(|p| {

Comment on lines +326 to +327
type Response = (Value, Value, Value, Value, Value, Value);

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
type Response = (Value, Value, Value, Value, Value, Value);

Comment on lines +141 to +143
type Response = (Value, Value, Value, Value, Value, Value);

test_compare::<Response>(|p| {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
type Response = (Value, Value, Value, Value, Value, Value);
test_compare::<Response>(|p| {
test_compare::<Vec<Value>>(|p| {

Comment on lines +164 to +166
type Response = (Value, Value, Value, Value, Value, Value, Value);

test_compare::<Response>(|p| {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
type Response = (Value, Value, Value, Value, Value, Value, Value);
test_compare::<Response>(|p| {
test_compare::<Vec<Value>>(|p| {

Comment on lines +222 to +224
type Response = (Value, Value, Value, Value, Value, Value);

test_compare::<Response>(|p| {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
type Response = (Value, Value, Value, Value, Value, Value);
test_compare::<Response>(|p| {
test_compare::<Vec<Value>>(|p| {

Comment on lines +276 to +278
type Response = (Value, Value, Value, Value, Value, Value);

test_compare::<Response>(|p| {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
type Response = (Value, Value, Value, Value, Value, Value);
test_compare::<Response>(|p| {
test_compare::<Vec<Value>>(|p| {

@gillchristian gillchristian merged commit e222155 into master Aug 23, 2024
2 checks passed
@gillchristian gillchristian deleted the more-integrations-tests branch August 23, 2024 07:59
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.

2 participants