Skip to content

Commit

Permalink
Fix json validator and others
Browse files Browse the repository at this point in the history
  • Loading branch information
hwware committed Mar 26, 2024
1 parent 975d3b6 commit 3e095f1
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 45 deletions.
18 changes: 9 additions & 9 deletions utils/create-cluster/create-cluster
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ then
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
echo "Starting $PORT"
$BIN_PATH/redis-server --port $PORT --protected-mode $PROTECTED_MODE --cluster-enabled yes --cluster-config-file nodes-${PORT}.conf --cluster-node-timeout $TIMEOUT --appendonly yes --appendfilename appendonly-${PORT}.aof --appenddirname appendonlydir-${PORT} --dbfilename dump-${PORT}.rdb --logfile ${PORT}.log --daemonize yes ${ADDITIONAL_OPTIONS}
$BIN_PATH/placeholderkv-server --port $PORT --protected-mode $PROTECTED_MODE --cluster-enabled yes --cluster-config-file nodes-${PORT}.conf --cluster-node-timeout $TIMEOUT --appendonly yes --appendfilename appendonly-${PORT}.aof --appenddirname appendonlydir-${PORT} --dbfilename dump-${PORT}.rdb --logfile ${PORT}.log --daemonize yes ${ADDITIONAL_OPTIONS}
done
exit 0
fi
Expand All @@ -44,7 +44,7 @@ then
if [ "$2" == "-f" ]; then
OPT_ARG="--cluster-yes"
fi
$BIN_PATH/redis-cli --cluster create $HOSTS --cluster-replicas $REPLICAS $OPT_ARG
$BIN_PATH/placeholderkv-cli --cluster create $HOSTS --cluster-replicas $REPLICAS $OPT_ARG
exit 0
fi

Expand All @@ -53,7 +53,7 @@ then
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
echo "Stopping $PORT"
$BIN_PATH/redis-cli -p $PORT shutdown nosave
$BIN_PATH/placeholderkv-cli -p $PORT shutdown nosave
done
exit 0
fi
Expand All @@ -70,7 +70,7 @@ then
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
echo "Starting $PORT"
$BIN_PATH/redis-server --port $PORT --protected-mode $PROTECTED_MODE --cluster-enabled yes --cluster-config-file nodes-${PORT}.conf --cluster-node-timeout $TIMEOUT --appendonly yes --appendfilename appendonly-${PORT}.aof --appenddirname appendonlydir-${PORT} --dbfilename dump-${PORT}.rdb --logfile ${PORT}.log --daemonize yes ${ADDITIONAL_OPTIONS}
$BIN_PATH/placeholderkv-server --port $PORT --protected-mode $PROTECTED_MODE --cluster-enabled yes --cluster-config-file nodes-${PORT}.conf --cluster-node-timeout $TIMEOUT --appendonly yes --appendfilename appendonly-${PORT}.aof --appenddirname appendonlydir-${PORT} --dbfilename dump-${PORT}.rdb --logfile ${PORT}.log --daemonize yes ${ADDITIONAL_OPTIONS}
done
exit 0
fi
Expand All @@ -81,7 +81,7 @@ then
while [ 1 ]; do
clear
date
$BIN_PATH/redis-cli -p $PORT cluster nodes | head -30
$BIN_PATH/placeholderkv-cli -p $PORT cluster nodes | head -30
sleep 1
done
exit 0
Expand All @@ -105,7 +105,7 @@ if [ "$1" == "call" ]
then
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
$BIN_PATH/redis-cli -p $PORT $2 $3 $4 $5 $6 $7 $8 $9
$BIN_PATH/placeholderkv-cli -p $PORT $2 $3 $4 $5 $6 $7 $8 $9
done
exit 0
fi
Expand All @@ -131,10 +131,10 @@ then
fi

echo "Usage: $0 [start|create|stop|restart|watch|tail|tailall|clean|clean-logs|call]"
echo "start -- Launch Redis Cluster instances."
echo "start -- Launch Server Cluster instances."
echo "create [-f] -- Create a cluster using redis-cli --cluster create."
echo "stop -- Stop Redis Cluster instances."
echo "restart -- Restart Redis Cluster instances."
echo "stop -- Stop Server Cluster instances."
echo "restart -- Restart Server Cluster instances."
echo "watch -- Show CLUSTER NODES output (first 30 lines) of first node."
echo "tail <id> -- Run tail -f of instance at base port + ID."
echo "tailall -- Run tail -f for all the log files at once."
Expand Down
10 changes: 5 additions & 5 deletions utils/redis_init_script
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
### END INIT INFO

REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
EXEC=/usr/local/bin/placeholderkv-server
CLIEXEC=/usr/local/bin/placeholderkv-cli

PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.conf"
Expand All @@ -24,7 +24,7 @@ case "$1" in
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
echo "Starting Placeholderkv server..."
$EXEC $CONF
fi
;;
Expand All @@ -38,10 +38,10 @@ case "$1" in
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
echo "Waiting for Placeholderkv to shutdown ..."
sleep 1
done
echo "Redis stopped"
echo "Placeholderkv stopped"
fi
;;
*)
Expand Down
24 changes: 12 additions & 12 deletions utils/req-res-log-validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
"""
The purpose of this file is to validate the reply_schema values of COMMAND DOCS.
Basically, this is what it does:
1. Goes over req-res files, generated by redis-servers, spawned by the testsuite (see logreqres.c)
1. Goes over req-res files, generated by placeholderkv-servers, spawned by the testsuite (see logreqres.c)
2. For each request-response pair, it validates the response against the request's reply_schema (obtained from COMMAND DOCS)
This script spins up a redis-server and a redis-cli in order to obtain COMMAND DOCS.
This script spins up a placeholderkv-server and a placeholderkv-cli in order to obtain COMMAND DOCS.
In order to use this file you must run the redis testsuite with the following flags:
In order to use this file you must run the placeholderkv testsuite with the following flags:
./runtest --dont-clean --force-resp3 --log-req-res
And then:
Expand Down Expand Up @@ -62,7 +62,7 @@

class Request(object):
"""
This class represents a Redis request (AKA command, argv)
This class represents a Placeholderkv request (AKA command, argv)
"""
def __init__(self, f, docs, line_counter):
"""
Expand Down Expand Up @@ -106,7 +106,7 @@ def __str__(self):

class Response(object):
"""
This class represents a Redis response in RESP3
This class represents a Placeholderkv response in RESP3
"""
def __init__(self, f, line_counter):
"""
Expand Down Expand Up @@ -159,7 +159,7 @@ def __init__(self, f, line_counter):
count = int(line[1:])
for i in range(count):
field = Response(f, line_counter)
# Redis allows fields to be non-strings but JSON doesn't.
# Placeholderkv allows fields to be non-strings but JSON doesn't.
# Luckily, for any kind of response we can validate, the fields are
# always strings (example: XINFO STREAM)
# The reason we can't always convert to string is because of DEBUG PROTOCOL MAP
Expand Down Expand Up @@ -241,7 +241,7 @@ def fetch_schemas(cli, port, args, docs):

while True:
try:
print('Connecting to Redis...')
print('Connecting to Placeholderkv...')
r = redis.Redis(port=port)
r.ping()
break
Expand Down Expand Up @@ -271,9 +271,9 @@ def fetch_schemas(cli, port, args, docs):
testdir = os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + "/../tests")

parser = argparse.ArgumentParser()
parser.add_argument('--server', type=str, default='%s/redis-server' % srcdir)
parser.add_argument('--server', type=str, default='%s/placeholderkv-server' % srcdir)
parser.add_argument('--port', type=int, default=6534)
parser.add_argument('--cli', type=str, default='%s/redis-cli' % srcdir)
parser.add_argument('--cli', type=str, default='%s/placeholderkv-cli' % srcdir)
parser.add_argument('--module', type=str, action='append', default=[])
parser.add_argument('--verbose', action='store_true')
parser.add_argument('--fail-commands-not-all-hit', action='store_true')
Expand All @@ -282,16 +282,16 @@ def fetch_schemas(cli, port, args, docs):

docs = dict()

# Fetch schemas from a Redis instance
print('Starting Redis server')
# Fetch schemas from a Placeholderkv instance
print('Starting Placeholderkv server')
redis_args = [args.server, '--port', str(args.port)]
for module in args.module:
redis_args += ['--loadmodule', 'tests/modules/%s.so' % module]

fetch_schemas(args.cli, args.port, redis_args, docs)

# Fetch schemas from a sentinel
print('Starting Redis sentinel')
print('Starting Placeholderkv sentinel')

# Sentinel needs a config file to start
config_file = "tmpsentinel.conf"
Expand Down
14 changes: 7 additions & 7 deletions utils/speed-regression.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ proc run-tests branches {
exec -ignorestderr make 2> /dev/null

if {$branch_id == 0} {
puts " copy redis-benchmark from unstable to /tmp..."
exec -ignorestderr cp ./redis-benchmark /tmp
puts " copy placeholderkv-benchmark from unstable to /tmp..."
exec -ignorestderr cp ./placeholderkv-benchmark /tmp
incr branch_id
continue
}

# Start the Redis server
puts " starting the server... [exec ./redis-server -v]"
set pids [exec echo "port $::port\nloglevel warning\n" | ./redis-server - > /dev/null 2> /dev/null &]
# Start the Placeholderkv server
puts " starting the server... [exec ./placeholderkv-server -v]"
set pids [exec echo "port $::port\nloglevel warning\n" | ./placeholderkv-server - > /dev/null 2> /dev/null &]
puts " pids: $pids"
after 1000
puts " running the benchmark"
Expand All @@ -38,7 +38,7 @@ proc run-tests branches {
puts " redis INFO shows version: [lindex [split $i] 0]"
$r close

set output [exec /tmp/redis-benchmark -n $::requests -t $::tests -d $::datasize --csv -p $::port]
set output [exec /tmp/placeholderkv-benchmark -n $::requests -t $::tests -d $::datasize --csv -p $::port]
lappend runs $b $output
puts " killing server..."
catch {exec kill -9 [lindex $pids 0]}
Expand Down Expand Up @@ -83,7 +83,7 @@ proc combine-results {results} {
}

proc main {} {
# Note: the first branch is only used in order to get the redis-benchmark
# Note: the first branch is only used in order to get the placeholderkv-benchmark
# executable. Tests are performed starting from the second branch.
set branches {
slowset 2.2.0 2.4.0 unstable slowset
Expand Down
16 changes: 8 additions & 8 deletions utils/[email protected]
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# example systemd template service unit file for multiple redis-servers
# example systemd template service unit file for multiple placeholderkv-server
#
# You can use this file as a blueprint for your actual template service unit
# file, if you intend to run multiple independent redis-server instances in
# file, if you intend to run multiple independent placeholderkv-server instances in
# parallel using systemd's "template unit files" feature. If you do, you will
# want to choose a better basename for your service unit by renaming this file
# when copying it.
#
# Please take a look at the provided "systemd-redis_server.service" example
# Please take a look at the provided "systemd-placeholderkv_server.service" example
# service unit file, too, if you choose to use this approach at managing
# multiple redis-server instances via systemd.
# multiple placeholderkv-server instances via systemd.

[Unit]
Description=Redis data structure server - instance %i
Documentation=https://redis.io/documentation
# This template unit assumes your redis-server configuration file(s)
# to live at /etc/redis/redis_server_<INSTANCE_NAME>.conf
AssertPathExists=/etc/redis/redis_server_%i.conf
# This template unit assumes your placeholderkv-server configuration file(s)
# to live at /etc/redis/placeholder_server_<INSTANCE_NAME>.conf
AssertPathExists=/etc/redis/placeholder_server_%i.conf
#Before=your_application.service another_example_application.service
#AssertPathExists=/var/lib/redis

[Service]
ExecStart=/usr/local/bin/redis-server /etc/redis/redis_server_%i.conf
ExecStart=/usr/local/bin/placeholderkv-server /etc/redis/placeholderkv_server_%i.conf
LimitNOFILE=10032
NoNewPrivileges=yes
#OOMScoreAdjust=-900
Expand Down
8 changes: 4 additions & 4 deletions utils/systemd-redis_server.service
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# example systemd service unit file for redis-server
# example systemd service unit file for placeholderkv-server
#
# In order to use this as a template for providing a redis service in your
# environment, _at the very least_ make sure to adapt the redis configuration
Expand All @@ -24,9 +24,9 @@ Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/usr/local/bin/redis-server --supervised systemd --daemonize no
## Alternatively, have redis-server load a configuration file:
#ExecStart=/usr/local/bin/redis-server /path/to/your/redis.conf
ExecStart=/usr/local/bin/placeholderkv-server --supervised systemd --daemonize no
## Alternatively, have placeholderkv-server load a configuration file:
#ExecStart=/usr/local/bin/placeholderkv-server /path/to/your/redis.conf
LimitNOFILE=10032
NoNewPrivileges=yes
#OOMScoreAdjust=-900
Expand Down

0 comments on commit 3e095f1

Please sign in to comment.