From 9879b4583fc5d714abffb894d0d027c775273111 Mon Sep 17 00:00:00 2001 From: Thodoris Greasidis Date: Mon, 21 Feb 2022 14:12:12 +0200 Subject: [PATCH] test parallel device registration in node Change-type: do-not-merge Signed-off-by: Thodoris Greasidis --- tests/integration/models/device.spec.js | 36 +++++++++++-------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/tests/integration/models/device.spec.js b/tests/integration/models/device.spec.js index 9885f4345..4fa812ea7 100644 --- a/tests/integration/models/device.spec.js +++ b/tests/integration/models/device.spec.js @@ -38,11 +38,15 @@ const makeRequest = (url) => ), ); -describe('Device Model', function () { +describe.only('Device Model', function () { timeSuite(before); givenLoggedInUser(before); givenInitialOrganization(before); + if (IS_BROWSER) { + return; + } + describe('given no applications', function () { parallel('balena.models.device.getManifestBySlug()', function () { it('should become the manifest if the slug is valid', async () => { @@ -2620,27 +2624,19 @@ describe('Device Model', function () { }); }); - const BATCH_DEVICE_COUNT = 55; + const BATCH_DEVICE_COUNT = 105; describe(`given ${BATCH_DEVICE_COUNT} registered offline device`, function () { before(async function () { - this.devices = []; - const REGISTRATION_CHUNK_SIZE = 10; - for (let i = 0; i < BATCH_DEVICE_COUNT; i += REGISTRATION_CHUNK_SIZE) { - this.devices.push( - ...(await Promise.all( - _.times( - Math.min(BATCH_DEVICE_COUNT - i, REGISTRATION_CHUNK_SIZE), - ).map(async () => { - const uuid = balena.models.device.generateUniqueKey(); - const deviceInfo = await balena.models.device.register( - this.application.id, - uuid, - ); - return deviceInfo; - }), - )), - ); - } + this.devices = await Promise.all( + _.times(BATCH_DEVICE_COUNT).map(async () => { + const uuid = balena.models.device.generateUniqueKey(); + const deviceInfo = await balena.models.device.register( + this.application.id, + uuid, + ); + return deviceInfo; + }), + ); }); describe('balena.models.device.pinToRelease()', function () {