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
main
Akanksha Mahajan 4 years ago committed by Facebook GitHub Bot
parent 4d897e51df
commit fbac1b3f80
  1. 4
      Makefile
  2. 8
      file/prefetch_test.cc
  3. 9
      trace_replay/io_tracer.cc
  4. 2
      trace_replay/io_tracer.h
  5. 10
      trace_replay/io_tracer_test.cc

@ -677,7 +677,9 @@ ifdef ASSERT_STATUS_CHECKED
compaction_iterator_test \
compaction_job_test \
compaction_job_stats_test \
io_tracer_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…
Cancel
Save