Clean up curl-tests, install `uuid` on Ubuntu test runners

master
Nicolas Favre-Felix 11 months ago
parent 90773ca519
commit cce05b666f
No known key found for this signature in database
GPG Key ID: C04E7AA8B6F73372

@ -43,7 +43,7 @@ jobs:
- name: Install dependencies
run: |
DEBIAN_FRONTEND=noninteractive apt-get -y --allow-unauthenticated --allow-downgrades --allow-remove-essential --allow-change-held-packages \
install make gcc libevent-dev libmsgpack-dev curl nodejs python3 python3-pip
install make gcc libevent-dev libmsgpack-dev curl uuid nodejs python3 python3-pip
- name: Fix pip3 on Ubuntu 23.04
if: matrix.os_name == 'ubuntu-23.04'

@ -3,19 +3,37 @@
# exit on first error
set -e
function send_delete() {
curl -s "http://127.0.0.1:7379/DEL/$1" > /dev/null
}
function fail_with_error() {
local message=$1
local key=$2
>&2 echo "${message}"
send_delete "${key}"
exit 1
}
# GitHub issue #194 (connection: close + HTTP 100)
function test_large_put_upload() {
echo 'Testing large PUT upload: generating the key...'
echo -n 'Test 1/2: Large PUT upload: generating the key... '
if [[ $(command -v uuidgen) ]]; then # macOS
key=$(uuidgen)
elif [[ $(command -v uuid) ]]; then # Ubuntu
key=$(uuid)
else
key=$(cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
>&2 echo 'failed: neither uuidgen or uuid was available'
exit 1
fi
echo 'OK'
send_delete "${key}" # initial cleanup
echo -n 'Sending a PUT request with a large payload... '
put_output=$(printf 'A%.0s' $(seq 1 10000) | curl -s -H 'Connection: close' -XPUT "http://127.0.0.1:7379/SET/${key}" -d @-)
if [[ ${PIPESTATUS[1]} -ne 0 || "${put_output}" != '{"SET":[true,"OK"]}' ]]; then
echo "failed! Response was: ${put_output}"
exit 1
fail_with_error "failed! Response was: ${put_output}" "${key}"
else
echo 'OK'
fi
@ -23,20 +41,21 @@ function test_large_put_upload() {
echo -n 'Verifying the upload... '
strlen_output=$(curl -s "http://127.0.0.1:7379/STRLEN/${key}.txt")
if [[ $strlen_output != '10000' ]]; then
echo "failed! Unexpected value for STRLEN: ${strlen_output}"
exit 1;
fail_with_error "failed! Unexpected value for STRLEN: ${strlen_output}" "${key}"
else
echo 'OK'
fi
send_delete "${key}" # cleanup
}
# GitHub issue #217 (empty header ":" returned for OPTIONS)
function test_options_headers() {
echo -n 'Sending an OPTIONS request... '
echo -n 'Test 2/2: Sending an OPTIONS request... '
empty_header_present=$(curl -v -X OPTIONS "http://127.0.0.1:7379/" 2>&1 | grep -cE '^< : ' || true) # || true to avoid false-positive exit code from grep
if [[ $empty_header_present != 0 ]]; then
echo "failed! Found an empty header entry"
>&2 echo "failed! Found an empty header entry"
exit 1
else
echo 'OK'
@ -44,4 +63,5 @@ function test_options_headers() {
}
test_large_put_upload
echo
test_options_headers

Loading…
Cancel
Save