Skip to content

Commit 8fc9907

Browse files
committed
Merge branch 'main' into playground
2 parents a05dfa3 + 52a0bf4 commit 8fc9907

File tree

33 files changed

+374
-106
lines changed

33 files changed

+374
-106
lines changed

.github/workflows/tests-integration.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,28 @@ on:
2222
description: SSH Debug
2323
type: boolean
2424
default: false
25-
25+
workflow_dispatch:
26+
inputs:
27+
build:
28+
description: Backend build to run tests over
29+
type: string
30+
default: 'local'
31+
redis_client:
32+
description: Library to use for redis connection
33+
type: string
34+
default: 'ioredis'
35+
report:
36+
description: Send report for test run to slack
37+
type: boolean
38+
default: false
39+
short_rte_list:
40+
description: Use short rte list
41+
type: boolean
42+
default: false
43+
debug:
44+
description: SSH Debug
45+
type: boolean
46+
default: false
2647
env:
2748
SLACK_AUDIT_REPORT_KEY: ${{ secrets.SLACK_AUDIT_REPORT_KEY }}
2849
SLACK_AUDIT_REPORT_CHANNEL: ${{ secrets.SLACK_AUDIT_REPORT_CHANNEL }}
@@ -262,4 +283,4 @@ jobs:
262283
owner: context.repo.owner,
263284
repo: context.repo.repo,
264285
artifact_id: ${{ steps.merge-artifacts.outputs.artifact-id }}
265-
});
286+
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
"@babel/preset-react": "^7.22.15",
111111
"@babel/preset-typescript": "^7.23.2",
112112
"@electron/rebuild": "^3.7.1",
113-
"@faker-js/faker": "^9.9.0",
113+
"@faker-js/faker": "^8.4.1",
114114
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
115115
"@storybook/addon-a11y": "^9.1.11",
116116
"@storybook/addon-docs": "^9.1.11",

redisinsight/api/src/constants/telemetry-events.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ export enum TelemetryEvents {
5858
WorkbenchIndexInfoSubmitted = 'WORKBENCH_INDEX_INFO_SUBMITTED',
5959
WorkbenchCommandErrorReceived = 'WORKBENCH_COMMAND_ERROR_RECEIVED',
6060
WorkbenchCommandDeleted = 'WORKBENCH_COMMAND_DELETE_COMMAND',
61+
62+
// Events for search tool
63+
SearchCommandExecuted = 'SEARCH_COMMAND_EXECUTED',
64+
SearchIndexInfoSubmitted = 'SEARCH_INDEX_INFO_SUBMITTED',
65+
SearchCommandErrorReceived = 'SEARCH_COMMAND_ERROR_RECEIVED',
66+
6167
// Custom tutorials
6268
WorkbenchEnablementAreaImportSucceeded = 'WORKBENCH_ENABLEMENT_AREA_IMPORT_SUCCEEDED',
6369
WorkbenchEnablementAreaImportFailed = 'WORKBENCH_ENABLEMENT_AREA_IMPORT_FAILED',

redisinsight/api/src/modules/bulk-actions/constants/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export enum BulkActionsServerEvents {
77
export enum BulkActionType {
88
Delete = 'delete',
99
Upload = 'upload',
10+
Unlink = 'unlink',
1011
}
1112

1213
export enum BulkActionStatus {
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import {
2+
mockSocket,
3+
mockBulkActionsAnalytics,
4+
mockCreateBulkActionDto,
5+
mockStandaloneRedisClient,
6+
} from 'src/__mocks__';
7+
import { UnlinkBulkActionSimpleRunner } from 'src/modules/bulk-actions/models/runners/simple/unlink.bulk-action.simple.runner';
8+
import { BulkAction } from 'src/modules/bulk-actions/models/bulk-action';
9+
import { RedisDataType } from 'src/modules/browser/keys/dto';
10+
import { BulkActionFilter } from 'src/modules/bulk-actions/models/bulk-action-filter';
11+
12+
const mockBulkActionFilter = Object.assign(new BulkActionFilter(), {
13+
count: 10_000,
14+
match: '*',
15+
type: RedisDataType.Set,
16+
});
17+
18+
const bulkAction = new BulkAction(
19+
mockCreateBulkActionDto.id,
20+
mockCreateBulkActionDto.databaseId,
21+
mockCreateBulkActionDto.type,
22+
mockBulkActionFilter,
23+
mockSocket,
24+
mockBulkActionsAnalytics as any,
25+
);
26+
27+
const mockKey = 'mockedKey';
28+
const mockKeyBuffer = Buffer.from(mockKey);
29+
30+
describe('UnlinkBulkActionSimpleRunner', () => {
31+
const client = mockStandaloneRedisClient;
32+
let unlinkRunner: UnlinkBulkActionSimpleRunner;
33+
34+
beforeEach(() => {
35+
unlinkRunner = new UnlinkBulkActionSimpleRunner(bulkAction, client);
36+
});
37+
38+
it('prepareCommands 3 commands', () => {
39+
const commands = unlinkRunner.prepareCommands([
40+
mockKeyBuffer,
41+
mockKeyBuffer,
42+
mockKeyBuffer,
43+
]);
44+
expect(commands).toEqual([
45+
['unlink', mockKeyBuffer],
46+
['unlink', mockKeyBuffer],
47+
['unlink', mockKeyBuffer],
48+
]);
49+
});
50+
51+
it('prepareCommands 0 commands', () => {
52+
const commands = unlinkRunner.prepareCommands([]);
53+
expect(commands).toEqual([]);
54+
});
55+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { AbstractBulkActionSimpleRunner } from 'src/modules/bulk-actions/models/runners/simple/abstract.bulk-action.simple.runner';
2+
import { RedisClientCommand } from 'src/modules/redis/client';
3+
4+
export class UnlinkBulkActionSimpleRunner extends AbstractBulkActionSimpleRunner {
5+
prepareCommands(keys: Buffer[]): RedisClientCommand[] {
6+
return keys.map((key) => ['unlink', key]);
7+
}
8+
}

redisinsight/api/src/modules/bulk-actions/providers/bulk-actions.provider.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ describe('BulkActionsProvider', () => {
9191

9292
expect(service['bulkActions'].size).toEqual(2);
9393
});
94+
it('should support unlink type', async () => {
95+
const bulkAction = await service.create(
96+
mockSessionMetadata,
97+
{ ...mockCreateBulkActionDto, type: BulkActionType.Unlink },
98+
mockSocket1,
99+
);
100+
101+
expect(bulkAction).toBeInstanceOf(BulkAction);
102+
expect(service['bulkActions'].size).toEqual(1);
103+
});
94104
it('should fail when unsupported runner class', async () => {
95105
try {
96106
await service.create(

redisinsight/api/src/modules/bulk-actions/providers/bulk-actions.provider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
BulkActionType,
1313
} from 'src/modules/bulk-actions/constants';
1414
import { DeleteBulkActionSimpleRunner } from 'src/modules/bulk-actions/models/runners/simple/delete.bulk-action.simple.runner';
15+
import { UnlinkBulkActionSimpleRunner } from 'src/modules/bulk-actions/models/runners/simple/unlink.bulk-action.simple.runner';
1516
import { BulkActionsAnalytics } from 'src/modules/bulk-actions/bulk-actions.analytics';
1617
import { ClientContext, SessionMetadata } from 'src/common/models';
1718
import { DatabaseClientFactory } from 'src/modules/database/providers/database.client.factory';
@@ -80,6 +81,8 @@ export class BulkActionsProvider {
8081
switch (dto.type) {
8182
case BulkActionType.Delete:
8283
return DeleteBulkActionSimpleRunner;
84+
case BulkActionType.Unlink:
85+
return UnlinkBulkActionSimpleRunner;
8386
default:
8487
throw new BadRequestException(
8588
`Unsupported type: ${dto.type} for Bulk Actions`,

redisinsight/api/src/modules/workbench/providers/workbench-commands.executor.spec.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ import {
2626
FormatterTypes,
2727
} from 'src/common/transformers';
2828
import { DatabaseClientFactory } from 'src/modules/database/providers/database.client.factory';
29-
import { RunQueryMode } from 'src/modules/workbench/models/command-execution';
29+
import {
30+
CommandExecutionType,
31+
RunQueryMode,
32+
} from 'src/modules/workbench/models/command-execution';
3033
import { WorkbenchAnalytics } from 'src/modules/workbench/workbench.analytics';
3134

3235
const MOCK_ERROR_MESSAGE = 'Some error';
@@ -85,6 +88,7 @@ describe('WorkbenchCommandsExecutor', () => {
8588
const result = await service.sendCommand(client, {
8689
command: 'ft.info idx',
8790
mode: RunQueryMode.Raw,
91+
type: CommandExecutionType.Workbench,
8892
});
8993

9094
expect(result).toEqual([
@@ -99,6 +103,7 @@ describe('WorkbenchCommandsExecutor', () => {
99103
).toHaveBeenCalledWith(
100104
mockSessionMetadata,
101105
mockWorkbenchClientMetadata.databaseId,
106+
CommandExecutionType.Workbench,
102107
[
103108
{
104109
response: mockRedisFtInfoReply,
@@ -113,6 +118,7 @@ describe('WorkbenchCommandsExecutor', () => {
113118
expect(mockAnalyticsService.sendIndexInfoEvent).toHaveBeenCalledWith(
114119
mockSessionMetadata,
115120
mockWorkbenchClientMetadata.databaseId,
121+
CommandExecutionType.Workbench,
116122
mockFtInfoAnalyticsData,
117123
);
118124
});
@@ -122,6 +128,7 @@ describe('WorkbenchCommandsExecutor', () => {
122128
const result = await service.sendCommand(client, {
123129
command: mockCreateCommandExecutionDto.command,
124130
mode: RunQueryMode.ASCII,
131+
type: CommandExecutionType.Workbench,
125132
});
126133

127134
expect(result).toEqual([
@@ -136,6 +143,7 @@ describe('WorkbenchCommandsExecutor', () => {
136143
).toHaveBeenCalledWith(
137144
mockSessionMetadata,
138145
mockWorkbenchClientMetadata.databaseId,
146+
CommandExecutionType.Workbench,
139147
[
140148
{
141149
response: mockCommandExecutionResult.response,
@@ -156,6 +164,7 @@ describe('WorkbenchCommandsExecutor', () => {
156164
const result = await service.sendCommand(client, {
157165
command: mockCreateCommandExecutionDto.command,
158166
mode: RunQueryMode.ASCII,
167+
type: CommandExecutionType.Workbench,
159168
});
160169

161170
expect(result).toEqual([
@@ -170,6 +179,7 @@ describe('WorkbenchCommandsExecutor', () => {
170179
).toHaveBeenCalledWith(
171180
mockSessionMetadata,
172181
mockWorkbenchClientMetadata.databaseId,
182+
CommandExecutionType.Workbench,
173183
{
174184
response: MOCK_ERROR_MESSAGE,
175185
error: new CommandNotSupportedError(MOCK_ERROR_MESSAGE),
@@ -192,6 +202,7 @@ describe('WorkbenchCommandsExecutor', () => {
192202
const result = await service.sendCommand(client, {
193203
command: mockCreateCommandExecutionDto.command,
194204
mode: RunQueryMode.ASCII,
205+
type: CommandExecutionType.Workbench,
195206
});
196207

197208
expect(result).toEqual([
@@ -206,6 +217,7 @@ describe('WorkbenchCommandsExecutor', () => {
206217
).toHaveBeenCalledWith(
207218
mockSessionMetadata,
208219
mockWorkbenchClientMetadata.databaseId,
220+
CommandExecutionType.Workbench,
209221
{
210222
response: MOCK_ERROR_MESSAGE,
211223
error: replyError,
@@ -227,6 +239,7 @@ describe('WorkbenchCommandsExecutor', () => {
227239
const result = await service.sendCommand(client, {
228240
command: mockCreateCommandExecutionDto.command,
229241
mode: RunQueryMode.ASCII,
242+
type: CommandExecutionType.Workbench,
230243
});
231244

232245
expect(result).toEqual([
@@ -242,6 +255,7 @@ describe('WorkbenchCommandsExecutor', () => {
242255
).toHaveBeenCalledWith(
243256
mockSessionMetadata,
244257
mockWorkbenchClientMetadata.databaseId,
258+
CommandExecutionType.Workbench,
245259
[
246260
{
247261
response: mockCommandExecutionResult.response,
@@ -264,6 +278,7 @@ describe('WorkbenchCommandsExecutor', () => {
264278
const result = await service.sendCommand(client, {
265279
command: mockCreateCommandExecutionDto.command,
266280
mode: RunQueryMode.Raw,
281+
type: CommandExecutionType.Workbench,
267282
});
268283

269284
expect(result).toEqual([
@@ -279,6 +294,7 @@ describe('WorkbenchCommandsExecutor', () => {
279294
).toHaveBeenCalledWith(
280295
mockSessionMetadata,
281296
mockWorkbenchClientMetadata.databaseId,
297+
CommandExecutionType.Workbench,
282298
[
283299
{
284300
response: mockCommandExecutionResult.response,
@@ -299,6 +315,7 @@ describe('WorkbenchCommandsExecutor', () => {
299315
const result = await service.sendCommand(client, {
300316
command: mockCreateCommandExecutionDto.command,
301317
mode: RunQueryMode.ASCII,
318+
type: CommandExecutionType.Workbench,
302319
});
303320

304321
expect(result).toEqual([
@@ -313,6 +330,7 @@ describe('WorkbenchCommandsExecutor', () => {
313330
).toHaveBeenCalledWith(
314331
mockSessionMetadata,
315332
mockWorkbenchClientMetadata.databaseId,
333+
CommandExecutionType.Workbench,
316334
{
317335
response: MOCK_ERROR_MESSAGE,
318336
error: new ServiceUnavailableException(MOCK_ERROR_MESSAGE),
@@ -337,6 +355,7 @@ describe('WorkbenchCommandsExecutor', () => {
337355
const result = await service.sendCommand(client, {
338356
command: mockGetEscapedKeyCommand,
339357
mode: RunQueryMode.ASCII,
358+
type: CommandExecutionType.Workbench,
340359
});
341360

342361
expect(result).toEqual(mockResult);
@@ -345,6 +364,7 @@ describe('WorkbenchCommandsExecutor', () => {
345364
).toHaveBeenCalledWith(
346365
mockSessionMetadata,
347366
mockWorkbenchClientMetadata.databaseId,
367+
CommandExecutionType.Workbench,
348368
{
349369
response: ERROR_MESSAGES.CLI_UNTERMINATED_QUOTES(),
350370
error: new CommandParsingError(

redisinsight/api/src/modules/workbench/providers/workbench-commands.executor.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export class WorkbenchCommandsExecutor {
7979
this.analyticsService.sendCommandExecutedEvents(
8080
client.clientMetadata.sessionMetadata,
8181
client.clientMetadata.databaseId,
82+
dto.type,
8283
result,
8384
{ command, rawMode: mode === RunQueryMode.Raw },
8485
);
@@ -87,6 +88,7 @@ export class WorkbenchCommandsExecutor {
8788
this.analyticsService.sendIndexInfoEvent(
8889
client.clientMetadata.sessionMetadata,
8990
client.clientMetadata.databaseId,
91+
dto.type,
9092
getAnalyticsDataFromIndexInfo(response as string[]),
9193
);
9294
}
@@ -102,6 +104,7 @@ export class WorkbenchCommandsExecutor {
102104
this.analyticsService.sendCommandExecutedEvent(
103105
client.clientMetadata.sessionMetadata,
104106
client.clientMetadata.databaseId,
107+
dto.type,
105108
{ ...errorResult, error },
106109
{ command, rawMode: dto.mode === RunQueryMode.Raw },
107110
);

0 commit comments

Comments
 (0)