Skip to content

Commit 24c97b6

Browse files
committed
#RI-3957 - add searchlight as part of modules of redistack
1 parent 8186226 commit 24c97b6

File tree

2 files changed

+54
-20
lines changed

2 files changed

+54
-20
lines changed

redisinsight/ui/src/utils/redistack.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
import { map, isEqual } from 'lodash'
1+
import { isArray, map } from 'lodash'
22
import { Instance, RedisDefaultModules } from 'uiSrc/slices/interfaces'
33

44
export const REDISTACK_PORT = 6379
5-
export const REDISTACK_MODULES = [
5+
export const REDISTACK_MODULES: Array<string | Array<string>> = [
66
RedisDefaultModules.ReJSON,
7+
RedisDefaultModules.Bloom,
78
RedisDefaultModules.Graph,
9+
[RedisDefaultModules.Search, RedisDefaultModules.SearchLight],
810
RedisDefaultModules.TimeSeries,
9-
RedisDefaultModules.Search,
10-
RedisDefaultModules.Bloom,
11-
].sort()
11+
]
1212

13-
const checkRediStackModules = (modules: any[]) => isEqual(map(modules, 'name').sort(), REDISTACK_MODULES)
13+
const checkRediStackModules = (modules: any[]) => map(modules, 'name')
14+
.sort()
15+
.every((m, index) => (isArray(REDISTACK_MODULES[index])
16+
? (REDISTACK_MODULES[index] as Array<string>).some((rm) => rm === m)
17+
: REDISTACK_MODULES[index] === m))
1418

1519
const checkRediStack = (instances: Instance[]): Instance[] => {
1620
let isRediStackCheck = false
@@ -25,6 +29,7 @@ const checkRediStack = (instances: Instance[]): Instance[] => {
2529
}
2630
})
2731

32+
// if no any database with redistack on port 6379 - mark others as redistack (with modules check)
2833
if (!isRediStackCheck) {
2934
newInstances = newInstances.map((instance) => ({
3035
...instance,

redisinsight/ui/src/utils/tests/redistack.spec.ts

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,51 @@
1-
import { checkRediStack, REDISTACK_MODULES, REDISTACK_PORT } from 'uiSrc/utils'
1+
/* eslint-disable max-len */
2+
import { checkRediStack, REDISTACK_PORT } from 'uiSrc/utils'
3+
import { RedisDefaultModules } from 'uiSrc/slices/interfaces'
24

35
const unmapWithName = (arr: any[]) => arr.map((item) => ({ name: item }))
46

5-
const REDISTACK_MODULE_DEFAULT = unmapWithName(REDISTACK_MODULES)
7+
const REDISTACK_MODULE_DEFAULT = unmapWithName([
8+
RedisDefaultModules.ReJSON,
9+
RedisDefaultModules.Graph,
10+
RedisDefaultModules.TimeSeries,
11+
RedisDefaultModules.Search,
12+
RedisDefaultModules.Bloom,
13+
].sort())
614

715
const getOutputCheckRediStackTests: any[] = [
8-
[[{ port: REDISTACK_PORT, modules: REDISTACK_MODULE_DEFAULT },
9-
{ port: 12000, modules: REDISTACK_MODULE_DEFAULT }],
10-
[{ port: REDISTACK_PORT, modules: REDISTACK_MODULE_DEFAULT, isRediStack: true },
11-
{ port: 12000, modules: REDISTACK_MODULE_DEFAULT, isRediStack: false }]],
12-
[[{ port: REDISTACK_PORT, modules: REDISTACK_MODULE_DEFAULT }],
13-
[{ port: REDISTACK_PORT, modules: REDISTACK_MODULE_DEFAULT, isRediStack: true }]],
14-
[[{ port: REDISTACK_PORT, modules: unmapWithName(['']) }], [{ port: REDISTACK_PORT, modules: unmapWithName(['']), isRediStack: false }]],
15-
[[{ port: REDISTACK_PORT, modules: unmapWithName(['search']) }], [{ port: REDISTACK_PORT, modules: unmapWithName(['search']), isRediStack: false }]],
16-
[[{ port: REDISTACK_PORT, modules: unmapWithName(['bf', 'search', 'timeseries']) }], [{ port: REDISTACK_PORT, modules: unmapWithName(['bf', 'search', 'timeseries']), isRediStack: false }]],
17-
[[{ port: 12000, modules: REDISTACK_MODULE_DEFAULT }],
18-
[{ port: 12000, modules: REDISTACK_MODULE_DEFAULT, isRediStack: true }]],
19-
[[{ port: 12000, modules: unmapWithName(['search']) }], [{ port: 12000, modules: unmapWithName(['search']), isRediStack: false }]],
16+
[
17+
[{ port: REDISTACK_PORT, modules: REDISTACK_MODULE_DEFAULT }, { port: 12000, modules: REDISTACK_MODULE_DEFAULT }],
18+
[{ port: REDISTACK_PORT, modules: REDISTACK_MODULE_DEFAULT, isRediStack: true }, { port: 12000, modules: REDISTACK_MODULE_DEFAULT, isRediStack: false }]
19+
],
20+
[
21+
[{ port: REDISTACK_PORT, modules: REDISTACK_MODULE_DEFAULT }],
22+
[{ port: REDISTACK_PORT, modules: REDISTACK_MODULE_DEFAULT, isRediStack: true }]
23+
],
24+
[
25+
[{ port: REDISTACK_PORT, modules: unmapWithName(['']) }],
26+
[{ port: REDISTACK_PORT, modules: unmapWithName(['']), isRediStack: false }]
27+
],
28+
[
29+
[{ port: REDISTACK_PORT, modules: unmapWithName(['search']) }],
30+
[{ port: REDISTACK_PORT, modules: unmapWithName(['search']), isRediStack: false }]
31+
],
32+
[
33+
[{ port: REDISTACK_PORT, modules: unmapWithName(['bf', 'search', 'timeseries']) }],
34+
[{ port: REDISTACK_PORT, modules: unmapWithName(['bf', 'search', 'timeseries']), isRediStack: false }]
35+
],
36+
[
37+
[{ port: 12000, modules: REDISTACK_MODULE_DEFAULT }],
38+
[{ port: 12000, modules: REDISTACK_MODULE_DEFAULT, isRediStack: true }]
39+
],
40+
[
41+
[{ port: 12000, modules: unmapWithName(['search']) }],
42+
[{ port: 12000, modules: unmapWithName(['search']), isRediStack: false }]
43+
],
44+
// check searchlight - should be also marked as RediStack
45+
[
46+
[{ port: 12000, modules: unmapWithName(['bf', 'timeseries', 'ReJSON', 'searchlight', 'graph']) }],
47+
[{ port: 12000, modules: unmapWithName(['bf', 'timeseries', 'ReJSON', 'searchlight', 'graph']), isRediStack: true }]
48+
],
2049
]
2150

2251
describe('checkRediStack', () => {

0 commit comments

Comments
 (0)