run_docker_tests.yaml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. name: Docker image tests
  2. concurrency:
  3. group: docker-tests-${{ github.event_name }}-${{ github.ref }}
  4. cancel-in-progress: true
  5. on:
  6. workflow_call:
  7. permissions:
  8. contents: read
  9. jobs:
  10. basic-tests:
  11. runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
  12. defaults:
  13. run:
  14. shell: bash
  15. strategy:
  16. fail-fast: false
  17. matrix:
  18. profile:
  19. - ["emqx", "emqx/emqx:5.0.16"]
  20. - ["emqx-enterprise", "emqx/emqx-enterprise:5.0.1"]
  21. env:
  22. EMQX_NAME: ${{ matrix.profile[0] }}
  23. EMQX_IMAGE_OLD_VERSION_TAG: ${{ matrix.profile[1] }}
  24. steps:
  25. - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  26. - name: Set up environment
  27. id: env
  28. run: |
  29. source env.sh
  30. PKG_VSN=$(docker run --rm -v $(pwd):$(pwd) -w $(pwd) -u $(id -u) "$EMQX_BUILDER" ./pkg-vsn.sh "$EMQX_NAME")
  31. echo "PKG_VSN=$PKG_VSN" >> "$GITHUB_ENV"
  32. - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
  33. with:
  34. name: ${{ env.EMQX_NAME }}-docker
  35. path: /tmp
  36. - name: load docker image
  37. run: |
  38. _EMQX_DOCKER_IMAGE_TAG=$(docker load < /tmp/${EMQX_NAME}-docker-${PKG_VSN}.tar.gz 2>/dev/null | sed 's/Loaded image: //g')
  39. echo "_EMQX_DOCKER_IMAGE_TAG=$_EMQX_DOCKER_IMAGE_TAG" >> $GITHUB_ENV
  40. - name: dashboard tests
  41. working-directory: ./scripts/ui-tests
  42. run: |
  43. set -eu
  44. docker compose up --abort-on-container-exit --exit-code-from selenium
  45. - name: test two nodes cluster with proto_dist=inet_tls in docker
  46. run: |
  47. ## -d 1 means only put node 1 (latest version) behind haproxy
  48. ./scripts/test/start-two-nodes-in-docker.sh -d 1 -P $_EMQX_DOCKER_IMAGE_TAG $EMQX_IMAGE_OLD_VERSION_TAG
  49. HTTP_PORT=$(docker inspect --format='{{(index (index .NetworkSettings.Ports "18083/tcp") 0).HostPort}}' haproxy)
  50. ./scripts/test/emqx-smoke-test.sh localhost $HTTP_PORT
  51. ## -c menas 'cleanup'
  52. ./scripts/test/start-two-nodes-in-docker.sh -c
  53. - name: cleanup
  54. if: always()
  55. working-directory: ./scripts/ui-tests
  56. run: |
  57. docker compose rm -fs
  58. paho-mqtt-testing:
  59. runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
  60. defaults:
  61. run:
  62. shell: bash
  63. env:
  64. EMQX_NAME: ${{ matrix.profile }}
  65. _EMQX_TEST_DB_BACKEND: ${{ matrix.cluster_db_backend }}
  66. strategy:
  67. fail-fast: false
  68. matrix:
  69. profile:
  70. - emqx
  71. - emqx-enterprise
  72. - emqx-elixir
  73. cluster_db_backend:
  74. - mnesia
  75. - rlog
  76. steps:
  77. - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  78. - name: Set up environment
  79. id: env
  80. run: |
  81. source env.sh
  82. PKG_VSN=$(docker run --rm -v $(pwd):$(pwd) -w $(pwd) -u $(id -u) "$EMQX_BUILDER" ./pkg-vsn.sh "$EMQX_NAME")
  83. echo "PKG_VSN=$PKG_VSN" >> "$GITHUB_ENV"
  84. - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
  85. with:
  86. name: ${{ env.EMQX_NAME }}-docker
  87. path: /tmp
  88. - name: load docker image
  89. run: |
  90. EMQX_IMAGE_TAG=$(docker load < /tmp/${EMQX_NAME}-docker-${PKG_VSN}.tar.gz 2>/dev/null | sed 's/Loaded image: //g')
  91. echo "_EMQX_DOCKER_IMAGE_TAG=$EMQX_IMAGE_TAG" >> $GITHUB_ENV
  92. - name: run emqx
  93. timeout-minutes: 5
  94. run: |
  95. ./.ci/docker-compose-file/scripts/run-emqx.sh $_EMQX_DOCKER_IMAGE_TAG $_EMQX_TEST_DB_BACKEND
  96. - name: make paho tests
  97. run: |
  98. if ! docker exec -i python /scripts/pytest.sh "$_EMQX_TEST_DB_BACKEND"; then
  99. echo "DUMP_CONTAINER_LOGS_BGN"
  100. echo "============== haproxy =============="
  101. docker logs haproxy
  102. echo "============== node1 =============="
  103. docker logs node1.emqx.io
  104. echo "============== node2 =============="
  105. docker logs node2.emqx.io
  106. echo "DUMP_CONTAINER_LOGS_END"
  107. exit 1
  108. fi
  109. # simple smoke test for node_dump
  110. - name: test node_dump
  111. run: |
  112. docker exec -t -u root node1.emqx.io bash -c 'apt-get -y update && apt-get -y install net-tools'
  113. docker exec -t -u root node1.emqx.io node_dump