diff options
author | Allison Easton <allison.easton@mongodb.com> | 2022-02-15 08:56:46 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-02-15 09:25:48 +0000 |
commit | 9a18b279d302d5aad79435bc2fa465dcd6692e6a (patch) | |
tree | a7c49a6298d01897c9192e42f4d4395ea6e5980c | |
parent | 7bd6a08e6ed1f308cba776cb1c71d9ccb3c0dfbe (diff) | |
download | mongo-9a18b279d302d5aad79435bc2fa465dcd6692e6a.tar.gz |
SERVER-63617 Invalid 2D sphere documents do not throw BadValue
-rw-r--r-- | jstests/core/timeseries/timeseries_metric_index_2dsphere.js | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/jstests/core/timeseries/timeseries_metric_index_2dsphere.js b/jstests/core/timeseries/timeseries_metric_index_2dsphere.js index 5997a8254e3..a7fece34c53 100644 --- a/jstests/core/timeseries/timeseries_metric_index_2dsphere.js +++ b/jstests/core/timeseries/timeseries_metric_index_2dsphere.js @@ -92,12 +92,15 @@ TimeseriesTest.run((insert) => { assert.commandWorked(insert(timeseriescoll, twoDSphereDocs), 'Failed to insert twoDSphereDocs: ' + tojson(twoDSphereDocs)); - const invalidDocs = [ - { - _id: 6, - [timeFieldName]: ISODate(), - location: {type: "Polygon", coordinates: [[0, 0], [1, 0], [1, 1], [0, 0]]} - }, + // Test invalid documents + const docWithInvalidCoordinates = { + _id: 6, + [timeFieldName]: ISODate(), + location: {type: "Polygon", coordinates: [[0, 0], [1, 0], [1, 1], [0, 0]]} + }; + // Can't extract geo keys: GeoJSON coordinates must be an array + assert.commandFailedWithCode(insert(timeseriescoll, docWithInvalidCoordinates), 183934); + const docsWithTypeNotPoint = [ { _id: 7, [timeFieldName]: ISODate(), @@ -109,10 +112,10 @@ TimeseriesTest.run((insert) => { location: {type: "LineString", coordinates: [[0, 0], [1, 0], [1, 1], [0, 0]]} } ]; - for (const invalidDoc in invalidDocs) { - assert.commandFailedWithCode(assert.throws(() => insert(timeseriescoll, invalidDoc)), - ErrorCodes.BadValue); - } + docsWithTypeNotPoint.forEach((invalidDoc) => { + // Time-series collections '2dsphere' indexes only support point data + assert.commandFailedWithCode(insert(timeseriescoll, invalidDoc), 183493); + }); // Assert that geoWithin queries use the index. const geoWithinPlan = |