Skip to content

Commit

Permalink
Add test to test device.saveState performance
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles committed Jan 31, 2021
1 parent 1a9184d commit df831d0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions server/test/lib/device/device.saveState.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,29 @@ describe('Device.saveState', () => {
12,
);
});
// we want to make sure that inserting states at a face pace is working, and not causing concurrencies issues
it('should insert 200 states in parallel', async function Test() {
this.timeout(10000);
const event = {
emit: stub().returns(null),
on: stub().returns(null),
};
const stateManager = new StateManager(event);
const device = new Device(event, {}, stateManager);
const promises = [];
for (let i = 0; i < 200; i += 1) {
promises.push(
device.saveState(
{
id: 'ca91dfdf-55b2-4cf8-a58b-99c0fbf6f5e4',
selector: 'test-device-feature',
has_feedback: false,
keep_history: true,
},
12,
),
);
}
await Promise.all(promises);
});
});

0 comments on commit df831d0

Please sign in to comment.