Skip to content

Commit

Permalink
Fix test_aborted_transaction.
Browse files Browse the repository at this point in the history
  • Loading branch information
ISibboI committed Dec 10, 2023
1 parent 9fe83bc commit 7e52301
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions backend/rvoc-backend/src/integration_tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::time::Duration;

use tokio::time::sleep;
use tracing::instrument;
use tracing::{info, instrument};

use crate::configuration::Configuration;
use crate::database::create_async_database_connection_pool;
Expand Down Expand Up @@ -41,6 +41,8 @@ async fn test_aborted_transaction(configuration: &Configuration) -> RVocResult<(
)
.await?;

info!("Test table set up successfully");

// Trigger a serialisation failure
let (first, second) = tokio::join!(
database_connection_pool.execute_transaction::<_, RVocError>(
Expand Down Expand Up @@ -69,7 +71,7 @@ async fn test_aborted_transaction(configuration: &Configuration) -> RVocResult<(

Ok(())
}),
2
0
),
database_connection_pool.execute_transaction::<_, RVocError>(
|database_connection| Box::pin(async move {
Expand Down Expand Up @@ -97,12 +99,22 @@ async fn test_aborted_transaction(configuration: &Configuration) -> RVocResult<(

Ok(())
}),
2
0
),
);

first?;
second?;
info!("Serialisation failure should have triggered");
info!("First result: {first:?}");
info!("Second result: {second:?}");
assert!(
matches!(
first,
Err(RVocError::DatabaseTransactionRetryLimitReached { .. })
) || matches!(
second,
Err(RVocError::DatabaseTransactionRetryLimitReached { .. })
)
);

// Ensure that we can still do transactions on the same data
database_connection_pool
Expand Down Expand Up @@ -131,5 +143,7 @@ async fn test_aborted_transaction(configuration: &Configuration) -> RVocResult<(
)
.await?;

todo!()
info!("Success! Transactions still work after serialisation failure");

Ok(())
}

0 comments on commit 7e52301

Please sign in to comment.