summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/exec/document_value/document_metadata_fields.h8
-rw-r--r--src/mongo/db/exec/document_value/document_metadata_fields_test.cpp29
-rw-r--r--src/mongo/db/pipeline/document_source_sort.cpp7
3 files changed, 40 insertions, 4 deletions
diff --git a/src/mongo/db/exec/document_value/document_metadata_fields.h b/src/mongo/db/exec/document_value/document_metadata_fields.h
index 12932c29686..c3541ced659 100644
--- a/src/mongo/db/exec/document_value/document_metadata_fields.h
+++ b/src/mongo/db/exec/document_value/document_metadata_fields.h
@@ -327,7 +327,9 @@ public:
}
Date_t getTimeseriesBucketMinTime() const {
- invariant(hasTimeseriesBucketMinTime());
+ tassert(6850100,
+ "Document must have timeseries bucket min time metadata field set",
+ hasTimeseriesBucketMinTime());
return _holder->timeseriesBucketMinTime;
}
@@ -344,7 +346,9 @@ public:
}
Date_t getTimeseriesBucketMaxTime() const {
- invariant(hasTimeseriesBucketMaxTime());
+ tassert(6850101,
+ "Document must have timeseries bucket max time metadata field set",
+ hasTimeseriesBucketMaxTime());
return _holder->timeseriesBucketMaxTime;
}
diff --git a/src/mongo/db/exec/document_value/document_metadata_fields_test.cpp b/src/mongo/db/exec/document_value/document_metadata_fields_test.cpp
index 5515009b2bd..16dd8a5b558 100644
--- a/src/mongo/db/exec/document_value/document_metadata_fields_test.cpp
+++ b/src/mongo/db/exec/document_value/document_metadata_fields_test.cpp
@@ -34,6 +34,7 @@
#include "mongo/db/exec/document_value/document_metadata_fields.h"
#include "mongo/db/exec/document_value/document_value_test_util.h"
#include "mongo/unittest/bson_test_util.h"
+#include "mongo/unittest/death_test.h"
#include "mongo/unittest/unittest.h"
namespace mongo {
@@ -268,4 +269,32 @@ TEST(DocumentMetadataFieldsTest, CopyFromCopiesAllMetadataThatSourceHas) {
ASSERT_FALSE(destination.hasSearchScoreDetails());
}
+TEST(DocumentMetadataFieldsTest, GetTimeseriesBucketMinTimeExists) {
+ DocumentMetadataFields source;
+ Date_t time;
+ source.setTimeseriesBucketMinTime(time);
+ ASSERT_EQ(source.getTimeseriesBucketMinTime(), time);
+}
+
+TEST(DocumentMetadataFieldsTest, GetTimeseriesBucketMaxTimeExists) {
+ DocumentMetadataFields source;
+ Date_t time;
+ source.setTimeseriesBucketMaxTime(time);
+ ASSERT_EQ(source.getTimeseriesBucketMaxTime(), time);
+}
+
+DEATH_TEST_REGEX(DocumentMetadataFieldsTest,
+ GetTimeseriesBucketMinTimeDoesntExist,
+ "Tripwire assertion.*6850100") {
+ DocumentMetadataFields source;
+ source.getTimeseriesBucketMinTime();
+}
+
+DEATH_TEST_REGEX(DocumentMetadataFieldsTest,
+ GetTimeseriesBucketMaxTimeDoesntExist,
+ "Tripwire assertion.*6850101") {
+ DocumentMetadataFields source;
+ source.getTimeseriesBucketMaxTime();
+}
+
} // namespace mongo
diff --git a/src/mongo/db/pipeline/document_source_sort.cpp b/src/mongo/db/pipeline/document_source_sort.cpp
index 2c07c43c501..1ccc8a5d58d 100644
--- a/src/mongo/db/pipeline/document_source_sort.cpp
+++ b/src/mongo/db/pipeline/document_source_sort.cpp
@@ -142,12 +142,15 @@ REGISTER_DOCUMENT_SOURCE(sort,
LiteParsedDocumentSourceDefault::parse,
DocumentSourceSort::createFromBson,
AllowedWithApiStrict::kAlways);
+
REGISTER_DOCUMENT_SOURCE_CONDITIONALLY(
_internalBoundedSort,
LiteParsedDocumentSourceDefault::parse,
DocumentSourceSort::parseBoundedSort,
- AllowedWithApiStrict::kNeverInVersion1,
- AllowedWithClientType::kAny,
+ ::mongo::getTestCommandsEnabled() ? AllowedWithApiStrict::kNeverInVersion1
+ : AllowedWithApiStrict::kInternal,
+ ::mongo::getTestCommandsEnabled() ? AllowedWithClientType::kAny
+ : AllowedWithClientType::kInternal,
feature_flags::gFeatureFlagBucketUnpackWithSort.getVersion(),
feature_flags::gFeatureFlagBucketUnpackWithSort.isEnabledAndIgnoreFCV());