Skip to content

Commit 0241819

Browse files
mrambacherfacebook-github-bot
authored andcommitted
Add more tests for assert status checked (facebook#7524)
Summary: Added 10 more tests that pass the ASSERT_STATUS_CHECKED test. Pull Request resolved: facebook#7524 Reviewed By: akankshamahajan15 Differential Revision: D24323093 Pulled By: ajkr fbshipit-source-id: 28d4106d0ca1740c3b896c755edf82d504b74801
1 parent daab760 commit 0241819

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+487
-384
lines changed

Makefile

+33
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ ifdef ASSERT_STATUS_CHECKED
587587
blob_file_reader_test \
588588
bloom_test \
589589
cassandra_format_test \
590+
cassandra_functional_test \
590591
cassandra_row_merge_test \
591592
cassandra_serialize_test \
592593
cleanable_test \
@@ -595,6 +596,14 @@ ifdef ASSERT_STATUS_CHECKED
595596
crc32c_test \
596597
dbformat_test \
597598
db_basic_test \
599+
compact_files_test \
600+
compaction_picker_test \
601+
comparator_db_test \
602+
db_encryption_test \
603+
db_iter_test \
604+
db_iter_stress_test \
605+
db_log_iter_test \
606+
db_bloom_filter_test \
598607
db_blob_basic_test \
599608
db_blob_index_test \
600609
db_block_cache_test \
@@ -615,6 +624,19 @@ ifdef ASSERT_STATUS_CHECKED
615624
deletefile_test \
616625
external_sst_file_test \
617626
options_file_test \
627+
db_statistics_test \
628+
db_table_properties_test \
629+
db_tailing_iter_test \
630+
fault_injection_test \
631+
listener_test \
632+
log_test \
633+
manual_compaction_test \
634+
obsolete_files_test \
635+
perf_context_test \
636+
periodic_work_scheduler_test \
637+
perf_context_test \
638+
version_set_test \
639+
wal_manager_test \
618640
defer_test \
619641
filename_test \
620642
dynamic_bloom_test \
@@ -658,6 +680,7 @@ ifdef ASSERT_STATUS_CHECKED
658680
ribbon_test \
659681
skiplist_test \
660682
slice_test \
683+
slice_transform_test \
661684
sst_dump_test \
662685
statistics_test \
663686
stats_history_test \
@@ -694,13 +717,23 @@ ifdef ASSERT_STATUS_CHECKED
694717
flush_job_test \
695718
block_based_filter_block_test \
696719
block_fetcher_test \
720+
block_test \
721+
data_block_hash_index_test \
697722
full_filter_block_test \
698723
partitioned_filter_block_test \
699724
column_family_test \
700725
file_reader_writer_test \
726+
rate_limiter_test \
701727
corruption_test \
728+
reduce_levels_test \
729+
thread_list_test \
730+
compact_on_deletion_collector_test \
702731
db_universal_compaction_test \
703732
import_column_family_test \
733+
option_change_migration_test \
734+
cuckoo_table_builder_test \
735+
cuckoo_table_db_test \
736+
cuckoo_table_reader_test \
704737
memory_test \
705738
table_test \
706739
write_batch_test \

db/compact_files_test.cc

+28-25
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ TEST_F(CompactFilesTest, L0ConflictsFiles) {
9191
// create couple files
9292
// Background compaction starts and waits in BackgroundCallCompaction:0
9393
for (int i = 0; i < kLevel0Trigger * 4; ++i) {
94-
db->Put(WriteOptions(), ToString(i), "");
95-
db->Put(WriteOptions(), ToString(100 - i), "");
96-
db->Flush(FlushOptions());
94+
ASSERT_OK(db->Put(WriteOptions(), ToString(i), ""));
95+
ASSERT_OK(db->Put(WriteOptions(), ToString(100 - i), ""));
96+
ASSERT_OK(db->Flush(FlushOptions()));
9797
}
9898

9999
ROCKSDB_NAMESPACE::ColumnFamilyMetaData meta;
@@ -138,18 +138,18 @@ TEST_F(CompactFilesTest, ObsoleteFiles) {
138138
DB* db = nullptr;
139139
DestroyDB(db_name_, options);
140140
Status s = DB::Open(options, db_name_, &db);
141-
assert(s.ok());
142-
assert(db);
141+
ASSERT_OK(s);
142+
ASSERT_NE(db, nullptr);
143143

144144
// create couple files
145145
for (int i = 1000; i < 2000; ++i) {
146-
db->Put(WriteOptions(), ToString(i),
147-
std::string(kWriteBufferSize / 10, 'a' + (i % 26)));
146+
ASSERT_OK(db->Put(WriteOptions(), ToString(i),
147+
std::string(kWriteBufferSize / 10, 'a' + (i % 26))));
148148
}
149149

150150
auto l0_files = collector->GetFlushedFiles();
151151
ASSERT_OK(db->CompactFiles(CompactionOptions(), l0_files, 1));
152-
static_cast_with_check<DBImpl>(db)->TEST_WaitForCompact();
152+
ASSERT_OK(static_cast_with_check<DBImpl>(db)->TEST_WaitForCompact());
153153

154154
// verify all compaction input files are deleted
155155
for (auto fname : l0_files) {
@@ -182,15 +182,17 @@ TEST_F(CompactFilesTest, NotCutOutputOnLevel0) {
182182

183183
// create couple files
184184
for (int i = 0; i < 500; ++i) {
185-
db->Put(WriteOptions(), ToString(i), std::string(1000, 'a' + (i % 26)));
185+
ASSERT_OK(db->Put(WriteOptions(), ToString(i),
186+
std::string(1000, 'a' + (i % 26))));
186187
}
187-
static_cast_with_check<DBImpl>(db)->TEST_WaitForFlushMemTable();
188+
ASSERT_OK(static_cast_with_check<DBImpl>(db)->TEST_WaitForFlushMemTable());
188189
auto l0_files_1 = collector->GetFlushedFiles();
189190
collector->ClearFlushedFiles();
190191
for (int i = 0; i < 500; ++i) {
191-
db->Put(WriteOptions(), ToString(i), std::string(1000, 'a' + (i % 26)));
192+
ASSERT_OK(db->Put(WriteOptions(), ToString(i),
193+
std::string(1000, 'a' + (i % 26))));
192194
}
193-
static_cast_with_check<DBImpl>(db)->TEST_WaitForFlushMemTable();
195+
ASSERT_OK(static_cast_with_check<DBImpl>(db)->TEST_WaitForFlushMemTable());
194196
auto l0_files_2 = collector->GetFlushedFiles();
195197
ASSERT_OK(db->CompactFiles(CompactionOptions(), l0_files_1, 0));
196198
ASSERT_OK(db->CompactFiles(CompactionOptions(), l0_files_2, 0));
@@ -213,13 +215,13 @@ TEST_F(CompactFilesTest, CapturingPendingFiles) {
213215
DB* db = nullptr;
214216
DestroyDB(db_name_, options);
215217
Status s = DB::Open(options, db_name_, &db);
216-
assert(s.ok());
218+
ASSERT_OK(s);
217219
assert(db);
218220

219221
// Create 5 files.
220222
for (int i = 0; i < 5; ++i) {
221-
db->Put(WriteOptions(), "key" + ToString(i), "value");
222-
db->Flush(FlushOptions());
223+
ASSERT_OK(db->Put(WriteOptions(), "key" + ToString(i), "value"));
224+
ASSERT_OK(db->Flush(FlushOptions()));
223225
}
224226

225227
auto l0_files = collector->GetFlushedFiles();
@@ -237,8 +239,8 @@ TEST_F(CompactFilesTest, CapturingPendingFiles) {
237239

238240
// In the meantime flush another file.
239241
TEST_SYNC_POINT("CompactFilesTest.CapturingPendingFiles:0");
240-
db->Put(WriteOptions(), "key5", "value");
241-
db->Flush(FlushOptions());
242+
ASSERT_OK(db->Put(WriteOptions(), "key5", "value"));
243+
ASSERT_OK(db->Flush(FlushOptions()));
242244
TEST_SYNC_POINT("CompactFilesTest.CapturingPendingFiles:1");
243245

244246
compaction_thread.join();
@@ -249,7 +251,7 @@ TEST_F(CompactFilesTest, CapturingPendingFiles) {
249251

250252
// Make sure we can reopen the DB.
251253
s = DB::Open(options, db_name_, &db);
252-
ASSERT_TRUE(s.ok());
254+
ASSERT_OK(s);
253255
assert(db);
254256
delete db;
255257
}
@@ -293,8 +295,8 @@ TEST_F(CompactFilesTest, CompactionFilterWithGetSv) {
293295
cf->SetDB(db);
294296

295297
// Write one L0 file
296-
db->Put(WriteOptions(), "K1", "V1");
297-
db->Flush(FlushOptions());
298+
ASSERT_OK(db->Put(WriteOptions(), "K1", "V1"));
299+
ASSERT_OK(db->Flush(FlushOptions()));
298300

299301
// Compact all L0 files using CompactFiles
300302
ROCKSDB_NAMESPACE::ColumnFamilyMetaData meta;
@@ -337,8 +339,8 @@ TEST_F(CompactFilesTest, SentinelCompressionType) {
337339
DB* db = nullptr;
338340
ASSERT_OK(DB::Open(options, db_name_, &db));
339341

340-
db->Put(WriteOptions(), "key", "val");
341-
db->Flush(FlushOptions());
342+
ASSERT_OK(db->Put(WriteOptions(), "key", "val"));
343+
ASSERT_OK(db->Flush(FlushOptions()));
342344

343345
auto l0_files = collector->GetFlushedFiles();
344346
ASSERT_EQ(1, l0_files.size());
@@ -377,14 +379,15 @@ TEST_F(CompactFilesTest, GetCompactionJobInfo) {
377379
DB* db = nullptr;
378380
DestroyDB(db_name_, options);
379381
Status s = DB::Open(options, db_name_, &db);
380-
assert(s.ok());
382+
ASSERT_OK(s);
381383
assert(db);
382384

383385
// create couple files
384386
for (int i = 0; i < 500; ++i) {
385-
db->Put(WriteOptions(), ToString(i), std::string(1000, 'a' + (i % 26)));
387+
ASSERT_OK(db->Put(WriteOptions(), ToString(i),
388+
std::string(1000, 'a' + (i % 26))));
386389
}
387-
static_cast_with_check<DBImpl>(db)->TEST_WaitForFlushMemTable();
390+
ASSERT_OK(static_cast_with_check<DBImpl>(db)->TEST_WaitForFlushMemTable());
388391
auto l0_files_1 = collector->GetFlushedFiles();
389392
CompactionOptions co;
390393
co.compression = CompressionType::kLZ4Compression;

db/compaction/compaction_picker_test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class CompactionPickerTest : public testing::Test {
141141
if (temp_vstorage_) {
142142
VersionBuilder builder(FileOptions(), &ioptions_, nullptr,
143143
vstorage_.get(), nullptr);
144-
builder.SaveTo(temp_vstorage_.get());
144+
ASSERT_OK(builder.SaveTo(temp_vstorage_.get()));
145145
vstorage_ = std::move(temp_vstorage_);
146146
}
147147
vstorage_->CalculateBaseBytes(ioptions_, mutable_cf_options_);

db/cuckoo_table_db_test.cc

+20-20
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ TEST_F(CuckooTableDBTest, Flush) {
129129
ASSERT_OK(Put("key1", "v1"));
130130
ASSERT_OK(Put("key2", "v2"));
131131
ASSERT_OK(Put("key3", "v3"));
132-
dbfull()->TEST_FlushMemTable();
132+
ASSERT_OK(dbfull()->TEST_FlushMemTable());
133133

134134
TablePropertiesCollection ptc;
135-
reinterpret_cast<DB*>(dbfull())->GetPropertiesOfAllTables(&ptc);
135+
ASSERT_OK(reinterpret_cast<DB*>(dbfull())->GetPropertiesOfAllTables(&ptc));
136136
ASSERT_EQ(1U, ptc.size());
137137
ASSERT_EQ(3U, ptc.begin()->second->num_entries);
138138
ASSERT_EQ("1", FilesPerLevel());
@@ -146,9 +146,9 @@ TEST_F(CuckooTableDBTest, Flush) {
146146
ASSERT_OK(Put("key4", "v4"));
147147
ASSERT_OK(Put("key5", "v5"));
148148
ASSERT_OK(Put("key6", "v6"));
149-
dbfull()->TEST_FlushMemTable();
149+
ASSERT_OK(dbfull()->TEST_FlushMemTable());
150150

151-
reinterpret_cast<DB*>(dbfull())->GetPropertiesOfAllTables(&ptc);
151+
ASSERT_OK(reinterpret_cast<DB*>(dbfull())->GetPropertiesOfAllTables(&ptc));
152152
ASSERT_EQ(2U, ptc.size());
153153
auto row = ptc.begin();
154154
ASSERT_EQ(3U, row->second->num_entries);
@@ -164,8 +164,8 @@ TEST_F(CuckooTableDBTest, Flush) {
164164
ASSERT_OK(Delete("key6"));
165165
ASSERT_OK(Delete("key5"));
166166
ASSERT_OK(Delete("key4"));
167-
dbfull()->TEST_FlushMemTable();
168-
reinterpret_cast<DB*>(dbfull())->GetPropertiesOfAllTables(&ptc);
167+
ASSERT_OK(dbfull()->TEST_FlushMemTable());
168+
ASSERT_OK(reinterpret_cast<DB*>(dbfull())->GetPropertiesOfAllTables(&ptc));
169169
ASSERT_EQ(3U, ptc.size());
170170
row = ptc.begin();
171171
ASSERT_EQ(3U, row->second->num_entries);
@@ -186,10 +186,10 @@ TEST_F(CuckooTableDBTest, FlushWithDuplicateKeys) {
186186
ASSERT_OK(Put("key1", "v1"));
187187
ASSERT_OK(Put("key2", "v2"));
188188
ASSERT_OK(Put("key1", "v3")); // Duplicate
189-
dbfull()->TEST_FlushMemTable();
189+
ASSERT_OK(dbfull()->TEST_FlushMemTable());
190190

191191
TablePropertiesCollection ptc;
192-
reinterpret_cast<DB*>(dbfull())->GetPropertiesOfAllTables(&ptc);
192+
ASSERT_OK(reinterpret_cast<DB*>(dbfull())->GetPropertiesOfAllTables(&ptc));
193193
ASSERT_EQ(1U, ptc.size());
194194
ASSERT_EQ(2U, ptc.begin()->second->num_entries);
195195
ASSERT_EQ("1", FilesPerLevel());
@@ -219,7 +219,7 @@ TEST_F(CuckooTableDBTest, Uint64Comparator) {
219219
ASSERT_OK(Put(Uint64Key(1), "v1"));
220220
ASSERT_OK(Put(Uint64Key(2), "v2"));
221221
ASSERT_OK(Put(Uint64Key(3), "v3"));
222-
dbfull()->TEST_FlushMemTable();
222+
ASSERT_OK(dbfull()->TEST_FlushMemTable());
223223

224224
ASSERT_EQ("v1", Get(Uint64Key(1)));
225225
ASSERT_EQ("v2", Get(Uint64Key(2)));
@@ -228,10 +228,10 @@ TEST_F(CuckooTableDBTest, Uint64Comparator) {
228228

229229
// Add more keys.
230230
ASSERT_OK(Delete(Uint64Key(2))); // Delete.
231-
dbfull()->TEST_FlushMemTable();
231+
ASSERT_OK(dbfull()->TEST_FlushMemTable());
232232
ASSERT_OK(Put(Uint64Key(3), "v0")); // Update.
233233
ASSERT_OK(Put(Uint64Key(4), "v4"));
234-
dbfull()->TEST_FlushMemTable();
234+
ASSERT_OK(dbfull()->TEST_FlushMemTable());
235235
ASSERT_EQ("v1", Get(Uint64Key(1)));
236236
ASSERT_EQ("NOT_FOUND", Get(Uint64Key(2)));
237237
ASSERT_EQ("v0", Get(Uint64Key(3)));
@@ -251,11 +251,11 @@ TEST_F(CuckooTableDBTest, CompactionIntoMultipleFiles) {
251251
for (int idx = 0; idx < 28; ++idx) {
252252
ASSERT_OK(Put(Key(idx), std::string(10000, 'a' + char(idx))));
253253
}
254-
dbfull()->TEST_WaitForFlushMemTable();
254+
ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable());
255255
ASSERT_EQ("1", FilesPerLevel());
256256

257-
dbfull()->TEST_CompactRange(0, nullptr, nullptr, nullptr,
258-
true /* disallow trivial move */);
257+
ASSERT_OK(dbfull()->TEST_CompactRange(0, nullptr, nullptr, nullptr,
258+
true /* disallow trivial move */));
259259
ASSERT_EQ("0,2", FilesPerLevel());
260260
for (int idx = 0; idx < 28; ++idx) {
261261
ASSERT_EQ(std::string(10000, 'a' + char(idx)), Get(Key(idx)));
@@ -274,15 +274,15 @@ TEST_F(CuckooTableDBTest, SameKeyInsertedInTwoDifferentFilesAndCompacted) {
274274
for (int idx = 0; idx < 11; ++idx) {
275275
ASSERT_OK(Put(Key(idx), std::string(10000, 'a')));
276276
}
277-
dbfull()->TEST_WaitForFlushMemTable();
277+
ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable());
278278
ASSERT_EQ("1", FilesPerLevel());
279279

280280
// Generate one more file in level-0, and should trigger level-0 compaction
281281
for (int idx = 0; idx < 11; ++idx) {
282282
ASSERT_OK(Put(Key(idx), std::string(10000, 'a' + char(idx))));
283283
}
284-
dbfull()->TEST_WaitForFlushMemTable();
285-
dbfull()->TEST_CompactRange(0, nullptr, nullptr);
284+
ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable());
285+
ASSERT_OK(dbfull()->TEST_CompactRange(0, nullptr, nullptr));
286286

287287
ASSERT_EQ("0,1", FilesPerLevel());
288288
for (int idx = 0; idx < 11; ++idx) {
@@ -303,7 +303,7 @@ TEST_F(CuckooTableDBTest, AdaptiveTable) {
303303
ASSERT_OK(Put("key1", "v1"));
304304
ASSERT_OK(Put("key2", "v2"));
305305
ASSERT_OK(Put("key3", "v3"));
306-
dbfull()->TEST_FlushMemTable();
306+
ASSERT_OK(dbfull()->TEST_FlushMemTable());
307307

308308
// Write some keys using plain table.
309309
std::shared_ptr<TableFactory> block_based_factory(
@@ -319,7 +319,7 @@ TEST_F(CuckooTableDBTest, AdaptiveTable) {
319319
Reopen(&options);
320320
ASSERT_OK(Put("key4", "v4"));
321321
ASSERT_OK(Put("key1", "v5"));
322-
dbfull()->TEST_FlushMemTable();
322+
ASSERT_OK(dbfull()->TEST_FlushMemTable());
323323

324324
// Write some keys using block based table.
325325
options.table_factory.reset(NewAdaptiveTableFactory(
@@ -328,7 +328,7 @@ TEST_F(CuckooTableDBTest, AdaptiveTable) {
328328
Reopen(&options);
329329
ASSERT_OK(Put("key5", "v6"));
330330
ASSERT_OK(Put("key2", "v7"));
331-
dbfull()->TEST_FlushMemTable();
331+
ASSERT_OK(dbfull()->TEST_FlushMemTable());
332332

333333
ASSERT_EQ("v5", Get("key1"));
334334
ASSERT_EQ("v7", Get("key2"));

0 commit comments

Comments
 (0)