Skip to content

Commit c6ff61c

Browse files
authored
Merge pull request #1551 from RedisInsight/fe/feature/RI-3957_redistack-modules
#RI-3957 - add searchlight as part of modules of redistack
2 parents b052e16 + 764621f commit c6ff61c

File tree

5 files changed

+77
-20
lines changed

5 files changed

+77
-20
lines changed

redisinsight/ui/src/utils/redistack.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
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[]) => {
14+
if (!modules?.length || modules.length !== REDISTACK_MODULES.length) return false
15+
16+
return map(modules, 'name')
17+
.sort()
18+
.every((m, index) => (isArray(REDISTACK_MODULES[index])
19+
? (REDISTACK_MODULES[index] as Array<string>).some((rm) => rm === m)
20+
: REDISTACK_MODULES[index] === m))
21+
}
1422

1523
const checkRediStack = (instances: Instance[]): Instance[] => {
1624
let isRediStackCheck = false
@@ -25,6 +33,7 @@ const checkRediStack = (instances: Instance[]): Instance[] => {
2533
}
2634
})
2735

36+
// if no any database with redistack on port 6379 - mark others as redistack (with modules check)
2837
if (!isRediStackCheck) {
2938
newInstances = newInstances.map((instance) => ({
3039
...instance,

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

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,63 @@
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+
],
49+
[
50+
[{ port: 12000, modules: [] }],
51+
[{ port: 12000, modules: [], isRediStack: false }]
52+
],
53+
[
54+
[{ port: 12000, modules: unmapWithName(['ReJSON']) }],
55+
[{ port: 12000, modules: unmapWithName(['ReJSON']), isRediStack: false }]
56+
],
57+
[
58+
[{ port: 12000, modules: unmapWithName(['bf', 'timeseries', 'ReJSON', 'searchlight', 'graph', 'custom']) }],
59+
[{ port: 12000, modules: unmapWithName(['bf', 'timeseries', 'ReJSON', 'searchlight', 'graph', 'custom']), isRediStack: false }]
60+
],
2061
]
2162

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

tests/e2e/pageObjects/my-redis-databases-page.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export class MyRedisDatabasePage {
99
//-------------------------------------------------------------------------------------------
1010
// CSS Selectors
1111
cssNumberOfDbs = '[data-testid=number-of-dbs]';
12+
cssRedisStackIcon = '[data-testid=redis-stack-icon]';
1213
//BUTTONS
1314
settingsButton = Selector('[data-testid=settings-page-btn]');
1415
workbenchButton = Selector('[data-testid=workbench-page-btn]');

tests/e2e/tests/regression/database/database-list-search.e2e.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ test('Verify DB list search', async t => {
5656
const searchTimeout = 60 * 1000; // 60 sec to wait for changing Last Connection time
5757
const dbSelector = myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[2].databaseName);
5858
const startTime = Date.now();
59+
const noModulesDbRedisStackIcon = myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[2].databaseName).parent('tr').find(myRedisDatabasePage.cssRedisStackIcon);
60+
61+
// Verify that db without modules has no redis stack icon
62+
await t.expect(noModulesDbRedisStackIcon.exists).notOk('The database with other alias is found');
5963

6064
// Search for DB by Invalid search
6165
await t.typeText(myRedisDatabasePage.searchInput, searchedDBHostInvalid, { replace: true, paste: true });

tests/e2e/tests/smoke/database/add-standalone-db.e2e.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,6 @@ test
6767
await addRECloudDatabase(cloudDatabaseConfig);
6868
// Verify new connection badge for RE cloud
6969
await myRedisDatabasePage.verifyDatabaseStatusIsVisible();
70+
// Verify redis stack icon for RE Cloud with all 5 modules
71+
await t.expect(myRedisDatabasePage.redisStackIcon.visible).ok('Redis Stack icon not found for RE Cloud db with all 5 modules');
7072
});

0 commit comments

Comments
 (0)