MCPcopy Create free account
hub / github.com/apache/impala / TestBlockVerification

Method TestBlockVerification

be/src/runtime/tmp-file-mgr-test.cc:785–826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

783}
784
785void TmpFileMgrTest::TestBlockVerification() {
786 FLAGS_disk_spill_encryption = true;
787 TUniqueId id;
788 TmpFileGroup file_group(test_env_->tmp_file_mgr(), io_mgr(), profile_, id);
789 string data = "the quick brown fox jumped over the lazy dog";
790 MemRange data_mem_range(reinterpret_cast<uint8_t*>(&data[0]), data.size());
791
792 // Start a write in flight, which should encrypt the data and write it to disk.
793 unique_ptr<TmpWriteHandle> handle;
794 WriteRange::WriteDoneCallback callback =
795 bind(mem_fn(&TmpFileMgrTest::SignalCallback), this, _1);
796 ASSERT_OK(file_group.Write(data_mem_range, callback, &handle));
797 string file_path = handle->TmpFilePath();
798
799 WaitForWrite(handle.get());
800 WaitForCallbacks(1);
801
802 // Modify the data in the scratch file and check that a read error occurs.
803 LOG(INFO) << "Corrupting " << file_path;
804 uint8_t corrupt_byte = data[0] ^ 1;
805 FILE* file = fopen(file_path.c_str(), "rb+");
806 ASSERT_TRUE(file != nullptr);
807 ASSERT_EQ(corrupt_byte, fputc(corrupt_byte, file));
808 ASSERT_EQ(0, fclose(file));
809 vector<uint8_t> tmp;
810 tmp.resize(data.size());
811 Status read_status = file_group.Read(handle.get(), MemRange(tmp.data(), tmp.size()));
812 LOG(INFO) << read_status.GetDetail();
813 EXPECT_EQ(TErrorCode::SCRATCH_READ_VERIFY_FAILED, read_status.code())
814 << read_status.GetDetail();
815
816 // Modify the data in memory. Restoring the data should fail.
817 LOG(INFO) << "Corrupting data in memory";
818 data[0] = corrupt_byte;
819 Status restore_status = file_group.RestoreData(move(handle), data_mem_range);
820 LOG(INFO) << restore_status.GetDetail();
821 EXPECT_EQ(TErrorCode::SCRATCH_READ_VERIFY_FAILED, restore_status.code())
822 << restore_status.GetDetail();
823
824 file_group.Close();
825 test_env_->TearDownQueries();
826}
827
828// Test that the current scratch space bytes and HWM values are proper when different
829// FileGroups are used concurrently. This test unit mimics concurrent spilling queries.

Callers

nothing calls this directly

Calls 15

bindFunction · 0.85
MemRangeClass · 0.85
moveFunction · 0.85
resizeMethod · 0.80
GetDetailMethod · 0.80
codeMethod · 0.80
RestoreDataMethod · 0.80
TearDownQueriesMethod · 0.80
getMethod · 0.65
tmp_file_mgrMethod · 0.45
sizeMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected