SERVER-93383 Test readOnly parameter on $listClusterCatalog (#50384)
GitOrigin-RevId: 01f8f1c5a56878c2e10c5c967f3b48b1f2637e96
This commit is contained in:
parent
a6bf665133
commit
c4f21ff2b9
@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
import {isViewlessTimeseriesOnlySuite} from "jstests/core/timeseries/libs/viewless_timeseries_util.js";
|
||||
import {FixtureHelpers} from "jstests/libs/fixture_helpers.js";
|
||||
|
||||
const kDb1 = "db1_agg_list_cluster_catalog";
|
||||
const kDb2 = "db2_agg_list_cluster_catalog";
|
||||
@ -282,3 +283,37 @@ jsTest.log("The stage must return the collections from the 'config' database.");
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
jsTest.log("The stage must report the correct 'readOnly' field.");
|
||||
{
|
||||
const expectedReadOnly = !FixtureHelpers.isMongos(db) && db.serverStatus().storageEngine.readOnly;
|
||||
|
||||
const stageResult = db
|
||||
.getSiblingDB(kDb1)
|
||||
.aggregate([{$listClusterCatalog: {}}])
|
||||
.toArray();
|
||||
assert.gt(stageResult.length, 0, "Expected at least one entry from $listClusterCatalog");
|
||||
|
||||
for (const entry of stageResult) {
|
||||
assert.neq(
|
||||
entry.info,
|
||||
undefined,
|
||||
"Expected 'info' field to be present in $listClusterCatalog entry: " + tojson(entry),
|
||||
);
|
||||
assert.neq(
|
||||
entry.info.readOnly,
|
||||
undefined,
|
||||
"Expected 'info.readOnly' field to be present in $listClusterCatalog entry: " + tojson(entry),
|
||||
);
|
||||
|
||||
if (entry.type === "view") {
|
||||
assert.eq(true, entry.info.readOnly, "Views must always report readOnly: true. Entry: " + tojson(entry));
|
||||
} else {
|
||||
assert.eq(
|
||||
expectedReadOnly,
|
||||
entry.info.readOnly,
|
||||
"Expected readOnly to be " + expectedReadOnly + " for non-view collection. Entry: " + tojson(entry),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,25 +43,46 @@ runReadOnlyTest(
|
||||
// Check that we can read our collections out.
|
||||
const db = readableCollection.getDB();
|
||||
|
||||
// Check that listCollections is working and prints collection information with readOnly
|
||||
// true.
|
||||
const collections = db.getCollectionInfos();
|
||||
// Check that listCollections and $listClusterCatalog are working and prints collection
|
||||
// information with readOnly true.
|
||||
const collectionsFromListCollections = db.getCollectionInfos();
|
||||
const collectionsFromListClusterCatalog = db.aggregate([{$listClusterCatalog: {}}]).toArray();
|
||||
|
||||
this.collectionNames.forEach((expectedCollectionName) => {
|
||||
const outputColl = collections.find((coll) => coll.name === expectedCollectionName);
|
||||
assert(
|
||||
outputColl,
|
||||
"expected collection '" +
|
||||
expectedCollectionName +
|
||||
"' to be readOnly, but according to listCollections output it isn't. " +
|
||||
tojson(collections),
|
||||
const outputColl = collectionsFromListCollections.find(
|
||||
(coll) => coll.name === expectedCollectionName,
|
||||
);
|
||||
assert(
|
||||
outputColl.info.readOnly,
|
||||
outputColl,
|
||||
"Collection '" +
|
||||
expectedCollectionName +
|
||||
"' not found in the output of listCollections, which was " +
|
||||
tojson(collections),
|
||||
tojson(collectionsFromListCollections),
|
||||
);
|
||||
assert(
|
||||
outputColl.info.readOnly,
|
||||
"Expected collection '" +
|
||||
expectedCollectionName +
|
||||
"' to be readOnly, but according to listCollections output it isn't. " +
|
||||
tojson(collectionsFromListCollections),
|
||||
);
|
||||
|
||||
const listClusterCatalogEntry = collectionsFromListClusterCatalog.find(
|
||||
(entry) => entry.ns === db.getName() + "." + expectedCollectionName,
|
||||
);
|
||||
assert(
|
||||
listClusterCatalogEntry,
|
||||
"Collection '" +
|
||||
expectedCollectionName +
|
||||
"' not found in the output of listCollections, which was " +
|
||||
tojson(collectionsFromListClusterCatalog),
|
||||
);
|
||||
assert(
|
||||
listClusterCatalogEntry.info.readOnly,
|
||||
"Expected collection '" +
|
||||
expectedCollectionName +
|
||||
"' to be readOnly, but according to $listClusterCatalog output it isn't. " +
|
||||
tojson(collectionsFromListClusterCatalog),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user