diff --git a/.github/workflows/run_docker_tests.yaml b/.github/workflows/run_docker_tests.yaml index cfc67be75..50468cdec 100644 --- a/.github/workflows/run_docker_tests.yaml +++ b/.github/workflows/run_docker_tests.yaml @@ -52,9 +52,11 @@ jobs: docker compose up --abort-on-container-exit --exit-code-from selenium - name: test two nodes cluster with proto_dist=inet_tls in docker 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) ./scripts/test/emqx-smoke-test.sh localhost $HTTP_PORT + ## -c menas 'cleanup' ./scripts/test/start-two-nodes-in-docker.sh -c - name: cleanup if: always() diff --git a/scripts/test/start-two-nodes-in-docker.sh b/scripts/test/start-two-nodes-in-docker.sh index c2cc30d5e..1a4af8c5e 100755 --- a/scripts/test/start-two-nodes-in-docker.sh +++ b/scripts/test/start-two-nodes-in-docker.sh @@ -17,6 +17,7 @@ NODE1="node1.$NET" NODE2="node2.$NET" COOKIE='this-is-a-secret' IPV6=0 +DASHBOARD_NODES='both' cleanup() { 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 "" echo "Options:" - echo " -h, --help Show this help message and exit." - echo " -P Add -p options for docker run to expose more HAProxy container ports." - echo " -6 Test with IPv6" - echo " -c Cleanup: delete docker network, force delete the containers." + echo " -h, --help: Show this help message and exit." + echo " -P: Add -p options for docker run to expose more HAProxy container ports." + echo " -6: Test with IPv6" + 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 case $opt in # -P option is treated similarly to docker run -P: @@ -47,6 +54,7 @@ do c) cleanup; exit 0;; h) show_help; exit 0;; 6) IPV6=1;; + d) DASHBOARD_NODES="$OPTARG";; *) ;; esac done @@ -55,6 +63,19 @@ shift $((OPTIND - 1)) IMAGE1="${1:-}" 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 show_help 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) balance source mode http - server emqx-1 $NODE1:18083 - server emqx-2 $NODE2:18083 + ${DASHBOARD_BACKEND1} + ${DASHBOARD_BACKEND2} ##---------------------------------------------------------------- ## TLS