Skip to content

Commit 4f4b62b

Browse files
committed
Merge branch 'main' into feature/RI-3637_databases-import
2 parents 294d730 + bb4272e commit 4f4b62b

File tree

225 files changed

+5088
-2453
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

225 files changed

+5088
-2453
lines changed

.circleci/config.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -877,30 +877,29 @@ workflows:
877877
jobs:
878878
- unit-tests-ui:
879879
name: UTest - UI
880-
# filters:
881-
# branches:
882-
# only:
883-
# - /^fe/feature.*/
884-
# - /^fe/bugfix.*/
880+
filters:
881+
branches:
882+
only:
883+
- /^fe/feature.*/
884+
- /^fe/bugfix.*/
885885
# BE Unit + Integration (limited RTEs) tests for "be/feature" or "be/bugfix" branches only
886886
backend-tests:
887887
jobs:
888888
- unit-tests-api:
889889
name: UTest - API
890-
# filters:
891-
# branches:
892-
# only:
893-
# - /^be/feature.*/
894-
# - /^be/bugfix.*/
890+
filters:
891+
branches:
892+
only:
893+
- /^be/feature.*/
894+
- /^be/bugfix.*/
895895
- integration-tests-run:
896896
matrix:
897897
alias: itest-code
898898
parameters:
899-
rte: *iTestsNames
900-
# rte: *iTestsNamesShort
899+
rte: *iTestsNamesShort
901900
name: ITest - << matrix.rte >> (code)
902-
# requires:
903-
# - UTest - API
901+
requires:
902+
- UTest - API
904903
# E2E tests for "e2e/feature" or "e2e/bugfix" branches only
905904
e2e-tests:
906905
jobs:

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ renderer.prod.js.map
4646
redisinsight/ui/style.css
4747
redisinsight/ui/style.css.map
4848
redisinsight/ui/dist
49+
redisinsight/api/commands
50+
redisinsight/api/guides
51+
redisinsight/api/tutorials
52+
redisinsight/api/content
4953
dist
5054
distWeb
5155
dll

jest.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ module.exports = {
5454
],
5555
coverageThreshold: {
5656
global: {
57-
statements: 70,
58-
branches: 50,
59-
functions: 60,
60-
lines: 72,
57+
statements: 77,
58+
branches: 55,
59+
functions: 65,
60+
lines: 75,
6161
},
6262
// './redisinsight/ui/src/slices/**/*.ts': {
6363
// statements: 90,
Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,49 @@
1-
import * as React from 'react';
1+
import React, { useEffect } from 'react';
22

33
export default function MonacoEditor(props) {
4-
return <div {...props} data-testid="monaco"/>;
4+
useEffect(() => {
5+
props.editorDidMount && props.editorDidMount(
6+
// editor
7+
{
8+
addCommand: jest.fn(),
9+
getContribution: jest.fn(),
10+
onKeyDown: jest.fn(),
11+
onMouseDown: jest.fn(),
12+
addAction: jest.fn(),
13+
getAction: jest.fn(),
14+
deltaDecorations: jest.fn(),
15+
createContextKey: jest.fn(),
16+
focus: jest.fn(),
17+
onDidChangeCursorPosition: jest.fn(),
18+
executeEdits: jest.fn()
19+
},
20+
// monaco
21+
{
22+
Range: jest.fn().mockImplementation(() => { return {} }),
23+
languages: {
24+
getLanguages: jest.fn(),
25+
register: jest.fn(),
26+
registerCompletionItemProvider: jest.fn().mockReturnValue({
27+
dispose: jest.fn()
28+
}),
29+
registerSignatureHelpProvider: jest.fn().mockReturnValue({
30+
dispose: jest.fn()
31+
}),
32+
setLanguageConfiguration: jest.fn(),
33+
setMonarchTokensProvider: jest.fn(),
34+
},
35+
KeyMod: {},
36+
KeyCode: {}
37+
})
38+
}, [])
39+
return <input {...props} data-testid="monaco"/>;
40+
}
41+
42+
export const languages = {
43+
CompletionItemKind: {
44+
Function: 1
45+
},
46+
CompletionItemInsertTextRule: {
47+
InsertAsSnippet: 4
48+
}
549
}

redisinsight/api/src/__mocks__/certificates.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ export const mockCaCertificateRepository = jest.fn(() => ({
4141
}));
4242

4343
export const mockCaCertificateService = jest.fn(() => ({
44-
getAll: jest.fn(),
45-
getOneById: jest.fn(),
44+
get: jest.fn().mockResolvedValue(mockCaCertificate),
4645
}));
4746

4847
// ================== Client Certificate ==================
@@ -85,6 +84,5 @@ export const mockClientCertificateRepository = jest.fn(() => ({
8584
}));
8685

8786
export const mockClientCertificateService = jest.fn(() => ({
88-
getAll: jest.fn(),
89-
getOneById: jest.fn(),
87+
get: jest.fn().mockResolvedValue(mockClientCertificate),
9088
}));

redisinsight/api/src/__mocks__/databases.ts

Lines changed: 105 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import { Database } from 'src/modules/database/models/database';
2-
import {
3-
mockCaCertificate,
4-
mockClientCertificate,
5-
} from 'src/__mocks__/certificates';
2+
import { mockCaCertificate, mockClientCertificate } from 'src/__mocks__/certificates';
63
import { SentinelMaster } from 'src/modules/redis-sentinel/models/sentinel-master';
74
import { ConnectionType, DatabaseEntity } from 'src/modules/database/entities/database.entity';
85
import { EncryptionStrategy } from 'src/modules/encryption/models';
96
import { mockIORedisClient } from 'src/__mocks__/redis';
7+
import { mockSentinelMasterDto } from 'src/__mocks__/redis-sentinel';
8+
import { pick } from 'lodash';
9+
import { RedisDatabaseInfoResponse } from 'src/modules/database/dto/redis-info.dto';
10+
import { ClientMetadata } from 'src/modules/redis/models/client-metadata';
11+
import { AppTool } from 'src/models';
12+
import { DatabaseOverview } from 'src/modules/database/models/database-overview';
1013

1114
export const mockDatabaseId = 'a77b23c1-7816-4ea4-b61f-d37795a0f805-db-id';
1215

@@ -21,8 +24,8 @@ export const mockDatabaseSentinelMasterPasswordPlain = 'some sentinel pass';
2124
export const mockDatabase = Object.assign(new Database(), {
2225
id: mockDatabaseId,
2326
name: 'database-name',
24-
host: 'localhost',
25-
port: 3679,
27+
host: '127.0.100.1',
28+
port: 6379,
2629
connectionType: ConnectionType.STANDALONE,
2730
});
2831

@@ -69,7 +72,7 @@ export const mockDatabaseWithTlsAuthEntity = Object.assign(new DatabaseEntity(),
6972
});
7073

7174
export const mockSentinelMaster = Object.assign(new SentinelMaster(), {
72-
name: 'master_group_name',
75+
name: 'mymaster',
7376
username: 'master_group_username',
7477
password: mockDatabaseSentinelMasterPasswordPlain,
7578
});
@@ -78,6 +81,7 @@ export const mockSentinelDatabaseWithTlsAuth = Object.assign(new Database(), {
7881
...mockDatabaseWithTlsAuth,
7982
sentinelMaster: mockSentinelMaster,
8083
connectionType: ConnectionType.SENTINEL,
84+
nodes: mockSentinelMasterDto.nodes,
8185
});
8286

8387
export const mockSentinelDatabaseWithTlsAuthEntity = Object.assign(new DatabaseEntity(), {
@@ -86,18 +90,83 @@ export const mockSentinelDatabaseWithTlsAuthEntity = Object.assign(new DatabaseE
8690
sentinelMasterUsername: mockSentinelMaster.username,
8791
sentinelMasterPassword: mockDatabaseSentinelMasterPasswordEncrypted,
8892
connectionType: ConnectionType.SENTINEL,
93+
nodes: JSON.stringify(mockSentinelDatabaseWithTlsAuth.nodes),
8994
});
95+
export const mockClusterNodes = [
96+
{
97+
host: '127.0.100.1',
98+
port: 6379,
99+
},
100+
{
101+
host: '127.0.100.2',
102+
port: 6379,
103+
},
104+
];
90105

91106
export const mockClusterDatabaseWithTlsAuth = Object.assign(new Database(), {
92107
...mockDatabaseWithTlsAuth,
93108
connectionType: ConnectionType.CLUSTER,
109+
nodes: mockClusterNodes,
94110
});
95111

96112
export const mockClusterDatabaseWithTlsAuthEntity = Object.assign(new DatabaseEntity(), {
97113
...mockDatabaseWithTlsAuthEntity,
98114
connectionType: ConnectionType.CLUSTER,
115+
nodes: JSON.stringify(mockClusterNodes),
99116
});
100117

118+
export const mockClientMetadata: ClientMetadata = {
119+
databaseId: mockDatabase.id,
120+
namespace: AppTool.Common,
121+
};
122+
123+
export const mockDatabaseOverview: DatabaseOverview = {
124+
version: '6.2.4',
125+
usedMemory: 1,
126+
totalKeys: 2,
127+
totalKeysPerDb: {
128+
db0: 1,
129+
},
130+
connectedClients: 1,
131+
opsPerSecond: 1,
132+
networkInKbps: 1,
133+
networkOutKbps: 1,
134+
cpuUsagePercentage: null,
135+
};
136+
137+
export const mockRedisServerInfoDto = {
138+
redis_version: '6.0.5',
139+
redis_mode: 'standalone',
140+
os: 'Linux 4.15.0-1087-gcp x86_64',
141+
arch_bits: '64',
142+
tcp_port: '11113',
143+
uptime_in_seconds: '1000',
144+
};
145+
146+
export const mockRedisGeneralInfo: RedisDatabaseInfoResponse = {
147+
version: mockRedisServerInfoDto.redis_version,
148+
databases: 16,
149+
role: 'master',
150+
server: mockRedisServerInfoDto,
151+
usedMemory: 1000000,
152+
totalKeys: 1,
153+
connectedClients: 1,
154+
uptimeInSeconds: 1000,
155+
hitRatio: 1,
156+
};
157+
158+
export const mockDatabaseRepository = jest.fn(() => ({
159+
exists: jest.fn().mockResolvedValue(true),
160+
get: jest.fn().mockResolvedValue(mockDatabase),
161+
create: jest.fn().mockResolvedValue(mockDatabase),
162+
update: jest.fn().mockResolvedValue(mockDatabase),
163+
delete: jest.fn(),
164+
list: jest.fn().mockResolvedValue([
165+
pick(mockDatabase, 'id', 'name'),
166+
pick(mockDatabase, 'id', 'name'),
167+
]),
168+
}));
169+
101170
export const mockDatabaseService = jest.fn(() => ({
102171
get: jest.fn().mockResolvedValue(mockDatabase),
103172
create: jest.fn().mockResolvedValue(mockDatabase),
@@ -107,3 +176,32 @@ export const mockDatabaseService = jest.fn(() => ({
107176
export const mockDatabaseConnectionService = jest.fn(() => ({
108177
getOrCreateClient: jest.fn().mockResolvedValue(mockIORedisClient),
109178
}));
179+
180+
export const mockDatabaseInfoProvider = jest.fn(() => ({
181+
isCluster: jest.fn(),
182+
isSentinel: jest.fn(),
183+
determineDatabaseModules: jest.fn(),
184+
determineSentinelMasterGroups: jest.fn().mockReturnValue([mockSentinelMasterDto]),
185+
determineClusterNodes: jest.fn().mockResolvedValue(mockClusterNodes),
186+
getRedisGeneralInfo: jest.fn().mockResolvedValueOnce(mockRedisGeneralInfo),
187+
}));
188+
189+
export const mockDatabaseOverviewProvider = jest.fn(() => ({
190+
getOverview: jest.fn().mockResolvedValue(mockDatabaseOverview),
191+
}));
192+
193+
export const mockDatabaseFactory = jest.fn(() => ({
194+
createDatabaseModel: jest.fn().mockResolvedValue(mockDatabase),
195+
createStandaloneDatabaseModel: jest.fn().mockResolvedValue(mockDatabase),
196+
createClusterDatabaseModel: jest.fn().mockResolvedValue(mockClusterDatabaseWithTlsAuth),
197+
createSentinelDatabaseModel: jest.fn().mockResolvedValue(mockSentinelDatabaseWithTlsAuth),
198+
}));
199+
200+
export const mockDatabaseAnalytics = jest.fn(() => ({
201+
sendInstanceListReceivedEvent: jest.fn(),
202+
sendConnectionFailedEvent: jest.fn(),
203+
sendInstanceAddedEvent: jest.fn(),
204+
sendInstanceAddFailedEvent: jest.fn(),
205+
sendInstanceEditedEvent: jest.fn(),
206+
sendInstanceDeletedEvent: jest.fn(),
207+
}));

redisinsight/api/src/__mocks__/errors.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { ReplyError } from 'src/models';
22

3+
export const mockRedisNoAuthError: ReplyError = {
4+
name: 'ReplyError',
5+
command: 'AUTH',
6+
message: 'NOAUTH authentication is required',
7+
};
8+
39
export const mockRedisNoPermError: ReplyError = {
410
name: 'ReplyError',
511
command: 'GET',

redisinsight/api/src/__mocks__/redis-sentinel.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import { SentinelMaster, SentinelMasterStatus } from 'src/modules/redis-sentinel/models/sentinel-master';
2+
import { Endpoint } from 'src/common/models';
23

3-
export const mockSentinelMasterDto: SentinelMaster = {
4-
name: 'mymaster',
4+
export const mockSentinelMasterEndpoint: Endpoint = {
55
host: '127.0.0.1',
66
port: 6379,
7+
};
8+
9+
export const mockSentinelMasterDto: SentinelMaster = {
10+
name: 'mymaster',
11+
host: mockSentinelMasterEndpoint.host,
12+
port: mockSentinelMasterEndpoint.port,
713
numberOfSlaves: 1,
814
status: SentinelMasterStatus.Active,
915
nodes: [{

0 commit comments

Comments
 (0)