Add tests in ASSERT_STATUS_CHECKED (#7793)
Summary: add io_tracer_parser_test and prefetch_test under ASSERT_STATUS_CHECKED Pull Request resolved: https://github.com/facebook/rocksdb/pull/7793 Test Plan: ASSERT_STATUS_CHECKED=1 make check -j64 Reviewed By: jay-zhuang Differential Revision: D25673464 Pulled By: akankshamahajan15 fbshipit-source-id: 50e0b6f17160ddda206a521a7b47ee33e699a2d4
This commit is contained in:
parent
4d897e51df
commit
fbac1b3f80
2
Makefile
2
Makefile
@ -678,6 +678,8 @@ ifdef ASSERT_STATUS_CHECKED
|
||||
compaction_job_test \
|
||||
compaction_job_stats_test \
|
||||
io_tracer_test \
|
||||
io_tracer_parser_test \
|
||||
prefetch_test \
|
||||
merge_helper_test \
|
||||
memtable_list_test \
|
||||
flush_job_test \
|
||||
|
@ -109,21 +109,21 @@ TEST_P(PrefetchTest, Basic) {
|
||||
// create first key range
|
||||
WriteBatch batch;
|
||||
for (int i = 0; i < kNumKeys; i++) {
|
||||
batch.Put(BuildKey(i), "value for range 1 key");
|
||||
ASSERT_OK(batch.Put(BuildKey(i), "value for range 1 key"));
|
||||
}
|
||||
ASSERT_OK(db_->Write(WriteOptions(), &batch));
|
||||
|
||||
// create second key range
|
||||
batch.Clear();
|
||||
for (int i = 0; i < kNumKeys; i++) {
|
||||
batch.Put(BuildKey(i, "key2"), "value for range 2 key");
|
||||
ASSERT_OK(batch.Put(BuildKey(i, "key2"), "value for range 2 key"));
|
||||
}
|
||||
ASSERT_OK(db_->Write(WriteOptions(), &batch));
|
||||
|
||||
// delete second key range
|
||||
batch.Clear();
|
||||
for (int i = 0; i < kNumKeys; i++) {
|
||||
batch.Delete(BuildKey(i, "key2"));
|
||||
ASSERT_OK(batch.Delete(BuildKey(i, "key2")));
|
||||
}
|
||||
ASSERT_OK(db_->Write(WriteOptions(), &batch));
|
||||
|
||||
@ -134,7 +134,7 @@ TEST_P(PrefetchTest, Basic) {
|
||||
Slice greatest(end_key.data(), end_key.size());
|
||||
|
||||
// commenting out the line below causes the example to work correctly
|
||||
db_->CompactRange(CompactRangeOptions(), &least, &greatest);
|
||||
ASSERT_OK(db_->CompactRange(CompactRangeOptions(), &least, &greatest));
|
||||
|
||||
if (support_prefetch && !use_direct_io) {
|
||||
// If underline file system supports prefetch, and directIO is not enabled
|
||||
|
@ -215,14 +215,15 @@ void IOTracer::EndIOTrace() {
|
||||
tracing_enabled = false;
|
||||
}
|
||||
|
||||
Status IOTracer::WriteIOOp(const IOTraceRecord& record) {
|
||||
// TODO: Return status and handle that in file_system_tracer.h
|
||||
void IOTracer::WriteIOOp(const IOTraceRecord& record) {
|
||||
if (!writer_.load()) {
|
||||
return Status::OK();
|
||||
return;
|
||||
}
|
||||
InstrumentedMutexLock lock_guard(&trace_writer_mutex_);
|
||||
if (!writer_.load()) {
|
||||
return Status::OK();
|
||||
return;
|
||||
}
|
||||
return writer_.load()->WriteIOOp(record);
|
||||
writer_.load()->WriteIOOp(record).PermitUncheckedError();
|
||||
}
|
||||
} // namespace ROCKSDB_NAMESPACE
|
||||
|
@ -158,7 +158,7 @@ class IOTracer {
|
||||
|
||||
TSAN_SUPPRESSION bool is_tracing_enabled() const { return tracing_enabled; }
|
||||
|
||||
Status WriteIOOp(const IOTraceRecord& record);
|
||||
void WriteIOOp(const IOTraceRecord& record);
|
||||
|
||||
private:
|
||||
TraceOptions trace_options_;
|
||||
|
@ -58,7 +58,7 @@ class IOTracerTest : public testing::Test {
|
||||
record.file_name = kDummyFile + std::to_string(i);
|
||||
record.len = i;
|
||||
record.offset = i + 20;
|
||||
ASSERT_OK(writer->WriteIOOp(record));
|
||||
EXPECT_OK(writer->WriteIOOp(record));
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ TEST_F(IOTracerTest, AtomicWrite) {
|
||||
&trace_writer));
|
||||
IOTracer writer;
|
||||
ASSERT_OK(writer.StartIOTrace(env_, trace_opt, std::move(trace_writer)));
|
||||
ASSERT_OK(writer.WriteIOOp(record));
|
||||
writer.WriteIOOp(record);
|
||||
ASSERT_OK(env_->FileExists(trace_file_path_));
|
||||
}
|
||||
{
|
||||
@ -124,7 +124,7 @@ TEST_F(IOTracerTest, AtomicWriteBeforeStartTrace) {
|
||||
IOTracer writer;
|
||||
// The record should not be written to the trace_file since StartIOTrace is
|
||||
// not called.
|
||||
ASSERT_OK(writer.WriteIOOp(record));
|
||||
writer.WriteIOOp(record);
|
||||
ASSERT_OK(env_->FileExists(trace_file_path_));
|
||||
}
|
||||
{
|
||||
@ -149,11 +149,11 @@ TEST_F(IOTracerTest, AtomicNoWriteAfterEndTrace) {
|
||||
&trace_writer));
|
||||
IOTracer writer;
|
||||
ASSERT_OK(writer.StartIOTrace(env_, trace_opt, std::move(trace_writer)));
|
||||
ASSERT_OK(writer.WriteIOOp(record));
|
||||
writer.WriteIOOp(record);
|
||||
writer.EndIOTrace();
|
||||
// Write the record again. This time the record should not be written since
|
||||
// EndIOTrace is called.
|
||||
ASSERT_OK(writer.WriteIOOp(record));
|
||||
writer.WriteIOOp(record);
|
||||
ASSERT_OK(env_->FileExists(trace_file_path_));
|
||||
}
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user