Skip to content

Commit

Permalink
chore: make CI a bit greener MONGOSH-1726 (#1848)
Browse files Browse the repository at this point in the history
- Specifically choose the npm version to be one that matches the
  Node.js version we install; this is a better version of the fix
  in a459c99, which made Windows CI (almost) green but left
  the test_n16_snippet_manager task failing due to the specific
  combination of Node.js 16 and npm 10.x on Windows.
- Account for upstream server changes to the PlanCache functionality.
  • Loading branch information
addaleax authored Mar 1, 2024
1 parent cd6f08b commit 2967a12
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
10 changes: 8 additions & 2 deletions .evergreen/install-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ set -e
set -x
export BASEDIR="$PWD/.evergreen"

if echo $NODE_JS_VERSION | grep -q ^16 ; then
NPM_VERSION=9.9.2 # 9.9.3 does not install well on Windows
else
NPM_VERSION=10.x
fi

if [ "$OS" == "Windows_NT" ]; then
powershell "$(cygpath -w "$BASEDIR")"/InstallNode.ps1
. "$BASEDIR/setup-env.sh"
mkdir -p "$BASEDIR/npm-10" && (cd "$BASEDIR/npm-10" && echo '{}' > package.json && npm i npm@10.x)
mkdir -p "$BASEDIR/npm-10" && (cd "$BASEDIR/npm-10" && echo '{}' > package.json && npm i npm@$NPM_VERSION)
# using npm 10 because npm 9.9.3 does not install well on windows

curl -sSfLO https://raw.githubusercontent.com/mongodb-js/compass/42e6142ae08be6fec944b80ff6289e6bcd11badf/.evergreen/node-gyp-bug-workaround.sh && bash node-gyp-bug-workaround.sh
Expand Down Expand Up @@ -59,7 +65,7 @@ else
npm cache clear --force || true # Try to work around `Cannot read property 'pickAlgorithm' of null` errors in CI
# Started observing CI failures on RHEL 7.2 (s390x) for installing npm, all
# related to network issues hence adding a retry with backoff here.
bash "$BASEDIR/retry-with-backoff.sh" npm i -g npm@9.x
bash "$BASEDIR/retry-with-backoff.sh" npm i -g npm@$NPM_VERSION
fi

. "$BASEDIR/setup-env.sh"
28 changes: 17 additions & 11 deletions packages/shell-api/src/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2557,29 +2557,33 @@ describe('Shell API (integration)', function () {
await loadQueryCache(collection);
const planCache = collection.getPlanCache();
const res = await planCache.list();
expect(res.length).to.equal(4);
// SERVER-82677 means that the number of plans actually stored can
// vary because queries get deduplicated, even if there are exact
// indexes matching one query but not the other one during deduplication.
expect(res).to.have.lengthOf.at.least(2);
expect(res).to.have.lengthOf.at.most(4);
});
it('lists projection with args', async function () {
await loadQueryCache(collection);
const planCache = collection.getPlanCache();
const res = await planCache.list([{ $project: { queryHash: 1 } }]);
// The 6.0 server greatly reduces the expectations we can make here,
// so just assert that query hashes are returned.
expect(res).to.have.lengthOf(4);
expect(res.map((doc) => Object.keys(doc))).to.deep.equal([
['queryHash'],
['queryHash'],
['queryHash'],
['queryHash'],
]);
expect(res).to.have.lengthOf.at.least(2);
expect(res).to.have.lengthOf.at.most(4);
expect([
...new Set(res.map((doc) => JSON.stringify(Object.keys(doc)))),
]).to.deep.equal(['["queryHash"]']);
});
});
describe('clear', function () {
skipIfServerVersion(testServer, '< 4.4');
it('clears list', async function () {
await loadQueryCache(collection);
const planCache = collection.getPlanCache();
expect((await planCache.list()).length).to.equal(4);
const res = await planCache.list();
expect(res).to.have.lengthOf.at.least(2);
expect(res).to.have.lengthOf.at.most(4);
const clearRes = await planCache.clear();
expect(clearRes.ok).to.equal(1);
expect((await planCache.list()).length).to.equal(0);
Expand All @@ -2591,10 +2595,12 @@ describe('Shell API (integration)', function () {
const query = { quantity: { $gte: 5 }, type: 'apparel' };
await loadQueryCache(collection);
const planCache = collection.getPlanCache();
expect((await planCache.list()).length).to.equal(4);
const res = await planCache.list();
expect(res).to.have.lengthOf.at.least(2);
expect(res).to.have.lengthOf.at.most(4);
const clearRes = await planCache.clearPlansByQuery(query);
expect(clearRes.ok).to.equal(1);
expect((await planCache.list()).length).to.equal(3);
expect((await planCache.list()).length).to.equal(res.length - 1);
});
});
});
Expand Down

0 comments on commit 2967a12

Please sign in to comment.