summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog
diff options
context:
space:
mode:
authorGregory Noma <gregory.noma@gmail.com>2022-04-19 21:17:58 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-04-19 21:53:50 +0000
commitfe892f349c9926583ceb6ad2f7dd6c8fb6ef10e7 (patch)
treedefde54f9b44cbd2b5b7bfd48485631fc2541953 /src/mongo/db/catalog
parent5280703383f79427adbef2a78c64e4b7c4739825 (diff)
downloadmongo-fe892f349c9926583ceb6ad2f7dd6c8fb6ef10e7.tar.gz
SERVER-65221 Run `ThrottleCursorTest` with `wiredTiger`
Diffstat (limited to 'src/mongo/db/catalog')
-rw-r--r--src/mongo/db/catalog/throttle_cursor_test.cpp87
1 files changed, 47 insertions, 40 deletions
diff --git a/src/mongo/db/catalog/throttle_cursor_test.cpp b/src/mongo/db/catalog/throttle_cursor_test.cpp
index 2710e627c3f..8de3f08fbeb 100644
--- a/src/mongo/db/catalog/throttle_cursor_test.cpp
+++ b/src/mongo/db/catalog/throttle_cursor_test.cpp
@@ -47,7 +47,6 @@ namespace mongo {
namespace {
const NamespaceString kNss = NamespaceString("test.throttleCursor");
-const KeyString::Value kMinKeyString = KeyString::Value();
const uint8_t kTickDelay = 200;
class ThrottleCursorTest : public CatalogTestFixture {
@@ -56,8 +55,13 @@ private:
void tearDown() override;
protected:
- // TODO (SERVER-65221): Use wiredTiger.
- ThrottleCursorTest() : CatalogTestFixture(Options{}.engine("ephemeralForTest")) {}
+ const KeyString::Value kMinKeyString = KeyString::Builder{KeyString::Version::kLatestVersion,
+ kMinBSONKey,
+ KeyString::ALL_ASCENDING}
+ .getValueCopy();
+
+ explicit ThrottleCursorTest(Milliseconds clockIncrement = Milliseconds{kTickDelay})
+ : CatalogTestFixture(Options{}.useMockClock(true, clockIncrement)) {}
public:
void setMaxMbPerSec(int maxMbPerSec);
@@ -69,6 +73,12 @@ public:
std::unique_ptr<DataThrottle> _dataThrottle;
};
+class ThrottleCursorTestFastClock : public ThrottleCursorTest {
+protected:
+ // Move the clock faster to speed up the test.
+ ThrottleCursorTestFastClock() : ThrottleCursorTest(Milliseconds{1000}) {}
+};
+
void ThrottleCursorTest::setUp() {
CatalogTestFixture::setUp();
CollectionOptions defaultCollectionOptions;
@@ -89,10 +99,6 @@ void ThrottleCursorTest::setUp() {
wuow.commit();
}
- std::unique_ptr<ClockSourceMock> clkSource =
- std::make_unique<AutoAdvancingClockSourceMock>(Milliseconds(kTickDelay));
-
- operationContext()->getServiceContext()->setFastClockSource(std::move(clkSource));
_dataThrottle = std::make_unique<DataThrottle>(operationContext());
}
@@ -205,7 +211,7 @@ TEST_F(ThrottleCursorTest, TestSeekableRecordThrottleCursorOn) {
}
}
-TEST_F(ThrottleCursorTest, TestSeekableRecordThrottleCursorOnLargeDocs) {
+TEST_F(ThrottleCursorTestFastClock, TestSeekableRecordThrottleCursorOnLargeDocs1MBps) {
auto opCtx = operationContext();
AutoGetCollection autoColl(opCtx, kNss, MODE_X);
const CollectionPtr& coll = autoColl.getCollection();
@@ -213,57 +219,58 @@ TEST_F(ThrottleCursorTest, TestSeekableRecordThrottleCursorOnLargeDocs) {
// Use a fixed record data size to simplify the timing calculations.
FailPointEnableBlock failPoint("fixedCursorDataSizeOf2MBForDataThrottle");
- // Move the clock faster to speed up the test.
- operationContext()->getServiceContext()->setFastClockSource(
- std::make_unique<AutoAdvancingClockSourceMock>(Milliseconds(1000)));
-
SeekableRecordThrottleCursor cursor =
SeekableRecordThrottleCursor(opCtx, coll->getRecordStore(), _dataThrottle.get());
// Using a throttle with a limit of 1MB per second, all operations should take at least 10
// seconds to finish. We scan 5 records, each of which is 2MB courtesy of the fail point, so
// 1 record every 2 seconds.
- {
- setMaxMbPerSec(1);
- Date_t start = getTime();
+ setMaxMbPerSec(1);
+ Date_t start = getTime();
- // Seek to the first record, then iterate through 4 more.
- ASSERT_TRUE(cursor.seekExact(opCtx, RecordId(1)));
- int scanRecords = 4;
+ // Seek to the first record, then iterate through 4 more.
+ ASSERT_TRUE(cursor.seekExact(opCtx, RecordId(1)));
+ int scanRecords = 4;
- while (scanRecords > 0 && cursor.next(opCtx)) {
- scanRecords--;
- }
+ while (scanRecords > 0 && cursor.next(opCtx)) {
+ scanRecords--;
+ }
- Date_t end = getTime();
+ Date_t end = getTime();
- ASSERT_EQ(scanRecords, 0);
- ASSERT_GTE(getDifferenceInMillis(start, end), 10 * 1000);
- }
+ ASSERT_EQ(scanRecords, 0);
+ ASSERT_GTE(getDifferenceInMillis(start, end), 10 * 1000);
+}
- operationContext()->getServiceContext()->setFastClockSource(
- std::make_unique<AutoAdvancingClockSourceMock>(Milliseconds(kTickDelay)));
+TEST_F(ThrottleCursorTest, TestSeekableRecordThrottleCursorOnLargeDocs5MBps) {
+ auto opCtx = operationContext();
+ AutoGetCollection autoColl(opCtx, kNss, MODE_X);
+ const CollectionPtr& coll = autoColl.getCollection();
+
+ // Use a fixed record data size to simplify the timing calculations.
+ FailPointEnableBlock failPoint("fixedCursorDataSizeOf2MBForDataThrottle");
+
+ SeekableRecordThrottleCursor cursor =
+ SeekableRecordThrottleCursor(opCtx, coll->getRecordStore(), _dataThrottle.get());
// Using a throttle with a limit of 5MB per second, all operations should take at least 2
// second to finish. We scan 5 records, each of which is 2MB courtesy of the fail point, so
// 2.5 records per second.
- {
- setMaxMbPerSec(5);
- Date_t start = getTime();
+ setMaxMbPerSec(5);
+ Date_t start = getTime();
- // Seek to the first record, then iterate through 4 more.
- ASSERT_TRUE(cursor.seekExact(opCtx, RecordId(1)));
- int scanRecords = 4;
+ // Seek to the first record, then iterate through 4 more.
+ ASSERT_TRUE(cursor.seekExact(opCtx, RecordId(1)));
+ int scanRecords = 4;
- while (scanRecords > 0 && cursor.next(opCtx)) {
- scanRecords--;
- }
+ while (scanRecords > 0 && cursor.next(opCtx)) {
+ scanRecords--;
+ }
- Date_t end = getTime();
+ Date_t end = getTime();
- ASSERT_EQ(scanRecords, 0);
- ASSERT_GTE(getDifferenceInMillis(start, end), 2000);
- }
+ ASSERT_EQ(scanRecords, 0);
+ ASSERT_GTE(getDifferenceInMillis(start, end), 2000);
}
TEST_F(ThrottleCursorTest, TestSortedDataInterfaceThrottleCursorOff) {