summaryrefslogtreecommitdiff
path: root/examples/redis-unstable/tests/vectorset
diff options
context:
space:
mode:
Diffstat (limited to 'examples/redis-unstable/tests/vectorset')
-rw-r--r--examples/redis-unstable/tests/vectorset/vectorset.tcl46
1 files changed, 46 insertions, 0 deletions
diff --git a/examples/redis-unstable/tests/vectorset/vectorset.tcl b/examples/redis-unstable/tests/vectorset/vectorset.tcl
new file mode 100644
index 0000000..1a1059b
--- /dev/null
+++ b/examples/redis-unstable/tests/vectorset/vectorset.tcl
@@ -0,0 +1,46 @@
1proc check_python_environment {} {
2 set ret [catch {exec sh -c "which python3 || which python" 2>@1} python_cmd]
3 if {$ret != 0} {
4 return ""
5 }
6
7 # Check if redis-py is installed
8 # Use a more robust way to check redis module
9 set ret [catch {exec $python_cmd -c "import redis" 2>@1} e]
10 if {$ret != 0} {
11 return ""
12 }
13
14 return $python_cmd
15}
16
17start_server {} {
18 set slave_port [srv 0 port]
19
20 start_server {} {
21 set master_port [srv 0 port]
22
23 test {Vector set Python test execution} {
24 set python_cmd [check_python_environment]
25 if {$python_cmd eq ""} {
26 puts "Python or redis-py module not found, skipping vectorset tests"
27 } else {
28 # Run the Python script with real-time output
29 puts "Running vectorset tests ..."
30 puts "Vectorset test output:"
31
32 set pipe [open "|$python_cmd modules/vector-sets/test.py --primary-port $master_port --replica-port $slave_port 2>@1" r]
33 # Read output line by line in real-time
34 while {[gets $pipe line] >= 0} {
35 puts $line
36 }
37
38 # Close pipe and check for errors
39 set result [catch {close $pipe} close_error]
40 if {$result != 0} {
41 fail "Vector set Python test failed: $close_error"
42 }
43 }
44 }
45 }
46}