diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2026-01-21 22:40:55 +0100 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2026-01-21 22:40:55 +0100 |
| commit | 5d8dfe892a2ea89f706ee140c3bdcfd89fe03fda (patch) | |
| tree | 1acdfa5220cd13b7be43a2a01368e80d306473ca /examples/redis-unstable/modules/vector-sets/tests/vsim_limit_efsearch.py | |
| parent | c7ab12bba64d9c20ccd79b132dac475f7bc3923e (diff) | |
| download | crep-5d8dfe892a2ea89f706ee140c3bdcfd89fe03fda.tar.gz | |
Add Redis source code for testing
Diffstat (limited to 'examples/redis-unstable/modules/vector-sets/tests/vsim_limit_efsearch.py')
| -rw-r--r-- | examples/redis-unstable/modules/vector-sets/tests/vsim_limit_efsearch.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/examples/redis-unstable/modules/vector-sets/tests/vsim_limit_efsearch.py b/examples/redis-unstable/modules/vector-sets/tests/vsim_limit_efsearch.py new file mode 100644 index 0000000..25b9689 --- /dev/null +++ b/examples/redis-unstable/modules/vector-sets/tests/vsim_limit_efsearch.py | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | from test import TestCase, generate_random_vector | ||
| 2 | import struct | ||
| 3 | |||
| 4 | class VSIMLimitEFSearch(TestCase): | ||
| 5 | def getname(self): | ||
| 6 | return "VSIM Limit EF Search" | ||
| 7 | |||
| 8 | def estimated_runtime(self): | ||
| 9 | return 0.2 | ||
| 10 | |||
| 11 | def test(self): | ||
| 12 | dim = 32 | ||
| 13 | vec = generate_random_vector(dim) | ||
| 14 | vec_bytes = struct.pack(f'{dim}f', *vec) | ||
| 15 | |||
| 16 | # Add test vector | ||
| 17 | self.redis.execute_command('VADD', self.test_key, 'FP32', vec_bytes, f'{self.test_key}:item:1') | ||
| 18 | |||
| 19 | query_vec = generate_random_vector(dim) | ||
| 20 | |||
| 21 | # Test EF upper bound (should accept 1000000) | ||
| 22 | result = self.redis.execute_command('VSIM', self.test_key, 'VALUES', dim, | ||
| 23 | *[str(x) for x in query_vec], 'EF', 1000000) | ||
| 24 | assert isinstance(result, list), "EF=1000000 should be accepted" | ||
| 25 | |||
| 26 | # Test EF over limit (should reject > 1000000) | ||
| 27 | try: | ||
| 28 | self.redis.execute_command('VSIM', self.test_key, 'VALUES', dim, | ||
| 29 | *[str(x) for x in query_vec], 'EF', 1000001) | ||
| 30 | assert False, "EF=1000001 should be rejected" | ||
| 31 | except Exception as e: | ||
| 32 | assert "invalid EF" in str(e), f"Expected EF validation error, got: {e}" | ||
