diff --git a/db/db_write_test.cc b/db/db_write_test.cc index 0c13cb81f..84fa34717 100644 --- a/db/db_write_test.cc +++ b/db/db_write_test.cc @@ -19,6 +19,7 @@ #include "util/random.h" #include "util/string_util.h" #include "utilities/fault_injection_env.h" +#include "utilities/fault_injection_fs.h" namespace ROCKSDB_NAMESPACE { @@ -608,10 +609,15 @@ TEST_P(DBWriteTest, IOErrorOnSwitchMemtable) { // Test that db->LockWAL() flushes the WAL after locking, which can fail TEST_P(DBWriteTest, LockWALInEffect) { + if (mem_env_ || encrypted_env_) { + ROCKSDB_GTEST_SKIP("Test requires non-mem or non-encrypted environment"); + return; + } Options options = GetOptions(); - std::unique_ptr mock_env( - new FaultInjectionTestEnv(env_)); - options.env = mock_env.get(); + std::shared_ptr fault_fs( + new FaultInjectionTestFS(FileSystem::Default())); + std::unique_ptr fault_fs_env(NewCompositeEnv(fault_fs)); + options.env = fault_fs_env.get(); options.disable_auto_compactions = true; options.paranoid_checks = false; Reopen(options); @@ -630,7 +636,7 @@ TEST_P(DBWriteTest, LockWALInEffect) { ASSERT_OK(db_->UnlockWAL()); // Fail the WAL flush if applicable - mock_env->SetFilesystemActive(false); + fault_fs->SetFilesystemActive(false); Status s = Put("key2", "value"); if (options.manual_wal_flush) { ASSERT_OK(s); @@ -642,7 +648,7 @@ TEST_P(DBWriteTest, LockWALInEffect) { ASSERT_OK(db_->LockWAL()); ASSERT_OK(db_->UnlockWAL()); } - mock_env->SetFilesystemActive(true); + fault_fs->SetFilesystemActive(true); // Writes should work again ASSERT_OK(Put("key3", "value")); ASSERT_EQ(Get("key3"), "value");