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

Method TestScratchLimit

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

Source from the content-addressed store, hash-verified

579}
580
581void TmpFileMgrTest::TestScratchLimit(bool punch_holes, int64_t alloc_size) {
582 // Size must bea power-of-two so that FileGroup allocates exactly this amount of
583 // scratch space.
584 ASSERT_TRUE(BitUtil::IsPowerOf2(alloc_size));
585 vector<string> tmp_dirs({"/tmp/tmp-file-mgr-test.1", "/tmp/tmp-file-mgr-test.2"});
586 RemoveAndCreateDirs(tmp_dirs);
587 TmpFileMgr tmp_file_mgr;
588 ASSERT_OK(tmp_file_mgr.InitCustom(tmp_dirs, false, "", punch_holes, metrics_.get()));
589
590 const int64_t limit = alloc_size * 2;
591 TUniqueId id;
592 TmpFileGroup file_group(&tmp_file_mgr, io_mgr(), profile_, id, limit);
593
594 vector<TmpFile*> files;
595 ASSERT_OK(CreateFiles(&file_group, &files));
596
597 // Test individual limit is enforced.
598 Status status;
599 int64_t offset;
600 TmpFile* alloc_file;
601
602 // Alloc from file 1 should succeed.
603 SetNextAllocationIndex(&file_group, DEFAULT_PRIORITY, 0);
604 ASSERT_OK(GroupAllocateSpace(&file_group, alloc_size, &alloc_file, &offset));
605 ASSERT_EQ(alloc_file, files[0]); // Should select files round-robin.
606 ASSERT_EQ(0, offset);
607
608 // Allocate up to the max.
609 ASSERT_OK(GroupAllocateSpace(&file_group, alloc_size, &alloc_file, &offset));
610 ASSERT_EQ(0, offset);
611 ASSERT_EQ(alloc_file, files[1]);
612
613 // Test aggregate limit is enforced.
614 status = GroupAllocateSpace(&file_group, 1, &alloc_file, &offset);
615 ASSERT_FALSE(status.ok());
616 ASSERT_EQ(status.code(), TErrorCode::SCRATCH_LIMIT_EXCEEDED);
617 ASSERT_NE(string::npos, status.msg().msg().find(GetBackendString()));
618
619 // Check HWM metrics
620 checkHWMMetrics(limit, limit);
621 file_group.Close();
622 checkHWMMetrics(0, limit);
623}
624
625// Test that scratch file ranges of varying length are recycled as expected.
626TEST_F(TmpFileMgrTest, TestScratchRangeRecycling) {

Callers

nothing calls this directly

Calls 7

GetBackendStringFunction · 0.85
InitCustomMethod · 0.80
codeMethod · 0.80
getMethod · 0.65
okMethod · 0.45
findMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected