소스 검색

模拟崩溃测试综合版

pull/2/head
augurier 8 달 전
부모
커밋
ea3d7c31f5
1개의 변경된 파일11개의 추가작업 그리고 7개의 파일을 삭제
  1. +11
    -7
      test/recover_test.cc

+ 11
- 7
test/recover_test.cc 파일 보기

@ -36,7 +36,7 @@ TEST(TestNormalRecover, Recover) {
findKeysByAgeIndex(db, true); findKeysByAgeIndex(db, true);
} }
TEST(TestParalPutRecover, Recover) {
TEST(TestParalRecover, Recover) {
//第一次运行 //第一次运行
// fielddb::DestroyDB("testdb3.2",Options()); // fielddb::DestroyDB("testdb3.2",Options());
// FieldDB *db = new FieldDB(); // FieldDB *db = new FieldDB();
@ -47,24 +47,28 @@ TEST(TestParalPutRecover, Recover) {
// } // }
// db->CreateIndexOnField("address"); // db->CreateIndexOnField("address");
// db->CreateIndexOnField("age"); // db->CreateIndexOnField("age");
// shanghaiKeys.clear();
// age20Keys.clear();
// int thread_num_ = 2;
// int thread_num_ = 4;
// std::vector<std::thread> threads(thread_num_); // std::vector<std::thread> threads(thread_num_);
// threads[0] = std::thread([db](){ // threads[0] = std::thread([db](){
// InsertFieldData(db); // InsertFieldData(db);
// }); // });
// threads[1] = std::thread([db](){ // threads[1] = std::thread([db](){
// WriteFieldData(db);
// });
// threads[2] = std::thread([db](){
// DeleteFieldData(db);
// });
// threads[3] = std::thread([db](){
// InsertOneField(db); // InsertOneField(db);
// delete db; // delete db;
// }); // });
// for (auto& t : threads) {
// for (auto& t : threads) {
// if (t.joinable()) { // if (t.joinable()) {
// t.join(); // t.join();
// } // }
// } // }
//线程1导致了线程0错误,测试会终止(模拟数据库崩溃)
//这会导致线程0写入的各种奇怪的时间点崩溃
//线程3导致了其他线程错误,测试会终止(模拟数据库崩溃)
//这会导致线程在各种奇怪的时间点崩溃
//第二次运行注释掉上面的代码,运行下面的代码测试恢复 //第二次运行注释掉上面的代码,运行下面的代码测试恢复

불러오는 중...
취소
저장