tests/concurrency/isolation_level_test.cpp
// FIXME: CONCURRENCY_TYPE_SPECULATIVE_READ can't pass it for now
CONCURRENCY_TYPE_SPECULATIVE_READ can't pass it for now
CONCURRENCY_TYPE_SPECULATIVE_READ can ' t pass it for now
TEST_F(IsolationLevelTest, StressTest) {
  const int num_txn = 16;
  const int scale = 20;
  const int num_key = 256;
  srand(15721);
  for (auto test_type : TEST_TYPES) {
    concurrency::TransactionManagerFactory::Configure(
        test_type, ISOLATION_LEVEL_TYPE_FULL);
    std::unique_ptr<storage::DataTable> table(
        TransactionTestsUtil::CreateTable(num_key));
    auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
    TransactionScheduler scheduler(num_txn, table.get(), &txn_manager);
    scheduler.SetConcurrent(true);
    for (int i = 0; i < num_txn; i++) {
      for (int j = 0; j < scale; j++) {
        int key1 = rand() % num_key;
        int key2 = rand() % num_key;
        int delta = rand() % 1000;
        scheduler.Txn(i).ReadStore(key1, -delta);
        scheduler.Txn(i).Update(key1, TXN_STORED_VALUE);
        scheduler.Txn(i).ReadStore(key2, delta);
        scheduler.Txn(i).Update(key2, TXN_STORED_VALUE);
      }
      scheduler.Txn(i).Commit();
    }
    scheduler.Run();
    TransactionScheduler scheduler2(1, table.get(), &txn_manager);
    for (int i = 0; i < num_key; i++) {
      scheduler2.Txn(0).Read(i);
    }
    scheduler2.Txn(0).Commit();
    scheduler2.Run();
    int sum = 0;
    for (auto result : scheduler2.schedules[0].results) {
      sum += result;
    }
    EXPECT_EQ(0, sum);
    int nabort = 0;
    for (auto &schedule : scheduler.schedules) {
      if (schedule.txn_result == RESULT_ABORTED) nabort += 1;
    }
    LOG_INFO("Abort: %d out of %d", nabort, num_txn);
  }
}
TEST_F ( IsolationLevelTest , StressTest ) { const int num_txn = 16 ; const int scale = 20 ; const int num_key = 256 ; srand ( 15721 ) ; for ( auto test_type : TEST_TYPES ) { concurrency :: TransactionManagerFactory :: Configure ( test_type , ISOLATION_LEVEL_TYPE_FULL ) ; std :: unique_ptr < storage :: DataTable > table ( TransactionTestsUtil :: CreateTable ( num_key ) ) ; auto & txn_manager = concurrency :: TransactionManagerFactory :: GetInstance ( ) ; TransactionScheduler scheduler ( num_txn , table . get ( ) , & txn_manager ) ; scheduler . SetConcurrent ( true ) ; for ( int i = 0 ; i < num_txn ; i ++ ) { for ( int j = 0 ; j < scale ; j ++ ) { int key1 = rand ( ) % num_key ; int key2 = rand ( ) % num_key ; int delta = rand ( ) % 1000 ; scheduler . Txn ( i ) . ReadStore ( key1 , - delta ) ; scheduler . Txn ( i ) . Update ( key1 , TXN_STORED_VALUE ) ; scheduler . Txn ( i ) . ReadStore ( key2 , delta ) ; scheduler . Txn ( i ) . Update ( key2 , TXN_STORED_VALUE ) ; } scheduler . Txn ( i ) . Commit ( ) ; } scheduler . Run ( ) ; TransactionScheduler scheduler2 ( 1 , table . get ( ) , & txn_manager ) ; for ( int i = 0 ; i < num_key ; i ++ ) { scheduler2 . Txn ( 0 ) . Read ( i ) ; } scheduler2 . Txn ( 0 ) . Commit ( ) ; scheduler2 . Run ( ) ; int sum = 0 ; for ( auto result : scheduler2 . schedules [ 0 ] . results ) { sum += result ; } EXPECT_EQ ( 0 , sum ) ; int nabort = 0 ; for ( auto & schedule : scheduler . schedules ) { if ( schedule . txn_result == RESULT_ABORTED ) nabort += 1 ; } LOG_INFO ( " " , nabort , num_txn ) ; } }
FIXME: CONCURRENCY_TYPE_SPECULATIVE_READ can't pass it for now
FIXME : CONCURRENCY_TYPE_SPECULATIVE_READ can ' t pass it for now
// randomly select two uniq keys // Store substracted value // Store increased value // Read all values // The sum should be zero // stats