Skip to content

Commit

Permalink
test parallel device registration in node
Browse files Browse the repository at this point in the history
Change-type: do-not-merge
Signed-off-by: Thodoris Greasidis <[email protected]>
  • Loading branch information
thgreasi committed Feb 21, 2022
1 parent d015602 commit 9879b45
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions tests/integration/models/device.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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 () {
Expand Down

0 comments on commit 9879b45

Please sign in to comment.