Skip to content

Commit

Permalink
chore: use c8/mocha instead of node_coverage env
Browse files Browse the repository at this point in the history
  • Loading branch information
AVVS committed Jan 22, 2024
1 parent 22b98bb commit 3af6872
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
7 changes: 3 additions & 4 deletions .mdeprc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ if (os.platform() !== 'darwin') {
} catch (e) { }
}

exports.node = "20.11";
exports.node = "20";
exports.in_one = true;
exports.auto_compose = true;
exports.with_local_compose = true;
exports.tester_flavour = "chrome-tester";
exports.rebuild = ['ms-flakeless'];
exports.docker_compose = './test/docker-compose.yml';
exports.test_framework = 'mocha';
exports.test_framework = 'c8 ./node_modules/.bin/mocha';
exports.extras = {
tester: {
user: `${uid}:${uid}`,
Expand All @@ -40,13 +40,12 @@ exports.extras = {
CERT_NAME: 'default',
SKIP_FB: process.env.SKIP_FB,
SKIP_MASTERS: process.env.SKIP_MASTERS,
NODE_V8_COVERAGE: 'coverage/tmp'
},
},
};

exports.pre = 'rimraf ./coverage/tmp';
exports.post_exec = 'pnpm exec -- c8 report -r text -r lcov';
// exports.post_exec = 'pnpm c8 report -r text -r lcov';

switch (process.env.DB_SRV) {
case 'redisCluster':
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"jwa": "^2.0.0",
"jwks-rsa": "^3.1.0",
"lodash": "^4.17.21",
"make-promises-safe": "^5.1.0",
"moment": "^2.30.1",
"ms-conf": "^8.2.1",
"ms-flakeless": "^4.7.2",
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/utils/bypass/masters.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MastersService {

this.pools = baseUrls.map((baseUrl) => {
return [new undici.Pool(baseUrl, {
connections: 1,
connections: 10,
pipelining: 1,
...this.config.httpPoolOptions,
}), baseUrl];
Expand Down Expand Up @@ -223,12 +223,14 @@ class MastersService {
let response;

try {
const ac = new AbortController();
const params = {
headersTimeout: 5000,
bodyTimeout: 5000,
...this.config.httpClientOptions,
path: `${this.config.authPath}?token=${profileToken}`,
method: 'GET',
signal: ac.signal,
};

response = await Promise.any(this.pools.map(async ([pool, baseUrl]) => {
Expand All @@ -245,6 +247,9 @@ class MastersService {

return output;
}));

// cleans up ongoing requests
ac.abort();
} catch (e) {
this.service.log.warn({ err: e, profileToken }, 'failed to get user from masters');
throw USERS_INVALID_TOKEN;
Expand All @@ -270,7 +275,7 @@ class MastersService {
}

async close() {
await this.pools.map(([pool]) => pool.close());
await Promise.all(this.pools.map(([pool]) => pool.destroy()));
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Promise = require('bluebird');
const sinon = require('sinon');

function registerUser(username, opts = {}) {
return async function register() {
Expand Down Expand Up @@ -42,7 +43,7 @@ async function startService(testConfig = {}) {
await this.users.register();

this.users.on('plugin:connect:amqp', () => {
this.users._mailer = { send: () => Promise.resolve() };
sinon.stub(this.users.mailer, 'send').resolves();
});

await this.users.connect();
Expand Down
3 changes: 1 addition & 2 deletions test/suites/actions/regenerate-token.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const Promise = require('bluebird');
const assert = require('node:assert/strict');
const is = require('is');
const sinon = require('sinon').usingPromise(Promise);
const sinon = require('sinon');
const { startService, clearRedis } = require('../../config');

describe('`regenerate-token` action', function regenerateTokenSuite() {
Expand Down

0 comments on commit 3af6872

Please sign in to comment.