add project

This commit is contained in:
GuilhermeStrice
2025-07-09 19:31:34 +01:00
parent 8d2e88edf4
commit f37078157d
44 changed files with 7680 additions and 0 deletions

11
CommandTests/01_setup.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
echo "=== Redis Manager Test Setup ==="
echo "Verifying existing Redis instances..."
# List instances to verify
echo "Listing configured instances:"
dotnet run -- list-instances
echo "Setup complete!"
echo ""

View File

@ -0,0 +1,46 @@
#!/bin/bash
echo "=== Basic String Commands Test ==="
echo "1. Testing SET and GET..."
dotnet run -- set "test:string" "Hello World" -i default
dotnet run -- get "test:string" -i default
echo ""
echo "2. Testing APPEND..."
dotnet run -- append "test:string" " - Appended!" -i default
dotnet run -- get "test:string" -i default
echo ""
echo "3. Testing INCR/DECR..."
dotnet run -- set "test:counter" "10" -i default
dotnet run -- incr "test:counter" -i default
dotnet run -- incrby "test:counter" "5" -i default
dotnet run -- decr "test:counter" -i default
dotnet run -- get "test:counter" -i default
echo ""
echo "4. Testing INCRBYFLOAT..."
dotnet run -- set "test:float" "10.5" -i default
dotnet run -- incrbyfloat "test:float" "2.3" -i default
dotnet run -- get "test:float" -i default
echo ""
echo "5. Testing GETRANGE/SETRANGE..."
dotnet run -- set "test:range" "Hello World" -i default
dotnet run -- getrange "test:range" "0" "4" -i default
dotnet run -- setrange "test:range" "6" "Redis" -i default
dotnet run -- get "test:range" -i default
echo ""
echo "6. Testing STRLEN..."
dotnet run -- strlen "test:range" -i default
echo ""
echo "7. Testing MGET/MSET..."
dotnet run -- mset --pairs key1=value1,key2=value2,key3=value3 -i default
dotnet run -- mget key1 key2 key3 -i default
echo ""
echo "Basic String Commands Test Complete!"
echo ""

62
CommandTests/03_hash_tests.sh Executable file
View File

@ -0,0 +1,62 @@
#!/bin/bash
echo "=== Testing Hash Commands ==="
# Test HSET and HGET
echo "Testing HSET and HGET..."
dotnet run -- hset user:1000 name "John Doe" -i localhost
dotnet run -- hset user:1000 email "john@example.com" -i localhost
dotnet run -- hset user:1000 age "30" -i localhost
dotnet run -- hget user:1000 name -i localhost
dotnet run -- hget user:1000 email -i localhost
dotnet run -- hget user:1000 age -i localhost
# Test HGETALL
echo "Testing HGETALL..."
dotnet run -- hgetall user:1000 -i localhost
# Test HKEYS and HVALS
echo "Testing HKEYS and HVALS..."
dotnet run -- hkeys user:1000 -i localhost
dotnet run -- hvals user:1000 -i localhost
# Test HEXISTS
echo "Testing HEXISTS..."
dotnet run -- hexists user:1000 name -i localhost
dotnet run -- hexists user:1000 phone -i localhost
# Test HLEN
echo "Testing HLEN..."
dotnet run -- hlen user:1000 -i localhost
# Test HINCRBY and HINCRBYFLOAT
echo "Testing HINCRBY and HINCRBYFLOAT..."
dotnet run -- hset user:1000 score "100" -i localhost
dotnet run -- hincrby user:1000 score "10" -i localhost
dotnet run -- hincrbyfloat user:1000 score "5.5" -i localhost
# Test HMSET and HMGET
echo "Testing HMSET and HMGET..."
dotnet run -- hmset user:1001 name "Jane Smith" email "jane@example.com" age "25" -i localhost
dotnet run -- hmget user:1001 name email age -i localhost
# Test HSETNX
echo "Testing HSETNX..."
dotnet run -- hsetnx user:1000 name "New Name" -i localhost
dotnet run -- hsetnx user:1000 phone "123-456-7890" -i localhost
# Test HSTRLEN
echo "Testing HSTRLEN..."
dotnet run -- hstrlen user:1000 name -i localhost
# Test HDEL
echo "Testing HDEL..."
dotnet run -- hdel user:1000 age -i localhost
dotnet run -- hgetall user:1000 -i localhost
# Test HSCAN
echo "Testing HSCAN..."
dotnet run -- hscan user:1000 0 -i localhost
echo "Hash tests completed!"

35
CommandTests/04_geo_tests.sh Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
echo "=== Geo Commands Test ==="
echo "1. Testing GEOADD..."
dotnet run -- geoadd cities 2.3522 48.8566 London 2.2945 48.8584 Paris 13.4050 52.5200 Berlin 12.4964 41.9028 Rome -i localhost
echo ""
echo "2. Testing GEOHASH..."
dotnet run -- geohash cities London Paris -i localhost
echo ""
echo "3. Testing GEOPOS..."
dotnet run -- geopos cities London Berlin Rome -i localhost
echo ""
echo "4. Testing GEODIST..."
dotnet run -- geodist cities London Paris --unit km -i localhost
dotnet run -- geodist cities London Berlin --unit mi -i localhost
echo ""
echo "5. Testing GEORADIUS..."
dotnet run -- georadius cities 2.3522 48.8566 1000 --unit km -i localhost
echo ""
echo "6. Testing GEOHASH with multiple members..."
dotnet run -- geohash cities London Paris Berlin Rome -i localhost
echo ""
echo "7. Testing GEOPOS with multiple members..."
dotnet run -- geopos cities London Paris Berlin Rome -i localhost
echo ""
echo "Geo Commands Test Complete!"
echo ""

62
CommandTests/05_bit_tests.sh Executable file
View File

@ -0,0 +1,62 @@
#!/bin/bash
echo "=== Bit Commands Test ==="
echo "1. Testing SETBIT and GETBIT..."
dotnet run -- setbit flags 0 1 -i localhost
dotnet run -- setbit flags 1 1 -i localhost
dotnet run -- setbit flags 2 0 -i localhost
dotnet run -- setbit flags 3 1 -i localhost
dotnet run -- getbit flags 0 -i localhost
dotnet run -- getbit flags 1 -i localhost
dotnet run -- getbit flags 2 -i localhost
dotnet run -- getbit flags 3 -i localhost
echo ""
echo "2. Testing BITCOUNT..."
dotnet run -- bitcount flags -i localhost
echo ""
echo "3. Testing BITPOS..."
dotnet run -- bitpos flags 1 -i localhost
dotnet run -- bitpos flags 0 -i localhost
echo ""
echo "4. Testing BITFIELD..."
dotnet run -- bitfield numbers SET u8 0 255 GET u8 0 -i localhost
dotnet run -- bitfield numbers SET i16 8 32767 GET i16 8 -i localhost
dotnet run -- bitfield numbers INCRBY u8 0 1 GET u8 0 -i localhost
echo ""
echo "5. Testing BITOP..."
dotnet run -- setbit flags1 0 1 -i localhost
dotnet run -- setbit flags1 1 0 -i localhost
dotnet run -- setbit flags2 0 0 -i localhost
dotnet run -- setbit flags2 1 1 -i localhost
dotnet run -- bitop AND result flags1 flags2 -i localhost
dotnet run -- getbit result 0 -i localhost
dotnet run -- getbit result 1 -i localhost
echo ""
echo "6. Testing BITOP OR..."
dotnet run -- bitop OR result_or flags1 flags2 -i localhost
dotnet run -- getbit result_or 0 -i localhost
dotnet run -- getbit result_or 1 -i localhost
echo ""
echo "7. Testing BITOP XOR..."
dotnet run -- bitop XOR result_xor flags1 flags2 -i localhost
dotnet run -- getbit result_xor 0 -i localhost
dotnet run -- getbit result_xor 1 -i localhost
echo ""
echo "8. Testing BITOP NOT..."
dotnet run -- bitop NOT result_not flags1 -i localhost
dotnet run -- getbit result_not 0 -i localhost
dotnet run -- getbit result_not 1 -i localhost
echo ""
echo "Bit Commands Test Complete!"
echo ""

25
CommandTests/06_module_tests.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
echo "=== Module Commands Test ==="
echo "1. Testing MODULE LIST..."
dotnet run -- module-list -i localhost
echo ""
echo "2. Testing MODULE LOAD (this may fail if no modules are available)..."
# Note: This will likely fail unless you have Redis modules available
dotnet run -- module-load "/path/to/module.so" "arg1" "arg2" -i localhost
echo ""
echo "3. Testing MODULE UNLOAD (this may fail if no modules are loaded)..."
# Note: This will likely fail unless you have modules loaded
dotnet run -- module-unload "testmodule" -i localhost
echo ""
echo "4. Testing MODULE LIST again..."
dotnet run -- module-list -i localhost
echo ""
echo "Module Commands Test Complete!"
echo "Note: Module commands may fail if no modules are available/loaded."
echo ""

70
CommandTests/07_list_tests.sh Executable file
View File

@ -0,0 +1,70 @@
#!/bin/bash
echo "=== Testing List Commands ==="
# Test LPUSH and RPUSH
echo "Testing LPUSH and RPUSH..."
dotnet run -- lpush mylist "first" -i localhost
dotnet run -- lpush mylist "second" -i localhost
dotnet run -- rpush mylist "third" -i localhost
dotnet run -- rpush mylist "fourth" -i localhost
# Test LLEN
echo "Testing LLEN..."
dotnet run -- llen mylist -i localhost
# Test LRANGE
echo "Testing LRANGE..."
dotnet run -- lrange mylist 0 -1 -i localhost
dotnet run -- lrange mylist 0 1 -i localhost
dotnet run -- lrange mylist 1 2 -i localhost
# Test LINDEX
echo "Testing LINDEX..."
dotnet run -- lindex mylist 0 -i localhost
dotnet run -- lindex mylist 1 -i localhost
dotnet run -- lindex mylist -1 -i localhost
# Test LSET
echo "Testing LSET..."
dotnet run -- lset mylist 1 "updated_second" -i localhost
dotnet run -- lrange mylist 0 -1 -i localhost
# Test LINSERT
echo "Testing LINSERT..."
dotnet run -- linsert mylist before "updated_second" "before_second" -i localhost
dotnet run -- linsert mylist after "updated_second" "after_second" -i localhost
dotnet run -- lrange mylist 0 -1 -i localhost
# Test LREM
echo "Testing LREM..."
dotnet run -- lpush mylist "duplicate" -i localhost
dotnet run -- lpush mylist "duplicate" -i localhost
dotnet run -- lrem mylist 2 "duplicate" -i localhost
dotnet run -- lrange mylist 0 -1 -i localhost
# Test LTRIM
echo "Testing LTRIM..."
dotnet run -- ltrim mylist 1 3 -i localhost
dotnet run -- lrange mylist 0 -1 -i localhost
# Test LPOP and RPOP
echo "Testing LPOP and RPOP..."
dotnet run -- lpop mylist -i localhost
dotnet run -- rpop mylist -i localhost
dotnet run -- lrange mylist 0 -1 -i localhost
# Test BLPOP and BRPOP (with timeout)
echo "Testing BLPOP and BRPOP..."
dotnet run -- blpop mylist 1 -i localhost
dotnet run -- brpop mylist 1 -i localhost
# Test RPOPLPUSH
echo "Testing RPOPLPUSH..."
dotnet run -- rpush mylist "last_item" -i localhost
dotnet run -- rpush otherlist "existing_item" -i localhost
dotnet run -- rpoplpush mylist otherlist -i localhost
dotnet run -- lrange mylist 0 -1 -i localhost
dotnet run -- lrange otherlist 0 -1 -i localhost
echo "List tests completed!"

72
CommandTests/08_set_tests.sh Executable file
View File

@ -0,0 +1,72 @@
#!/bin/bash
echo "=== Testing Set Commands ==="
# Test SADD and SMEMBERS
echo "Testing SADD and SMEMBERS..."
dotnet run -- sadd set1 "apple" -i localhost
dotnet run -- sadd set1 "banana" -i localhost
dotnet run -- sadd set1 "cherry" -i localhost
dotnet run -- smembers set1 -i localhost
# Test SISMEMBER
echo "Testing SISMEMBER..."
dotnet run -- sismember set1 "apple" -i localhost
dotnet run -- sismember set1 "orange" -i localhost
# Test SCARD
echo "Testing SCARD..."
dotnet run -- scard set1 -i localhost
# Test SPOP and SRANDMEMBER
echo "Testing SPOP and SRANDMEMBER..."
dotnet run -- sadd set2 "one" "two" "three" "four" "five" -i localhost
dotnet run -- spop set2 -i localhost
dotnet run -- srandmember set2 -i localhost
dotnet run -- srandmember set2 2 -i localhost
# Test SREM
echo "Testing SREM..."
dotnet run -- srem set1 "banana" -i localhost
dotnet run -- smembers set1 -i localhost
# Test Set operations with multiple sets
echo "Testing Set operations..."
dotnet run -- sadd set3 "apple" "banana" "grape" -i localhost
dotnet run -- sadd set4 "banana" "cherry" "date" -i localhost
# Test SINTER
echo "Testing SINTER..."
dotnet run -- sinter set1 set3 set4 -i localhost
# Test SUNION
echo "Testing SUNION..."
dotnet run -- sunion set1 set3 set4 -i localhost
# Test SDIFF
echo "Testing SDIFF..."
dotnet run -- sdiff set3 set4 -i localhost
# Test SINTERSTORE, SUNIONSTORE, SDIFFSTORE
echo "Testing SINTERSTORE, SUNIONSTORE, SDIFFSTORE..."
dotnet run -- sinterstore result1 set1 set3 -i localhost
dotnet run -- sunionstore result2 set1 set3 -i localhost
dotnet run -- sdiffstore result3 set3 set4 -i localhost
dotnet run -- smembers result1 -i localhost
dotnet run -- smembers result2 -i localhost
dotnet run -- smembers result3 -i localhost
# Test SSCAN
echo "Testing SSCAN..."
dotnet run -- sscan set3 0 -i localhost
# Test SMOVE
echo "Testing SMOVE..."
dotnet run -- sadd source_set "item1" "item2" "item3" -i localhost
dotnet run -- sadd dest_set "existing_item" -i localhost
dotnet run -- smove source_set dest_set "item2" -i localhost
dotnet run -- smembers source_set -i localhost
dotnet run -- smembers dest_set -i localhost
echo "Set tests completed!"

View File

@ -0,0 +1,82 @@
#!/bin/bash
echo "=== Testing Sorted Set Commands ==="
# Test ZADD and ZRANGE
echo "Testing ZADD and ZRANGE..."
dotnet run -- zadd leaderboard 100 "player1" -i localhost
dotnet run -- zadd leaderboard 200 "player2" -i localhost
dotnet run -- zadd leaderboard 150 "player3" -i localhost
dotnet run -- zrange leaderboard 0 -1 -i localhost
dotnet run -- zrange leaderboard 0 -1 withscores -i localhost
# Test ZSCORE
echo "Testing ZSCORE..."
dotnet run -- zscore leaderboard "player1" -i localhost
dotnet run -- zscore leaderboard "player2" -i localhost
# Test ZRANK and ZREVRANK
echo "Testing ZRANK and ZREVRANK..."
dotnet run -- zrank leaderboard "player1" -i localhost
dotnet run -- zrevrank leaderboard "player1" -i localhost
# Test ZCARD
echo "Testing ZCARD..."
dotnet run -- zcard leaderboard -i localhost
# Test ZREM
echo "Testing ZREM..."
dotnet run -- zrem leaderboard "player2" -i localhost
dotnet run -- zrange leaderboard 0 -1 -i localhost
# Test ZRANGEBYSCORE and ZREVRANGEBYSCORE
echo "Testing ZRANGEBYSCORE and ZREVRANGEBYSCORE..."
dotnet run -- zadd scores 50 "user1" -i localhost
dotnet run -- zadd scores 75 "user2" -i localhost
dotnet run -- zadd scores 90 "user3" -i localhost
dotnet run -- zadd scores 120 "user4" -i localhost
dotnet run -- zrangebyscore scores 60 100 -i localhost
dotnet run -- zrangebyscore scores 60 100 withscores -i localhost
dotnet run -- zrevrangebyscore scores 100 60 -i localhost
# Test ZCOUNT
echo "Testing ZCOUNT..."
dotnet run -- zcount scores 60 100 -i localhost
# Test ZINCRBY
echo "Testing ZINCRBY..."
dotnet run -- zincrby scores 25 "user1" -i localhost
dotnet run -- zscore scores "user1" -i localhost
# Test ZUNIONSTORE and ZINTERSTORE
echo "Testing ZUNIONSTORE and ZINTERSTORE..."
dotnet run -- zadd set1 1 "a" 2 "b" 3 "c" -i localhost
dotnet run -- zadd set2 2 "b" 3 "c" 4 "d" -i localhost
dotnet run -- zunionstore union_result 2 set1 set2 -i localhost
dotnet run -- zinterstore inter_result 2 set1 set2 -i localhost
dotnet run -- zrange union_result 0 -1 withscores -i localhost
dotnet run -- zrange inter_result 0 -1 withscores -i localhost
# Test ZSCAN
echo "Testing ZSCAN..."
dotnet run -- zscan scores 0 -i localhost
# Test ZPOPMAX and ZPOPMIN
echo "Testing ZPOPMAX and ZPOPMIN..."
dotnet run -- zpopmax scores -i localhost
dotnet run -- zpopmin scores -i localhost
# Test ZREMRANGEBYRANK and ZREMRANGEBYSCORE
echo "Testing ZREMRANGEBYRANK and ZREMRANGEBYSCORE..."
dotnet run -- zadd test_set 10 "item1" 20 "item2" 30 "item3" 40 "item4" -i localhost
dotnet run -- zremrangebyrank test_set 1 2 -i localhost
dotnet run -- zrange test_set 0 -1 -i localhost
dotnet run -- zadd test_set2 10 "item1" 20 "item2" 30 "item3" 40 "item4" -i localhost
dotnet run -- zremrangebyscore test_set2 15 35 -i localhost
dotnet run -- zrange test_set2 0 -1 -i localhost
echo "Sorted Set tests completed!"

4
CommandTests/10_cleanup.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
echo "Flushing the current Redis database..."
dotnet run -- flushdb -i localhost --yes

0
CommandTests/README.md Normal file
View File

53
CommandTests/run_all_tests.sh Executable file
View File

@ -0,0 +1,53 @@
#!/bin/bash
echo "=========================================="
echo "Redis Manager - Complete Test Suite"
echo "=========================================="
echo ""
# Make all scripts executable
chmod +x CommandTests/*.sh
echo "Running setup..."
./CommandTests/01_setup.sh
echo ""
echo "Running basic string tests..."
./CommandTests/02_basic_string_tests.sh
echo ""
echo "Running hash tests..."
./CommandTests/03_hash_tests.sh
echo ""
echo "Running geo tests..."
./CommandTests/04_geo_tests.sh
echo ""
echo "Running bit tests..."
./CommandTests/05_bit_tests.sh
echo ""
echo "Running module tests..."
./CommandTests/06_module_tests.sh
echo ""
echo "Running list tests..."
./CommandTests/07_list_tests.sh
echo ""
echo "Running set tests..."
./CommandTests/08_set_tests.sh
echo ""
echo "Running sorted set tests..."
./CommandTests/09_sorted_set_tests.sh
echo ""
echo "Running cleanup..."
./CommandTests/10_cleanup.sh
echo ""
echo "=========================================="
echo "All tests completed!"
echo "=========================================="