ci: test dashboard against latest version

This commit is contained in:
zmstone 2024-06-22 12:04:48 +02:00
parent af0fe1db89
commit 6b3f293ac6
2 changed files with 31 additions and 8 deletions

View File

@ -52,9 +52,11 @@ jobs:
docker compose up --abort-on-container-exit --exit-code-from selenium docker compose up --abort-on-container-exit --exit-code-from selenium
- name: test two nodes cluster with proto_dist=inet_tls in docker - name: test two nodes cluster with proto_dist=inet_tls in docker
run: | run: |
./scripts/test/start-two-nodes-in-docker.sh -P $_EMQX_DOCKER_IMAGE_TAG $EMQX_IMAGE_OLD_VERSION_TAG ## -d 1 means only put node 1 (latest version) behind haproxy
./scripts/test/start-two-nodes-in-docker.sh -d 1 -P $_EMQX_DOCKER_IMAGE_TAG $EMQX_IMAGE_OLD_VERSION_TAG
HTTP_PORT=$(docker inspect --format='{{(index (index .NetworkSettings.Ports "18083/tcp") 0).HostPort}}' haproxy) HTTP_PORT=$(docker inspect --format='{{(index (index .NetworkSettings.Ports "18083/tcp") 0).HostPort}}' haproxy)
./scripts/test/emqx-smoke-test.sh localhost $HTTP_PORT ./scripts/test/emqx-smoke-test.sh localhost $HTTP_PORT
## -c menas 'cleanup'
./scripts/test/start-two-nodes-in-docker.sh -c ./scripts/test/start-two-nodes-in-docker.sh -c
- name: cleanup - name: cleanup
if: always() if: always()

View File

@ -17,6 +17,7 @@ NODE1="node1.$NET"
NODE2="node2.$NET" NODE2="node2.$NET"
COOKIE='this-is-a-secret' COOKIE='this-is-a-secret'
IPV6=0 IPV6=0
DASHBOARD_NODES='both'
cleanup() { cleanup() {
docker rm -f haproxy >/dev/null 2>&1 || true docker rm -f haproxy >/dev/null 2>&1 || true
@ -32,13 +33,19 @@ show_help() {
echo "EMQX_IMAGE2 is the same as EMQX_IMAGE1 if not set" echo "EMQX_IMAGE2 is the same as EMQX_IMAGE1 if not set"
echo "" echo ""
echo "Options:" echo "Options:"
echo " -h, --help Show this help message and exit." echo " -h, --help: Show this help message and exit."
echo " -P Add -p options for docker run to expose more HAProxy container ports." echo " -P: Add -p options for docker run to expose more HAProxy container ports."
echo " -6 Test with IPv6" echo " -6: Test with IPv6"
echo " -c Cleanup: delete docker network, force delete the containers." echo " -c: Cleanup: delete docker network, force delete the containers."
echo " -d: '1', '2', or 'both' (defualt = 'both')"
echo " 1: Only put node 1 behind haproxy"
echo " 2: Only put node 2 behind haproxy"
echo " both: This is the default value, which means both nodes serve dashboard"
echo " This is often needed for tests which want to check one dashboard version"
echo " when starting two different versions of EMQX."
} }
while getopts "hc6P:" opt while getopts "hc6P:d:" opt
do do
case $opt in case $opt in
# -P option is treated similarly to docker run -P: # -P option is treated similarly to docker run -P:
@ -47,6 +54,7 @@ do
c) cleanup; exit 0;; c) cleanup; exit 0;;
h) show_help; exit 0;; h) show_help; exit 0;;
6) IPV6=1;; 6) IPV6=1;;
d) DASHBOARD_NODES="$OPTARG";;
*) ;; *) ;;
esac esac
done done
@ -55,6 +63,19 @@ shift $((OPTIND - 1))
IMAGE1="${1:-}" IMAGE1="${1:-}"
IMAGE2="${2:-${IMAGE1}}" IMAGE2="${2:-${IMAGE1}}"
DASHBOARD_BACKEND1="server emqx-1 $NODE1:18083"
DASHBOARD_BACKEND2="server emqx-2 $NODE2:18083"
case "${DASHBOARD_NODES}" in
1)
DASHBOARD_BACKEND2=""
;;
2)
DASHBOARD_BACKEND1=""
;;
both)
;;
esac
if [ -z "${IMAGE1:-}" ] || [ -z "${IMAGE2:-}" ]; then if [ -z "${IMAGE1:-}" ] || [ -z "${IMAGE2:-}" ]; then
show_help show_help
exit 1 exit 1
@ -146,8 +167,8 @@ backend emqx_dashboard_back
# load randomly will cause the browser fail to GET some chunks (or get bad chunks if names clash) # load randomly will cause the browser fail to GET some chunks (or get bad chunks if names clash)
balance source balance source
mode http mode http
server emqx-1 $NODE1:18083 ${DASHBOARD_BACKEND1}
server emqx-2 $NODE2:18083 ${DASHBOARD_BACKEND2}
##---------------------------------------------------------------- ##----------------------------------------------------------------
## TLS ## TLS