Skip to content

Commit 272498b

Browse files
committed
test: improve version-specific test coverage
- Add `testWithClientIfVersionWithinRange` method to run tests for specific Redis versions - Refactor TestUtils to handle version comparisons more accurately - Update test utilities across Redis modules to run tests against multiple versions, and not against latest only
1 parent d647d34 commit 272498b

File tree

17 files changed

+469
-191
lines changed

17 files changed

+469
-191
lines changed

packages/bloom/lib/test-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import TestUtils from '@redis/test-utils';
22
import RedisBloomModules from '.';
33

4-
export default new TestUtils({
4+
export default TestUtils.createFromConfig({
55
dockerImageName: 'redislabs/client-libs-test',
6-
dockerImageVersionArgument: 'redisbloom-version',
6+
dockerImageVersionArgument: 'redis-version',
77
defaultDockerVersion: '8.0-M04-pre'
88
});
99

packages/client/lib/test-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { CredentialsProvider } from './authx';
55
import { Command } from './RESP/types';
66
import { BasicCommandParser } from './client/parser';
77

8-
const utils = new TestUtils({
8+
const utils = TestUtils.createFromConfig({
99
dockerImageName: 'redislabs/client-libs-test',
1010
dockerImageVersionArgument: 'redis-version',
1111
defaultDockerVersion: '8.0-M04-pre'

packages/entraid/lib/test-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { IdentityProvider, StreamingCredentialsProvider, TokenManager, TokenResp
33
import TestUtils from '@redis/test-utils';
44
import { EntraidCredentialsProvider } from './entraid-credentials-provider';
55

6-
export const testUtils = new TestUtils({
6+
export const testUtils = TestUtils.createFromConfig({
77
dockerImageName: 'redislabs/client-libs-test',
88
dockerImageVersionArgument: 'redis-version',
99
defaultDockerVersion: '8.0-M04-pre'

packages/graph/lib/test-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import TestUtils from '@redis/test-utils';
22
import RedisGraph from '.';
33

44

5-
export default new TestUtils({
5+
export default TestUtils.createFromConfig({
66
dockerImageName: 'redislabs/client-libs-test',
7-
dockerImageVersionArgument: 'redisgraph-version',
7+
dockerImageVersionArgument: 'redis-version',
88
defaultDockerVersion: '8.0-M04-pre'
99
});
1010

packages/json/lib/test-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import TestUtils from '@redis/test-utils';
22
import RedisJSON from '.';
33

4-
export default new TestUtils({
4+
export default TestUtils.createFromConfig({
55
dockerImageName: 'redislabs/client-libs-test',
6-
dockerImageVersionArgument: 'redisgraph-version',
6+
dockerImageVersionArgument: 'redis-version',
77
defaultDockerVersion: '8.0-M04-pre'
88
});
99

packages/search/lib/commands/CONFIG_SET.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('FT.CONFIG SET', () => {
1818
);
1919
}, GLOBAL.SERVERS.OPEN);
2020

21-
testUtils.testWithClient('setSearchConfigGloballyTest', async client => {
21+
testUtils.testWithClientIfVersionWithinRange([[8], 'LATEST'], 'setSearchConfigGloballyTest', async client => {
2222

2323
const normalizeObject = obj => JSON.parse(JSON.stringify(obj));
2424
assert.equal(await client.configSet('search-default-dialect', '3'),

packages/search/lib/commands/INFO.spec.ts

Lines changed: 200 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -5,112 +5,209 @@ import { SCHEMA_FIELD_TYPE } from './CREATE';
55
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
66

77
describe('INFO', () => {
8-
it('transformArguments', () => {
9-
assert.deepEqual(
10-
parseArgs(INFO, 'index'),
11-
['FT.INFO', 'index']
12-
);
8+
it('transformArguments', () => {
9+
assert.deepEqual(
10+
parseArgs(INFO, 'index'),
11+
['FT.INFO', 'index']
12+
);
13+
});
14+
15+
testUtils.testWithClientIfVersionWithinRange([[8], 'LATEST'], 'client.ft.info', async client => {
16+
17+
await client.ft.create('index', {
18+
field: SCHEMA_FIELD_TYPE.TEXT
1319
});
20+
const ret = await client.ft.info('index');
21+
// effectively testing that stopwords_list is not in ret
22+
assert.deepEqual(
23+
ret,
24+
{
25+
index_name: 'index',
26+
index_options: [],
27+
index_definition: Object.create(null, {
28+
29+
indexes_all: {
30+
value: 'false',
31+
configurable: true,
32+
enumerable: true
33+
},
1434

15-
testUtils.testWithClient('client.ft.info', async client => {
16-
await client.ft.create('index', {
17-
field: SCHEMA_FIELD_TYPE.TEXT
18-
});
19-
const ret = await client.ft.info('index');
20-
// effectively testing that stopwords_list is not in ret
21-
assert.deepEqual(
22-
ret,
23-
{
24-
index_name: 'index',
25-
index_options: [],
26-
index_definition: Object.create(null, {
35+
default_score: {
36+
value: '1',
37+
configurable: true,
38+
enumerable: true
39+
},
40+
key_type: {
41+
value: 'HASH',
42+
configurable: true,
43+
enumerable: true
44+
},
45+
prefixes: {
46+
value: [''],
47+
configurable: true,
48+
enumerable: true
49+
}
50+
}),
51+
attributes: [Object.create(null, {
52+
identifier: {
53+
value: 'field',
54+
configurable: true,
55+
enumerable: true
56+
},
57+
attribute: {
58+
value: 'field',
59+
configurable: true,
60+
enumerable: true
61+
},
62+
type: {
63+
value: 'TEXT',
64+
configurable: true,
65+
enumerable: true
66+
},
67+
WEIGHT: {
68+
value: '1',
69+
configurable: true,
70+
enumerable: true
71+
}
72+
})],
73+
num_docs: 0,
74+
max_doc_id: 0,
75+
num_terms: 0,
76+
num_records: 0,
77+
inverted_sz_mb: 0,
78+
vector_index_sz_mb: 0,
79+
total_inverted_index_blocks: 0,
80+
offset_vectors_sz_mb: 0,
81+
doc_table_size_mb: 0,
82+
sortable_values_size_mb: 0,
83+
key_table_size_mb: 0,
84+
records_per_doc_avg: NaN,
85+
bytes_per_record_avg: NaN,
86+
cleaning: 0,
87+
offsets_per_term_avg: NaN,
88+
offset_bits_per_record_avg: NaN,
89+
geoshapes_sz_mb: 0,
90+
hash_indexing_failures: 0,
91+
indexing: 0,
92+
percent_indexed: 1,
93+
number_of_uses: 1,
94+
tag_overhead_sz_mb: 0,
95+
text_overhead_sz_mb: 0,
96+
total_index_memory_sz_mb: 0,
97+
total_indexing_time: 0,
98+
gc_stats: {
99+
bytes_collected: 0,
100+
total_ms_run: 0,
101+
total_cycles: 0,
102+
average_cycle_time_ms: NaN,
103+
last_run_time_ms: 0,
104+
gc_numeric_trees_missed: 0,
105+
gc_blocks_denied: 0
106+
},
107+
cursor_stats: {
108+
global_idle: 0,
109+
global_total: 0,
110+
index_capacity: 128,
111+
index_total: 0
112+
},
113+
}
114+
);
27115

28-
indexes_all: {
29-
value: 'false',
30-
configurable: true,
31-
enumerable: true
32-
},
116+
}, GLOBAL.SERVERS.OPEN);
33117

34-
default_score: {
35-
value: '1',
36-
configurable: true,
37-
enumerable: true
38-
},
39-
key_type: {
40-
value: 'HASH',
41-
configurable: true,
42-
enumerable: true
43-
},
44-
prefixes: {
45-
value: [''],
46-
configurable: true,
47-
enumerable: true
48-
}
49-
}),
50-
attributes: [Object.create(null, {
51-
identifier: {
52-
value: 'field',
53-
configurable: true,
54-
enumerable: true
55-
},
56-
attribute: {
57-
value: 'field',
58-
configurable: true,
59-
enumerable: true
60-
},
61-
type: {
62-
value: 'TEXT',
63-
configurable: true,
64-
enumerable: true
65-
},
66-
WEIGHT: {
67-
value: '1',
68-
configurable: true,
69-
enumerable: true
70-
}
71-
})],
72-
num_docs: 0,
73-
max_doc_id: 0,
74-
num_terms: 0,
75-
num_records: 0,
76-
inverted_sz_mb: 0,
77-
vector_index_sz_mb: 0,
78-
total_inverted_index_blocks: 0,
79-
offset_vectors_sz_mb: 0,
80-
doc_table_size_mb: 0,
81-
sortable_values_size_mb: 0,
82-
key_table_size_mb: 0,
83-
records_per_doc_avg: NaN,
84-
bytes_per_record_avg: NaN,
85-
cleaning: 0,
86-
offsets_per_term_avg: NaN,
87-
offset_bits_per_record_avg: NaN,
88-
geoshapes_sz_mb: 0,
89-
hash_indexing_failures: 0,
90-
indexing: 0,
91-
percent_indexed: 1,
92-
number_of_uses: 1,
93-
tag_overhead_sz_mb: 0,
94-
text_overhead_sz_mb: 0,
95-
total_index_memory_sz_mb: 0,
96-
total_indexing_time: 0,
97-
gc_stats: {
98-
bytes_collected: 0,
99-
total_ms_run: 0,
100-
total_cycles: 0,
101-
average_cycle_time_ms: NaN,
102-
last_run_time_ms: 0,
103-
gc_numeric_trees_missed: 0,
104-
gc_blocks_denied: 0
105-
},
106-
cursor_stats: {
107-
global_idle: 0,
108-
global_total: 0,
109-
index_capacity: 128,
110-
index_total: 0
111-
},
112-
}
113-
);
118+
testUtils.testWithClientIfVersionWithinRange([[6, 2, 6], [7, 4, 2]], 'client.ft.info', async client => {
119+
120+
await client.ft.create('index', {
121+
field: SCHEMA_FIELD_TYPE.TEXT
122+
});
123+
const ret = await client.ft.info('index');
124+
// effectively testing that stopwords_list is not in ret
125+
assert.deepEqual(
126+
ret,
127+
{
128+
index_name: 'index',
129+
index_options: [],
130+
index_definition: Object.create(null, {
131+
default_score: {
132+
value: '1',
133+
configurable: true,
134+
enumerable: true
135+
},
136+
key_type: {
137+
value: 'HASH',
138+
configurable: true,
139+
enumerable: true
140+
},
141+
prefixes: {
142+
value: [''],
143+
configurable: true,
144+
enumerable: true
145+
}
146+
}),
147+
attributes: [Object.create(null, {
148+
identifier: {
149+
value: 'field',
150+
configurable: true,
151+
enumerable: true
152+
},
153+
attribute: {
154+
value: 'field',
155+
configurable: true,
156+
enumerable: true
157+
},
158+
type: {
159+
value: 'TEXT',
160+
configurable: true,
161+
enumerable: true
162+
},
163+
WEIGHT: {
164+
value: '1',
165+
configurable: true,
166+
enumerable: true
167+
}
168+
})],
169+
num_docs: 0,
170+
max_doc_id: 0,
171+
num_terms: 0,
172+
num_records: 0,
173+
inverted_sz_mb: 0,
174+
vector_index_sz_mb: 0,
175+
total_inverted_index_blocks: 0,
176+
offset_vectors_sz_mb: 0,
177+
doc_table_size_mb: 0,
178+
sortable_values_size_mb: 0,
179+
key_table_size_mb: 0,
180+
records_per_doc_avg: NaN,
181+
bytes_per_record_avg: NaN,
182+
cleaning: 0,
183+
offsets_per_term_avg: NaN,
184+
offset_bits_per_record_avg: NaN,
185+
geoshapes_sz_mb: 0,
186+
hash_indexing_failures: 0,
187+
indexing: 0,
188+
percent_indexed: 1,
189+
number_of_uses: 1,
190+
tag_overhead_sz_mb: 0,
191+
text_overhead_sz_mb: 0,
192+
total_index_memory_sz_mb: 0,
193+
total_indexing_time: 0,
194+
gc_stats: {
195+
bytes_collected: 0,
196+
total_ms_run: 0,
197+
total_cycles: 0,
198+
average_cycle_time_ms: NaN,
199+
last_run_time_ms: 0,
200+
gc_numeric_trees_missed: 0,
201+
gc_blocks_denied: 0
202+
},
203+
cursor_stats: {
204+
global_idle: 0,
205+
global_total: 0,
206+
index_capacity: 128,
207+
index_total: 0
208+
},
209+
}
210+
);
114211

115-
}, GLOBAL.SERVERS.OPEN);
212+
}, GLOBAL.SERVERS.OPEN);
116213
});

0 commit comments

Comments
 (0)