Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

Commit

Permalink
tests: replace curl by wget
Browse files Browse the repository at this point in the history
The `curl` on CI is too old to handle ECC keys. But `wget` somehow works.
  • Loading branch information
kennytm committed Feb 20, 2020
1 parent 4ce165c commit 4a876f4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 10 deletions.
3 changes: 1 addition & 2 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ programs.
2. The following programs must be installed:

* `mysql` (the CLI client)
* `python2.7`
* `curl`
* `wget`
* `openssl`

3. The user executing the tests must have permission to create the folder
Expand Down
33 changes: 33 additions & 0 deletions tests/_utils/run_curl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh
#
# Copyright 2020 PingCAP, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# See the License for the specific language governing permissions and
# limitations under the License.

# Usage: run_curl https://url '{"json":"data"}'

set -eu
TEST_DIR=/tmp/lightning_test_result

if [ -z "${2-}" ]; then
POST_ARGS=
else
POST_ARGS="--post-data '$2'"
fi

# FIXME: use `wget` instead of `curl` because the latter rejects ECC certs on our CI.
# CentOS is re~~ally old.
wget -q -O - \
--ca-certificate="$TEST_DIR/tls/ca.pem" \
--certificate="$TEST_DIR/tls/curl.pem" \
--private-key="$TEST_DIR/tls/curl.key" \
$POST_ARGS "$1"
10 changes: 3 additions & 7 deletions tests/check_requirements/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
set -eu

curl_cluster_version() {
curl "$@" \
--cacert "$TEST_DIR/tls/ca.pem" \
--cert "$TEST_DIR/tls/curl.pem" \
--key "$TEST_DIR/tls/curl.key" \
'https://127.0.0.1:2379/pd/api/v1/config/cluster-version'
run_curl 'https://127.0.0.1:2379/pd/api/v1/config/cluster-version' "$@"
}

# should be OK when the version is normal
Expand All @@ -30,11 +26,11 @@ run_lightning --check-requirements=1 -L warning
# now try to reduce the version to below 2.1.0
OLD_VERSION=$(curl_cluster_version)
reset_cluster_version() {
curl_cluster_version --data-binary '{"cluster-version":'"$OLD_VERSION"'}'
curl_cluster_version '{"cluster-version":'"$OLD_VERSION"'}'
}
trap reset_cluster_version EXIT

curl_cluster_version --data-binary '{"cluster-version":"2.0.0-fake.and.error.expected"}'
curl_cluster_version '{"cluster-version":"2.0.0-fake.and.error.expected"}'

run_sql 'DROP DATABASE IF EXISTS checkreq'
set +e
Expand Down
2 changes: 1 addition & 1 deletion tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ EOF
bin/pd-server --config "$TEST_DIR/pd-config.toml" &
# wait until PD is online...
i=0
while ! curl --cacert "$TT/ca.pem" --cert "$TT/curl.pem" --key "$TT/curl.key" -o /dev/null -sf https://127.0.0.1:2379/pd/api/v1/version; do
while ! run_curl https://127.0.0.1:2379/pd/api/v1/version; do
i=$((i+1))
if [ "$i" -gt 10 ]; then
echo 'Failed to start PD'
Expand Down

0 comments on commit 4a876f4

Please sign in to comment.