Skip to content

Commit 98c6701

Browse files
author
Artem
committed
add additional tests for 10_000 keys unit + integration
1 parent 9a82110 commit 98c6701

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

redisinsight/api/src/modules/bulk-actions/bulk-import.service.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,29 @@ describe('BulkImportService', () => {
151151
});
152152
});
153153

154+
it('should import data (10K) from file in batches 10K each', async () => {
155+
spy.mockResolvedValue(Object.assign(new BulkActionSummary(), {
156+
processed: 10_000,
157+
succeed: 10_000,
158+
failed: 0,
159+
}));
160+
expect(await service.import(mockClientMetadata, {
161+
file: {
162+
...mockUploadImportFileDto.file,
163+
buffer: generateNCommandsBuffer(10_000),
164+
} as unknown as MemoryStoredFile,
165+
})).toEqual({
166+
...mockImportResult,
167+
summary: {
168+
processed: 10_000,
169+
succeed: 10_000,
170+
failed: 0,
171+
errors: [],
172+
},
173+
duration: jasmine.anything(),
174+
});
175+
});
176+
154177
it('should not import any data due to parse error', async () => {
155178
spy.mockResolvedValue(Object.assign(new BulkActionSummary(), {
156179
processed: 0,

redisinsight/api/test/api/bulk-actions/POST-databases-id-bulk_actions-upload.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,36 @@ describe('POST /databases/:id/bulk-actions/import', () => {
6565
},
6666
});
6767
});
68+
it('Should import 10K strings', async () => {
69+
await validateApiCall({
70+
endpoint,
71+
attach: [
72+
'file',
73+
Buffer.from(
74+
(new Array(10_000)).fill(1).map(
75+
(_v, idx) => `SET key${idx} value${idx}`,
76+
).join('\n'),
77+
),
78+
'any_filename_and_ext',
79+
],
80+
responseBody: {
81+
id: 'empty',
82+
databaseId: constants.TEST_INSTANCE_ID,
83+
type: 'import',
84+
summary: { processed: 10_000, succeed: 10_000, failed: 0, errors: [] },
85+
progress: null,
86+
filter: null,
87+
status: 'completed',
88+
},
89+
checkFn: async ({ body }) => {
90+
expect(body.duration).to.gt(0);
91+
92+
expect(await rte.client.get('key0')).to.eq('value0');
93+
expect(await rte.client.get('key9999')).to.eq('value9999');
94+
expect(await rte.client.get('key10000')).to.eq(null);
95+
},
96+
});
97+
});
6898
it('Should import 50 out of 100 keys strings', async () => {
6999
await validateApiCall({
70100
endpoint,

0 commit comments

Comments
 (0)