From f8022a849ac2ebd1f52cd988e6dc1afb28575f36 Mon Sep 17 00:00:00 2001 From: Ivan Dyachkov Date: Wed, 2 Aug 2023 16:09:04 +0200 Subject: [PATCH] ci: fix docker and helm tests --- .github/workflows/build_docker_for_test.yaml | 26 ++++++------------ .github/workflows/run_docker_tests.yaml | 28 +++++++++++++------- .github/workflows/run_helm_tests.yaml | 12 ++++----- 3 files changed, 32 insertions(+), 34 deletions(-) diff --git a/.github/workflows/build_docker_for_test.yaml b/.github/workflows/build_docker_for_test.yaml index d4f3448c9..68f1ba72f 100644 --- a/.github/workflows/build_docker_for_test.yaml +++ b/.github/workflows/build_docker_for_test.yaml @@ -35,39 +35,33 @@ jobs: docker: runs-on: ubuntu-latest env: - EMQX_NAME: ${{ matrix.profile[0] }} + EMQX_NAME: ${{ matrix.profile }} OTP_VSN: 25.3.2-1 ELIXIR_VSN: 1.14.5 - PKG_VSN: ${{ matrix.profile[0] == 'emqx' && inputs.version-emqx || inputs.version-emqx-enterprise }} - EMQX_IMAGE_TAG: emqx/${{ matrix.profile[0] }}:${{ matrix.profile[0] == 'emqx' && inputs.version-emqx || inputs.version-emqx-enterprise }} - EMQX_IMAGE_OLD_VERSION_TAG: emqx/${{ matrix.profile[0] }}:${{ matrix.profile[1] }} + PKG_VSN: ${{ matrix.profile == 'emqx-enterprise' && inputs.version-emqx-enterprise || inputs.version-emqx }} strategy: fail-fast: false matrix: profile: - - ["emqx", "5.0.16"] - - ["emqx-elixir", "5.0.16"] - - ["emqx-enterprise", "5.0.1"] + - emqx + - emqx-enterprise + - emqx-elixir steps: - uses: actions/checkout@v3 - name: build and export to Docker id: build run: | - make ${{ matrix.profile[0] }}-docker - echo "EMQX_IMAGE_TAG=$(cat .docker_image_tag)" >> $GITHUB_OUTPUT + make ${EMQX_NAME}-docker + echo "EMQX_IMAGE_TAG=$(cat .docker_image_tag)" >> $GITHUB_ENV - name: smoke test - env: - EMQX_IMAGE_TAG: ${{ steps.build.outputs.EMQX_IMAGE_TAG }} run: | CID=$(docker run -d --rm -P $EMQX_IMAGE_TAG) HTTP_PORT=$(docker inspect --format='{{(index (index .NetworkSettings.Ports "18083/tcp") 0).HostPort}}' $CID) ./scripts/test/emqx-smoke-test.sh localhost $HTTP_PORT docker stop $CID - name: export docker image - env: - EMQX_IMAGE_TAG: ${{ steps.build.outputs.EMQX_IMAGE_TAG }} run: | docker save $EMQX_IMAGE_TAG | gzip > $EMQX_NAME-docker-$PKG_VSN.tar.gz - uses: actions/upload-artifact@v3 @@ -75,8 +69,4 @@ jobs: name: "${{ env.EMQX_NAME }}-docker" path: "${{ env.EMQX_NAME }}-docker-${{ env.PKG_VSN }}.tar.gz" retention-days: 3 - - name: cleanup - if: always() - working-directory: ./scripts/ui-tests - run: | - docker compose rm -fs + diff --git a/.github/workflows/run_docker_tests.yaml b/.github/workflows/run_docker_tests.yaml index 63bba2eef..b74c34e97 100644 --- a/.github/workflows/run_docker_tests.yaml +++ b/.github/workflows/run_docker_tests.yaml @@ -23,26 +23,28 @@ on: jobs: main: runs-on: ${{ github.repository_owner == 'emqx' && 'aws-amd64' || 'ubuntu-22.04' }} + env: + EMQX_NAME: ${{ matrix.profile[0] }} + PKG_VSN: ${{ matrix.profile[0] == 'emqx-enterprise' && inputs.version-emqx-enterprise || inputs.version-emqx }} + EMQX_IMAGE_OLD_VERSION_TAG: emqx/${{ matrix.profile[0] }}:${{ matrix.profile[1] }} strategy: fail-fast: false matrix: profile: - - emqx - - emqx-enterprise - - emqx-elixir + - ["emqx", "5.0.16"] + - ["emqx-elixir", "5.0.16"] + - ["emqx-enterprise", "5.0.1"] steps: - uses: AutoModality/action-clean@v1 - uses: actions/checkout@v3 - uses: actions/download-artifact@v3 with: - name: ${{ matrix.profile }}-docker + name: ${{ matrix.profile[0] }}-docker path: /tmp - name: load docker image - env: - PKG_VSN: ${{ inputs.version-emqx }} run: | - EMQX_IMAGE_TAG=$(docker load < /tmp/emqx-docker-${PKG_VSN}.tar.gz | sed 's/Loaded image: //g') + EMQX_IMAGE_TAG=$(docker load < /tmp/${EMQX_NAME}-${PKG_VSN}.tar.gz | sed 's/Loaded image: //g') echo "EMQX_IMAGE_TAG=$EMQX_IMAGE_TAG" >> $GITHUB_ENV - name: test two nodes cluster with proto_dist=inet_tls in docker run: | @@ -56,10 +58,17 @@ jobs: run: | set -eu docker compose up --abort-on-container-exit --exit-code-from selenium + - name: cleanup + if: always() + working-directory: ./scripts/ui-tests + run: | + docker compose rm -fs pytest: runs-on: ${{ github.repository_owner == 'emqx' && 'aws-amd64' || 'ubuntu-22.04' }} env: + EMQX_NAME: ${{ matrix.profile[0] }} + PKG_VSN: ${{ matrix.profile[0] == 'emqx-enterprise' && inputs.version-emqx-enterprise || inputs.version-emqx }} DB_BACKEND: ${{ matrix.cluster_db_backend }} strategy: @@ -80,10 +89,8 @@ jobs: name: ${{ matrix.profile }}-docker path: /tmp - name: load docker image - env: - PKG_VSN: ${{ inputs.version-emqx }} run: | - EMQX_IMAGE_TAG=$(docker load < /tmp/emqx-docker-${PKG_VSN}.tar.gz | sed 's/Loaded image: //g') + EMQX_IMAGE_TAG=$(docker load < /tmp/${EMQX_NAME}-${PKG_VSN}.tar.gz | sed 's/Loaded image: //g') echo "EMQX_IMAGE_TAG=$EMQX_IMAGE_TAG" >> $GITHUB_ENV - name: run emqx timeout-minutes: 5 @@ -105,4 +112,5 @@ jobs: # simple smoke test for node_dump - name: test node_dump run: | + docker exec -u root node1.emqx.io apt update && apt install -y net-tools docker exec node1.emqx.io node_dump diff --git a/.github/workflows/run_helm_tests.yaml b/.github/workflows/run_helm_tests.yaml index 6cc872c47..0b6aa8334 100644 --- a/.github/workflows/run_helm_tests.yaml +++ b/.github/workflows/run_helm_tests.yaml @@ -22,7 +22,10 @@ on: jobs: helm_test: - runs-on: ${{ github.repository_owner == 'emqx' && 'aws-amd64' || 'ubuntu-22.04' }} + runs-on: ubuntu-22.04 + env: + EMQX_NAME: ${{ matrix.profile }} + PKG_VSN: ${{ matrix.profile == 'emqx-enterprise' && inputs.version-emqx-enterprise || inputs.version-emqx }} strategy: fail-fast: false @@ -35,7 +38,6 @@ jobs: - emqx-enterprise steps: - - uses: AutoModality/action-clean@v1 - uses: actions/checkout@v3 with: path: source @@ -44,12 +46,10 @@ jobs: name: "${{ matrix.profile }}-docker" path: /tmp - name: load docker image - env: - PKG_VSN: ${{ inputs.version-emqx }} run: | - EMQX_TAG=$(docker load < /tmp/emqx-docker-${PKG_VSN}.tar.gz | sed 's/Loaded image: //g') + EMQX_TAG=$(docker load < /tmp/${EMQX_NAME}-${PKG_VSN}.tar.gz | sed 's/Loaded image: //g') echo "EMQX_TAG=$EMQX_TAG" >> $GITHUB_ENV - echo "TARGET=emqx/${{ matrix.profile }}" >> $GITHUB_ENV + echo "TARGET=emqx/${EMQX_NAME}" >> $GITHUB_ENV - run: minikube start - run: minikube image load $TARGET:$EMQX_TAG - name: run emqx on chart (k8s)