chore: fix pkg-tests.sh
This commit is contained in:
parent
42627a3d42
commit
8293fce7f2
|
@ -46,6 +46,7 @@ export SCRIPTS="${CODE_PATH}/scripts"
|
||||||
export EMQX_NAME
|
export EMQX_NAME
|
||||||
export PACKAGE_PATH="${CODE_PATH}/_packages/${EMQX_NAME}"
|
export PACKAGE_PATH="${CODE_PATH}/_packages/${EMQX_NAME}"
|
||||||
export RELUP_PACKAGE_PATH="${CODE_PATH}/_upgrade_base"
|
export RELUP_PACKAGE_PATH="${CODE_PATH}/_upgrade_base"
|
||||||
|
export PAHO_MQTT_TESTING_PATH="${PAHO_MQTT_TESTING_PATH:-/paho-mqtt-testing}"
|
||||||
|
|
||||||
SYSTEM="$("$SCRIPTS"/get-distro.sh)"
|
SYSTEM="$("$SCRIPTS"/get-distro.sh)"
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ fi
|
||||||
PACKAGE_VERSION="$("$CODE_PATH"/pkg-vsn.sh "${EMQX_NAME}")"
|
PACKAGE_VERSION="$("$CODE_PATH"/pkg-vsn.sh "${EMQX_NAME}")"
|
||||||
PACKAGE_VERSION_LONG="$("$CODE_PATH"/pkg-vsn.sh "${EMQX_NAME}" --long --elixir "${IS_ELIXIR}")"
|
PACKAGE_VERSION_LONG="$("$CODE_PATH"/pkg-vsn.sh "${EMQX_NAME}" --long --elixir "${IS_ELIXIR}")"
|
||||||
PACKAGE_NAME="${EMQX_NAME}-${PACKAGE_VERSION_LONG}"
|
PACKAGE_NAME="${EMQX_NAME}-${PACKAGE_VERSION_LONG}"
|
||||||
PACKAGE_FILE_NAME="${PACKAGE_NAME}.${PKG_SUFFIX}"
|
PACKAGE_FILE_NAME="${PACKAGE_FILE_NAME:-${PACKAGE_NAME}.${PKG_SUFFIX}}"
|
||||||
|
|
||||||
PACKAGE_FILE="${PACKAGE_PATH}/${PACKAGE_FILE_NAME}"
|
PACKAGE_FILE="${PACKAGE_PATH}/${PACKAGE_FILE_NAME}"
|
||||||
if ! [ -f "$PACKAGE_FILE" ]; then
|
if ! [ -f "$PACKAGE_FILE" ]; then
|
||||||
|
@ -75,9 +76,21 @@ fi
|
||||||
emqx_prepare(){
|
emqx_prepare(){
|
||||||
mkdir -p "${PACKAGE_PATH}"
|
mkdir -p "${PACKAGE_PATH}"
|
||||||
|
|
||||||
if [ ! -d "/paho-mqtt-testing" ]; then
|
if [ ! -d "${PAHO_MQTT_TESTING_PATH}" ]; then
|
||||||
git clone -b develop-4.0 https://github.com/emqx/paho.mqtt.testing.git /paho-mqtt-testing
|
git clone -b develop-4.0 https://github.com/emqx/paho.mqtt.testing.git "${PAHO_MQTT_TESTING_PATH}"
|
||||||
fi
|
fi
|
||||||
|
# Debian 12 complains if we don't use venv
|
||||||
|
case "${SYSTEM:-}" in
|
||||||
|
debian12)
|
||||||
|
apt-get update -y && apt-get install -y virtualenv
|
||||||
|
virtualenv venv
|
||||||
|
# https://www.shellcheck.net/wiki/SC1091
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source ./venv/bin/activate
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
pip3 install pytest
|
pip3 install pytest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,36 +110,22 @@ emqx_test(){
|
||||||
# fi
|
# fi
|
||||||
# sed -i '/emqx_telemetry/d' "${PACKAGE_PATH}"/emqx/data/loaded_plugins
|
# sed -i '/emqx_telemetry/d' "${PACKAGE_PATH}"/emqx/data/loaded_plugins
|
||||||
|
|
||||||
echo "running ${packagename} start"
|
run_test "${PACKAGE_PATH}/emqx/bin" "${PACKAGE_PATH}/emqx/log" "${PACKAGE_PATH}/emqx/releases/emqx_vars"
|
||||||
if ! "${PACKAGE_PATH}"/emqx/bin/emqx start; then
|
|
||||||
cat "${PACKAGE_PATH}"/emqx/log/erlang.log.1 || true
|
|
||||||
cat "${PACKAGE_PATH}"/emqx/log/emqx.log.1 || true
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
"$SCRIPTS/test/emqx-smoke-test.sh" 127.0.0.1 18083
|
|
||||||
pytest -v /paho-mqtt-testing/interoperability/test_client/V5/test_connect.py::test_basic
|
|
||||||
if ! "${PACKAGE_PATH}"/emqx/bin/emqx stop; then
|
|
||||||
cat "${PACKAGE_PATH}"/emqx/log/erlang.log.1 || true
|
|
||||||
cat "${PACKAGE_PATH}"/emqx/log/emqx.log.1 || true
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "running ${packagename} stop"
|
|
||||||
rm -rf "${PACKAGE_PATH}"/emqx
|
rm -rf "${PACKAGE_PATH}"/emqx
|
||||||
;;
|
;;
|
||||||
"deb")
|
"deb")
|
||||||
dpkg -i "${PACKAGE_PATH}/${packagename}"
|
dpkg -i "${PACKAGE_PATH}/${packagename}"
|
||||||
if [ "$(dpkg -l |grep emqx |awk '{print $1}')" != "ii" ]
|
if [ "$(dpkg -l | grep ${EMQX_NAME} | awk '{print $1}')" != "ii" ]
|
||||||
then
|
then
|
||||||
echo "package install error"
|
echo "package install error"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "running ${packagename} start"
|
run_test "/usr/bin" "/var/log/emqx" "$(dpkg -L ${EMQX_NAME} | grep emqx_vars)"
|
||||||
run_test
|
|
||||||
echo "running ${packagename} stop"
|
|
||||||
|
|
||||||
dpkg -r "${EMQX_NAME}"
|
dpkg -r "${EMQX_NAME}"
|
||||||
if [ "$(dpkg -l |grep emqx |awk '{print $1}')" != "rc" ]
|
if [ "$(dpkg -l | grep ${EMQX_NAME} | awk '{print $1}')" != "rc" ]
|
||||||
then
|
then
|
||||||
echo "package remove error"
|
echo "package remove error"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -146,6 +145,10 @@ emqx_test(){
|
||||||
# el8 is fine with python3
|
# el8 is fine with python3
|
||||||
true
|
true
|
||||||
;;
|
;;
|
||||||
|
"el9")
|
||||||
|
# el9 is fine with python3
|
||||||
|
true
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
alternatives --list | grep python && alternatives --set python /usr/bin/python2
|
alternatives --list | grep python && alternatives --set python /usr/bin/python2
|
||||||
;;
|
;;
|
||||||
|
@ -161,12 +164,10 @@ emqx_test(){
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "running ${packagename} start"
|
run_test "/usr/bin" "/var/log/emqx" "$(rpm -ql ${EMQX_NAME} | grep emqx_vars)"
|
||||||
run_test
|
|
||||||
echo "running ${packagename} stop"
|
|
||||||
|
|
||||||
rpm -e "${EMQX_NAME}"
|
rpm -e "${EMQX_NAME}"
|
||||||
if [ "$(rpm -q emqx)" != "package emqx is not installed" ];then
|
if [ "$(rpm -q ${EMQX_NAME})" != "package ${EMQX_NAME} is not installed" ];then
|
||||||
echo "package uninstall error"
|
echo "package uninstall error"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -175,8 +176,10 @@ emqx_test(){
|
||||||
}
|
}
|
||||||
|
|
||||||
run_test(){
|
run_test(){
|
||||||
|
local bin_dir="$1"
|
||||||
|
local log_dir="$2"
|
||||||
|
local emqx_env_vars="$3"
|
||||||
# sed -i '/emqx_telemetry/d' /var/lib/emqx/loaded_plugins
|
# sed -i '/emqx_telemetry/d' /var/lib/emqx/loaded_plugins
|
||||||
emqx_env_vars=$(dirname "$(readlink "$(command -v emqx)")")/../releases/emqx_vars
|
|
||||||
|
|
||||||
if [ -f "$emqx_env_vars" ];
|
if [ -f "$emqx_env_vars" ];
|
||||||
then
|
then
|
||||||
|
@ -194,21 +197,21 @@ EOF
|
||||||
echo "Error: cannot locate emqx_vars"
|
echo "Error: cannot locate emqx_vars"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if ! emqx 'start'; then
|
echo "running ${packagename} start"
|
||||||
cat /var/log/emqx/erlang.log.1 || true
|
if ! "${bin_dir}/emqx" 'start'; then
|
||||||
cat /var/log/emqx/emqx.log.1 || true
|
echo "ERROR: failed_to_start_emqx"
|
||||||
|
cat "${log_dir}/erlang.log.1" || true
|
||||||
|
cat "${log_dir}/emqx.log.1" || true
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
"$SCRIPTS/test/emqx-smoke-test.sh" 127.0.0.1 18083
|
"$SCRIPTS/test/emqx-smoke-test.sh" 127.0.0.1 18083
|
||||||
pytest -v /paho-mqtt-testing/interoperability/test_client/V5/test_connect.py::test_basic
|
pytest -v "${PAHO_MQTT_TESTING_PATH}"/interoperability/test_client/V5/test_connect.py::test_basic
|
||||||
# shellcheck disable=SC2009 # pgrep does not support Extended Regular Expressions
|
"${bin_dir}/emqx" ping
|
||||||
ps -ef | grep -E '\-progname\s.+emqx\s'
|
echo "running ${packagename} stop"
|
||||||
if ! emqx 'stop'; then
|
if ! "${bin_dir}/emqx" 'stop'; then
|
||||||
# shellcheck disable=SC2009 # pgrep does not support Extended Regular Expressions
|
|
||||||
ps -ef | grep -E '\-progname\s.+emqx\s'
|
|
||||||
echo "ERROR: failed_to_stop_emqx_with_the_stop_command"
|
echo "ERROR: failed_to_stop_emqx_with_the_stop_command"
|
||||||
cat /var/log/emqx/erlang.log.1 || true
|
cat "${log_dir}/erlang.log.1" || true
|
||||||
cat /var/log/emqx/emqx.log.1 || true
|
cat "${log_dir}/emqx.log.1" || true
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue