Skip to content

Commit

Permalink
More Mongo mappings (#1359)
Browse files Browse the repository at this point in the history
* map j->journal

* minSize->minPoolSize

* rm obsolete comment

* fix test
  • Loading branch information
tinahollygb committed Jun 9, 2023
1 parent 8eabf79 commit ac0edeb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions packages/back-end/src/util/mongo.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* - acceptableLatencyMS: is no longer documented. Possibly related: maxStalenessSeconds
* - connectWithNoPrimary: is no longer documented
* - w: still exists but is marked as deprecated -> writeConcern (incompatible types)
* - j: is no longer documented (journal write concern). -> writeConcern (incompatible types)
* - domainsEnabled: is no longer documented
* - bufferMaxEntries: is no longer documented
* - promiseLibrary: still exists but is marked as deprecated.
Expand All @@ -41,19 +40,24 @@ export const getConnectionStringWithDeprecatedKeysMigratedForV3to4 = (
"secondaryAcceptableLatencyMS",
"acceptableLatencyMS",
"connectWithNoPrimary",
"j",
"domainsEnabled",
"bufferMaxEntries",
];
const v3to4Mappings: Record<string, string> = {
minSize: "minPoolSize",
poolSize: "maxPoolSize",
tlsinsecure: "tlsInsecure",

/**
* @deprecated
* @deprecated use WriteConcern
*/
wtimeout: "wtimeoutMS",

/**
* @deprecated use WriteConcern
*/
j: "journal",

appname: "appName",
};

Expand Down
4 changes: 2 additions & 2 deletions packages/back-end/test/util/mongo.util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe("mongo utils", () => {
"mongodb://root:password@localhost:27017/growthbook?authSource=admin&poolSize=50&wtimeout=123456&appname=foobar&tlsinsecure=true&autoReconnect=true&reconnectRetries=3&reconnectInterval=300&ha=true&haInterval=300&secondaryAcceptableLatencyMS=1000&acceptableLatencyMS=1000&j=true&connectWithNoPrimary=true&domainsEnabled=false&bufferMaxEntries=10&foo=1&bar=2&baz=3";
// includes original deprecated keys
const expected =
"mongodb://root:password@localhost:27017/growthbook?authSource=admin&autoReconnect=true&reconnectRetries=3&reconnectInterval=300&ha=true&haInterval=300&secondaryAcceptableLatencyMS=1000&acceptableLatencyMS=1000&j=true&connectWithNoPrimary=true&domainsEnabled=false&bufferMaxEntries=10&foo=1&bar=2&baz=3&maxPoolSize=50&tlsInsecure=true&wtimeoutMS=123456&appName=foobar";
"mongodb://root:password@localhost:27017/growthbook?authSource=admin&autoReconnect=true&reconnectRetries=3&reconnectInterval=300&ha=true&haInterval=300&secondaryAcceptableLatencyMS=1000&acceptableLatencyMS=1000&connectWithNoPrimary=true&domainsEnabled=false&bufferMaxEntries=10&foo=1&bar=2&baz=3&maxPoolSize=50&tlsInsecure=true&wtimeoutMS=123456&journal=true&appName=foobar";

const {
url,
Expand All @@ -103,6 +103,7 @@ describe("mongo utils", () => {
"poolSize",
"tlsinsecure",
"wtimeout",
"j",
"appname",
]);
expect(unsupported).toEqual([
Expand All @@ -113,7 +114,6 @@ describe("mongo utils", () => {
"secondaryAcceptableLatencyMS",
"acceptableLatencyMS",
"connectWithNoPrimary",
"j",
"domainsEnabled",
"bufferMaxEntries",
]);
Expand Down

0 comments on commit ac0edeb

Please sign in to comment.