deploy-test.yaml 13.7 KB
Newer Older
1
name: Deploy Test
Z
zhuwenxing 已提交
2 3 4

on:
  workflow_dispatch:
5 6 7 8
    inputs:
      old_image_repo:
        description: The image repository name to use for the deploy test
        required: true
9
        default: 'milvusdb/milvus'
10 11 12 13 14 15 16 17 18

      old_image_tag:
        description: The old image tag to use for the deploy test
        required: true
        default: 'latest'

      previous_release_version:
        description: The previous release version to use for the deploy test
        required: true
19
        default: 'v2.0.2'
20 21 22 23

      new_image_repo:
        description: The image repository name to use for the deploy test
        required: true
24
        default: 'milvusdb/milvus'
25 26 27 28 29 30

      new_image_tag:
        description: The new image tag to use for the deploy test
        required: true
        default: 'master-latest'

Z
zhuwenxing 已提交
31
  schedule:
32 33 34 35 36 37 38 39 40
    # * is a special character in YAML so you have to quote this string
    #         ┌───────────── minute (0 - 59)
    #         │  ┌───────────── hour (0 - 23)
    #         │  │ ┌───────────── day of the month (1 - 31)
    #         │  │ │ ┌───────────── month (1 - 12 or JAN-DEC)
    #         │  │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
    #         │  │ │ │ │
    #         │  │ │ │ │
    #         │  │ │ │ │
Z
zhuwenxing 已提交
41 42 43 44 45 46 47 48 49 50
    - cron: "30 20 * * *"

jobs:

  test-docker-compose:

    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
51 52
        mode: [standalone, cluster]
        task: [reinstall, upgrade]
Z
zhuwenxing 已提交
53 54

    steps:
55 56 57 58
      - name: Set env param
        env:
          DEFAULT_OLD_IMAGE_REPO: "milvusdb/milvus"
          DEFAULT_OLD_IMAGE_TAG: "latest"
59
          DEFAULT_PREVIOUS_RELEASE_VERSION: "v2.0.2"
60
          DEFAULT_NEW_IMAGE_REPO: "milvusdb/milvus"
61 62 63 64 65 66 67
          DEFAULT_NEW_IMAGE_TAG: "master-latest"
        run: |
          echo "OLD_IMAGE_REPO=${{ github.event.inputs.old_image_repo || env.DEFAULT_OLD_IMAGE_REPO }}" >> $GITHUB_ENV
          echo "OLD_IMAGE_TAG=${{ github.event.inputs.old_image_tag || env.DEFAULT_OLD_IMAGE_TAG }}" >> $GITHUB_ENV
          echo "PREVIOUS_RELEASE_VERSION=${{ github.event.inputs.previous_release_version || env.DEFAULT_PREVIOUS_RELEASE_VERSION }}" >> $GITHUB_ENV
          echo "NEW_IMAGE_REPO=${{ github.event.inputs.new_image_repo || env.DEFAULT_NEW_IMAGE_REPO }}" >> $GITHUB_ENV
          echo "NEW_IMAGE_TAG=${{ github.event.inputs.new_image_tag || env.DEFAULT_NEW_IMAGE_TAG }}" >> $GITHUB_ENV
68

Z
zhuwenxing 已提交
69 70 71 72 73 74
      - uses: actions/checkout@v2

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: 3.8
75

Z
zhuwenxing 已提交
76 77
      - name: Install dependency
        shell: bash
78
        working-directory: tests/python_client
Z
zhuwenxing 已提交
79
        run: |
80
          pip install -r requirements.txt --trusted-host https://test.pypi.org
81

82
      - name: First Milvus deployment
83
        timeout-minutes: 15
Z
zhuwenxing 已提交
84
        shell: bash
85
        working-directory: tests/python_client/deploy/${{ matrix.mode }}
Z
zhuwenxing 已提交
86
        run: |
87
          source ../utils.sh
88
          if [ ${{ matrix.task }} == "reinstall" ]; then
89
            wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/docker/${{ matrix.mode }}/docker-compose.yml -O docker-compose.yml;
90
            replace_image_tag ${{ env.NEW_IMAGE_REPO }} ${{ env.NEW_IMAGE_TAG }};
91

92 93 94
          fi
          if [ ${{ matrix.task }} == "upgrade" ]; then
            wget https://github.com/milvus-io/milvus/releases/download/${{ env.PREVIOUS_RELEASE_VERSION }}/milvus-${{ matrix.mode }}-docker-compose.yml -O docker-compose.yml;
95
            replace_image_tag ${{ env.OLD_IMAGE_REPO }} ${{ env.OLD_IMAGE_TAG }};
96
          fi
97
          docker-compose up -d
98 99 100 101
          bash ../check_healthy.sh
          docker-compose ps -a
          sleep 10s
      - name: Run first test
102
        timeout-minutes: 15
103 104 105
        shell: bash
        working-directory: tests/python_client/deploy/scripts
        run: |
106
          if [ ${{ matrix.task }} == "reinstall" ]; then
107 108 109 110 111
            python3 action_before_reinstall.py
          fi
          if [ ${{ matrix.task }} == "upgrade" ]; then
            python3 action_before_upgrade.py
          fi
112 113 114 115 116 117
      - name: Milvus Idle Time
        timeout-minutes: 5
        shell: bash
        working-directory: tests/python_client/deploy
        run: |
          sleep 60s
118 119 120 121 122 123 124 125
      - name: Export logs
        if: ${{ always() }}
        shell: bash
        working-directory: tests/python_client/deploy/${{ matrix.mode }}
        run: |
          docker-compose ps -a || true
          mkdir -p logs/first_deploy
          bash ../../../scripts/export_log_docker.sh ./logs/first_deploy || echo "export logs failed"
126
      - name: Second Milvus deployment
127
        timeout-minutes: 15
128 129 130
        shell: bash
        working-directory: tests/python_client/deploy/${{ matrix.mode }}
        run: |
131
          source ../utils.sh
132
          if [ ${{ matrix.task }} == "reinstall" ]; then
133
            docker-compose restart
134 135 136
          fi
          if [ ${{ matrix.task }} == "upgrade" ]; then
            wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/docker/${{ matrix.mode }}/docker-compose.yml -O docker-compose.yml;
137 138
            replace_image_tag ${{ env.NEW_IMAGE_REPO }} ${{ env.NEW_IMAGE_TAG }};
            docker-compose up -d;
139 140 141
          fi
          bash ../check_healthy.sh
          docker-compose ps -a
142

143 144 145
          echo "sleep 120s for the second deployment to be ready"
          sleep 120s
      - name: Run second test
146
        timeout-minutes: 15
147 148 149
        shell: bash
        working-directory: tests/python_client/deploy/scripts
        run: |
150
          if [ ${{ matrix.task }} == "reinstall" ]; then
151 152 153 154 155 156 157 158 159 160 161
            python3 action_after_reinstall.py
          fi
          if [ ${{ matrix.task }} == "upgrade" ]; then
            python3 action_after_upgrade.py
          fi
      - name: Export logs
        if: ${{ always() }}
        shell: bash
        working-directory: tests/python_client/deploy/${{ matrix.mode }}
        run: |
          docker-compose ps -a || true
162 163
          mkdir -p logs/second_deploy
          bash ../../../scripts/export_log_docker.sh ./logs/second_deploy || echo "export logs failed"
Z
zhuwenxing 已提交
164 165 166 167 168 169 170 171 172
      - name: 'Send mail'
        if: ${{ failure() }}
        uses: dawidd6/action-send-mail@v3
        with:
          server_address: ${{ secrets.EMAIL_SERVICE_NAME }}
          server_port: 465
          username: ${{ secrets.TEST_EMAIL_USERNAME }}
          password: ${{ secrets.TEST_EMAIL_PASSWORD  }}
          subject: Deploy Test
173
          body: "test ${{ matrix.mode }} ${{ matrix.task }} failed \n You can view it at https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
Z
zhuwenxing 已提交
174 175 176 177
          to: ${{ secrets.QA_EMAIL_ADDRESS }}
          from: GitHub Actions

      - name: Upload logs
178
        if: ${{ ! success() }}
Z
zhuwenxing 已提交
179 180
        uses: actions/upload-artifact@v2
        with:
181
          name: docker-compose-logs-${{ matrix.mode }}-${{ matrix.task }}
Z
zhuwenxing 已提交
182 183
          path: tests/python_client/deploy/${{ matrix.mode }}/logs

Z
zhuwenxing 已提交
184 185 186 187 188
  test-helm-install:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
189
        mq_type: [pulsar, kafka]
190
        mode: [standalone,cluster]
191 192 193 194 195
        task: [reinstall,upgrade]
        exclude:
          - mq_type: kafka
            task: upgrade

Z
zhuwenxing 已提交
196
    steps:
197

Z
zhuwenxing 已提交
198 199
      - name: Creating kind cluster
        uses: helm/kind-action@v1.2.0
200

Z
zhuwenxing 已提交
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
      - name: Print cluster information
        run: |
          kubectl config view
          kubectl cluster-info
          kubectl get nodes
          kubectl get pods -n kube-system
          helm version
          kubectl version

      - uses: actions/checkout@v2

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: 3.8

      - name: Install dependency
        shell: bash
219
        working-directory: tests/python_client
Z
zhuwenxing 已提交
220
        run: |
221
          pip install -r requirements.txt --trusted-host https://test.pypi.org
222 223 224 225 226 227 228 229

      - name: Modify chart value config
        timeout-minutes: 1
        shell: bash
        working-directory: tests/python_client/deploy
        run: |
          yq -i ".kafka.enabled = false" cluster-values.yaml
          yq -i ".pulsar.enabled = false" cluster-values.yaml
230 231
          yq -i ".kafka.enabled = false" cluster-values-second.yaml
          yq -i ".pulsar.enabled = false" cluster-values-second.yaml
232
          yq -i ".${{ matrix.mq_type }}.enabled = true" cluster-values.yaml
233
          yq -i ".${{ matrix.mq_type }}.enabled = true" cluster-values-second.yaml
234 235 236
          if [ ${{ matrix.mq_type }} == "kafka" ]; then
              yq -i ".kafka.enabled = true" standalone-values.yaml;
          fi
237

Z
zhuwenxing 已提交
238
      - name: First Milvus Deployment
239
        timeout-minutes: 15
Z
zhuwenxing 已提交
240
        shell: bash
241
        working-directory: tests/python_client/deploy
Z
zhuwenxing 已提交
242 243 244 245
        run: |
          helm repo add milvus https://milvus-io.github.io/milvus-helm
          helm repo update

246
          # if the task is reinstall, install milvus with latest image in repo milvusdb/milvus
247 248 249 250 251 252 253 254 255 256
          # for cluster mode
          if [ ${{ matrix.task }} == "reinstall" ] && [ ${{ matrix.mode }} == "cluster" ]; then
              echo "task: ${{ matrix.task }} mode: ${{ matrix.mode }}";
              helm install --wait --timeout 720s deploy-testing milvus/milvus -f cluster-values.yaml;
          fi
          # for standalone mode
          if [ ${{ matrix.task }} == "reinstall" ] && [ ${{ matrix.mode }} == "standalone" ]; then
              echo "task: ${{ matrix.task }} mode: ${{ matrix.mode }}";
              helm install --wait --timeout 720s deploy-testing milvus/milvus -f standalone-values.yaml;
          fi
Z
zhuwenxing 已提交
257 258

          # if the task is upgrade, install milvus with latest rc image in repo milvusdb/milvus
259 260
          if [ ${{ matrix.task }} == "upgrade" ] && [ ${{ matrix.mode }} == "cluster" ]; then
              echo "task: ${{ matrix.task }} mode: ${{ matrix.mode }}";
261
              helm install --wait --timeout 720s deploy-testing milvus/milvus --set image.all.repository=milvusdb/milvus --set image.all.tag=latest --set etcd.image.repository=bitnami/etcd --set etcd.image.tag=3.5.0-debian-10-r24 -f cluster-values.yaml;
262 263 264
          fi
          if [ ${{ matrix.task }} == "upgrade" ] && [ ${{ matrix.mode }} == "standalone" ]; then
              echo "task: ${{ matrix.task }} mode: ${{ matrix.mode }}";
265
              helm install --wait --timeout 720s deploy-testing milvus/milvus --set image.all.repository=milvusdb/milvus --set image.all.tag=latest --set etcd.image.repository=bitnami/etcd --set etcd.image.tag=3.5.0-debian-10-r24 -f standalone-values.yaml;
266 267
          fi

Z
zhuwenxing 已提交
268 269 270 271 272 273 274 275
          kubectl get pods
          sleep 20s
          kubectl get pods
          kubectl port-forward service/deploy-testing-milvus 19530 >/dev/null 2>&1 &
          sleep 20s
          # check whether port-forward success
          nc -vz 127.0.0.1 19530

276 277 278 279 280
      - name: Run first test
        timeout-minutes: 15
        shell: bash
        working-directory: tests/python_client/deploy
        run: |
Z
zhuwenxing 已提交
281
          # first test
282
          if [ ${{ matrix.task }} == "reinstall" ]; then python scripts/action_before_reinstall.py; fi
Z
zhuwenxing 已提交
283
          if [ ${{ matrix.task }} == "upgrade" ]; then python scripts/action_before_upgrade.py; fi
284 285 286 287 288 289
      - name: Milvus Idle Time
        timeout-minutes: 5
        shell: bash
        working-directory: tests/python_client/deploy
        run: |
          sleep 60s
290 291 292 293 294 295 296 297
      - name: Export logs
        if: ${{ always() }}
        shell: bash
        working-directory: tests/python_client/deploy
        run: |
          kubectl get pod
          # export k8s log for milvus
          bash ../../scripts/export_log_k8s.sh default deploy-testing k8s_logs/first_deploy
298 299 300 301 302
      - name: Restart Milvus
        timeout-minutes: 15
        shell: bash
        working-directory: tests/python_client/deploy
        run: |
Z
zhuwenxing 已提交
303
          # uninstall milvus
304
          if [ ${{ matrix.mode }} == "standalone" ];
305 306 307 308 309 310
          then
            kubectl delete pod -l app.kubernetes.io/instance=deploy-testing --grace-period=0 --force;
            kubectl delete pod -l release=deploy-testing --grace-period=0 --force;
          else
            helm uninstall deploy-testing
          fi
311

Z
zhuwenxing 已提交
312
      - name: Seconde Milvus Deployment
313
        timeout-minutes: 15
Z
zhuwenxing 已提交
314
        shell: bash
315
        working-directory: tests/python_client/deploy
Z
zhuwenxing 已提交
316
        run: |
317
          if [ ${{ matrix.mode }} == "cluster" ]; then helm install --wait --timeout 720s deploy-testing milvus/milvus -f cluster-values-second.yaml; fi
318
          if [ ${{ matrix.mode }} == "standalone" ]; then helm upgrade --wait --timeout 720s deploy-testing milvus/milvus -f standalone-values.yaml; fi
Z
zhuwenxing 已提交
319 320 321 322 323
          kubectl get pods
          sleep 20s
          kubectl get pods
          ps aux|grep forward|grep -v grep|awk '{print $2}'|xargs kill -9
          kubectl port-forward service/deploy-testing-milvus 19530 >/dev/null 2>&1 &
324
          sleep 120s
Z
zhuwenxing 已提交
325 326
          # check whether port-forward success
          nc -vz 127.0.0.1 19530
327 328 329 330 331 332

      - name: Run second test
        timeout-minutes: 15
        shell: bash
        working-directory: tests/python_client/deploy
        run: |
Z
zhuwenxing 已提交
333
          # second test
334
          if [ ${{ matrix.task }} == "reinstall" ]; then python scripts/action_after_reinstall.py; fi
Z
zhuwenxing 已提交
335
          if [ ${{ matrix.task }} == "upgrade" ]; then python scripts/action_after_upgrade.py; fi
336

Z
zhuwenxing 已提交
337 338 339 340 341 342 343
      - name: Export logs
        if: ${{ always() }}
        shell: bash
        working-directory: tests/python_client/deploy
        run: |
          kubectl get pod
          # export k8s log for milvus
344
          bash ../../scripts/export_log_k8s.sh default deploy-testing k8s_logs/second_deploy
345

Z
zhuwenxing 已提交
346
      - name: Upload logs
347
        if: ${{ ! success() }}
Z
zhuwenxing 已提交
348 349
        uses: actions/upload-artifact@v2
        with:
350
          name: helm-log-${{ matrix.mq_type }}-${{ matrix.mode }}-${{ matrix.task }}
351
          path: tests/python_client/deploy/k8s_logs