Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
2eaf2360
Commit
2eaf2360
authored
May 30, 2023
by
Yossi Gottlieb
Browse files
Merge commit '
fad6c713
' into hiredis-refresh
parents
c2f1815b
fad6c713
Changes
41
Show whitespace changes
Inline
Side-by-side
deps/hiredis/test.sh
View file @
2eaf2360
...
@@ -4,9 +4,17 @@ REDIS_SERVER=${REDIS_SERVER:-redis-server}
...
@@ -4,9 +4,17 @@ REDIS_SERVER=${REDIS_SERVER:-redis-server}
REDIS_PORT
=
${
REDIS_PORT
:-
56379
}
REDIS_PORT
=
${
REDIS_PORT
:-
56379
}
REDIS_SSL_PORT
=
${
REDIS_SSL_PORT
:-
56443
}
REDIS_SSL_PORT
=
${
REDIS_SSL_PORT
:-
56443
}
TEST_SSL
=
${
TEST_SSL
:-
0
}
TEST_SSL
=
${
TEST_SSL
:-
0
}
SKIPS_AS_FAILS
=
${
SKIPS_AS_FAILS
-
:0
}
SKIPS_AS_FAILS
=
${
SKIPS_AS_FAILS
:-
0
}
ENABLE_DEBUG_CMD
=
SSL_TEST_ARGS
=
SSL_TEST_ARGS
=
SKIPS_ARG
=
SKIPS_ARG
=
${
SKIPS_ARG
:-}
REDIS_DOCKER
=
${
REDIS_DOCKER
:-}
# We need to enable the DEBUG command for redis-server >= 7.0.0
REDIS_MAJOR_VERSION
=
"
$(
redis-server
--version
|awk
-F
'[^0-9]+'
'{ print $2 }'
)
"
if
[
"
$REDIS_MAJOR_VERSION
"
-gt
"6"
]
;
then
ENABLE_DEBUG_CMD
=
"enable-debug-command local"
fi
tmpdir
=
$(
mktemp
-d
)
tmpdir
=
$(
mktemp
-d
)
PID_FILE
=
${
tmpdir
}
/hiredis-test-redis.pid
PID_FILE
=
${
tmpdir
}
/hiredis-test-redis.pid
...
@@ -43,20 +51,34 @@ if [ "$TEST_SSL" = "1" ]; then
...
@@ -43,20 +51,34 @@ if [ "$TEST_SSL" = "1" ]; then
fi
fi
cleanup
()
{
cleanup
()
{
if
[
-n
"
${
REDIS_DOCKER
}
"
]
;
then
docker
kill
redis-test-server
else
set
+e
set
+e
kill
$(
cat
${
PID_FILE
}
)
kill
$(
cat
${
PID_FILE
}
)
fi
rm
-rf
${
tmpdir
}
rm
-rf
${
tmpdir
}
}
}
trap
cleanup INT TERM EXIT
trap
cleanup INT TERM EXIT
# base config
cat
>
${
tmpdir
}
/redis.conf
<<
EOF
cat
>
${
tmpdir
}
/redis.conf
<<
EOF
daemonize yes
pidfile
${
PID_FILE
}
pidfile
${
PID_FILE
}
port
${
REDIS_PORT
}
port
${
REDIS_PORT
}
bind 127.0.0.1
unixsocket
${
SOCK_FILE
}
unixsocket
${
SOCK_FILE
}
unixsocketperm 777
EOF
EOF
# if not running in docker add these:
if
[
!
-n
"
${
REDIS_DOCKER
}
"
]
;
then
cat
>>
${
tmpdir
}
/redis.conf
<<
EOF
daemonize yes
${
ENABLE_DEBUG_CMD
}
bind 127.0.0.1
EOF
fi
# if doing ssl, add these
if
[
"
$TEST_SSL
"
=
"1"
]
;
then
if
[
"
$TEST_SSL
"
=
"1"
]
;
then
cat
>>
${
tmpdir
}
/redis.conf
<<
EOF
cat
>>
${
tmpdir
}
/redis.conf
<<
EOF
tls-port
${
REDIS_SSL_PORT
}
tls-port
${
REDIS_SSL_PORT
}
...
@@ -66,13 +88,25 @@ tls-key-file ${SSL_KEY}
...
@@ -66,13 +88,25 @@ tls-key-file ${SSL_KEY}
EOF
EOF
fi
fi
echo
${
tmpdir
}
cat
${
tmpdir
}
/redis.conf
cat
${
tmpdir
}
/redis.conf
${
REDIS_SERVER
}
${
tmpdir
}
/redis.conf
if
[
-n
"
${
REDIS_DOCKER
}
"
]
;
then
chmod
a+wx
${
tmpdir
}
chmod
a+r
${
tmpdir
}
/
*
docker run
-d
--rm
--name
redis-test-server
\
-p
${
REDIS_PORT
}
:
${
REDIS_PORT
}
\
-p
${
REDIS_SSL_PORT
}
:
${
REDIS_SSL_PORT
}
\
-v
${
tmpdir
}
:
${
tmpdir
}
\
${
REDIS_DOCKER
}
\
redis-server
${
tmpdir
}
/redis.conf
else
${
REDIS_SERVER
}
${
tmpdir
}
/redis.conf
fi
# Wait until we detect the unix socket
# Wait until we detect the unix socket
echo
waiting
for
server
while
[
!
-S
"
${
SOCK_FILE
}
"
]
;
do
sleep
1
;
done
while
[
!
-S
"
${
SOCK_FILE
}
"
]
;
do
sleep
1
;
done
# Treat skips as failures if directed
# Treat skips as failures if directed
[
"
$SKIPS_AS_FAILS
"
=
1
]
&&
SKIPS_ARG
=
"--skips-as-fails"
[
"
$SKIPS_AS_FAILS
"
=
1
]
&&
SKIPS_ARG
=
"
${
SKIPS_ARG
}
--skips-as-fails"
${
TEST_PREFIX
:-}
./hiredis-test
-h
127.0.0.1
-p
${
REDIS_PORT
}
-s
${
SOCK_FILE
}
${
SSL_TEST_ARGS
}
${
SKIPS_ARG
}
${
TEST_PREFIX
:-}
./hiredis-test
-h
127.0.0.1
-p
${
REDIS_PORT
}
-s
${
SOCK_FILE
}
${
SSL_TEST_ARGS
}
${
SKIPS_ARG
}
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment