github.com/polarismesh/polaris@v1.17.8/.github/workflows/integration-testing-mysql.yml (about) 1 # Tencent is pleased to support the open source community by making Polaris available. 2 # 3 # Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 4 # 5 # Licensed under the BSD 3-Clause License (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # https://opensource.org/licenses/BSD-3-Clause 10 # 11 # Unless required by applicable law or agreed to in writing, software distributed 12 # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 13 # CONDITIONS OF ANY KIND, either express or implied. See the License for the 14 # specific language governing permissions and limitations under the License. 15 16 name: IntegrationTest(MySQL + Redis) 17 18 on: 19 push: 20 branches: 21 - main 22 - release* 23 pull_request: 24 branches: 25 - main 26 - release* 27 28 permissions: 29 contents: write 30 31 # Always force the use of Go modules 32 env: 33 GO111MODULE: on 34 35 jobs: 36 build: 37 strategy: 38 matrix: 39 os: [ ubuntu-latest ] 40 goarch: [ amd64 ] 41 goos: [ linux ] 42 include: 43 - os: ubuntu-latest 44 goos: linux 45 goarch: amd64 46 vert: 1 47 exclude: 48 - os: ubuntu-latest 49 goos: windows 50 - os: ubuntu-latest 51 goos: darwin 52 - os: windows-latest 53 goos: linux 54 - os: windows-latest 55 goos: darwin 56 - os: macos-latest 57 goos: windows 58 - os: macos-latest 59 goos: linux 60 61 runs-on: ${{ matrix.os }} 62 services: 63 # Label used to access the service container 64 redis: 65 # Docker Hub image 66 image: redis 67 # Set health checks to wait until redis has started 68 options: >- 69 --health-cmd "redis-cli ping" 70 --health-interval 10s 71 --health-timeout 5s 72 --health-retries 5 73 ports: 74 # Maps port 6379 on service container to the host 75 - 6379:6379 76 steps: 77 # Setup the environment. 78 - name: Setup Go 79 uses: actions/setup-go@v4 80 with: 81 go-version: "1.20" 82 # Checkout latest code 83 - name: Checkout repo 84 uses: actions/checkout@v2 85 86 # Compile 87 - name: Build server 88 env: 89 GOOS: ${{ matrix.goos }} 90 GOARCH: ${{ matrix.goarch }} 91 run: make build 92 93 - name: Initialize database 94 env: 95 MYSQL_DB_USER: root 96 MYSQL_DB_PWD: root 97 MYSQL_DATABASE: polaris_server 98 run: | 99 sudo systemctl start mysql.service 100 mysql -e 'CREATE DATABASE ${{ env.MYSQL_DATABASE }};' -u${{ env.MYSQL_DB_USER }} -p${{ env.MYSQL_DB_PWD }} 101 mysql -e "ALTER USER '${{ env.MYSQL_DB_USER }}'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';" -u${{ env.MYSQL_DB_USER }} -p${{ env.MYSQL_DB_PWD }} 102 103 # Run interface tests 104 - name: run discover interface tests 105 env: 106 MYSQL_DB_USER: root 107 MYSQL_DB_PWD: root 108 REDIS_ADDR: 127.0.0.1:6379 109 REDIS_PWD: 110 run: | 111 export STORE_MODE=sqldb 112 export MYSQL_DB_USER=${{ env.MYSQL_DB_USER }} 113 export MYSQL_DB_PWD=${{ env.MYSQL_DB_PWD }} 114 echo "cur STORE MODE=${STORE_MODE}, MYSQL_DB_USER=${MYSQL_DB_USER}, MYSQL_DB_PWD=${MYSQL_DB_PWD}" 115 # 设置严格模式 116 mysql -h127.0.0.1 -P3306 -u${{ env.MYSQL_DB_USER }} -p"${{ env.MYSQL_DB_PWD }}" -e "set sql_mode='STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION'"; 117 # 清空数据 118 mysql -h127.0.0.1 -P3306 -u${{ env.MYSQL_DB_USER }} -p"${{ env.MYSQL_DB_PWD }}" -e "DROP DATABASE IF EXISTS polaris_server"; 119 # 初始化 polaris 数据库 120 mysql -h127.0.0.1 -P3306 -u${{ env.MYSQL_DB_USER }} -p"${{ env.MYSQL_DB_PWD }}" < store/mysql/scripts/polaris_server.sql 121 # 临时放开 DB 的最大连接数 122 mysql -h127.0.0.1 -P3306 -u${{ env.MYSQL_DB_USER }} -p"${{ env.MYSQL_DB_PWD }}" -e "set GLOBAL max_connections = 3000;" 123 124 work_dir=$(ls | grep polaris-server-release | sed -n '1p') 125 echo "work_dir is $work_dir" 126 127 cp -rf ./test/data/polaris-server.yaml $work_dir/ 128 129 cd $work_dir 130 131 ls -alR 132 133 if [[ "$(uname)" == "Darwin" ]]; then 134 # Mac OS X 操作系统 135 echo "Run on MacOS" 136 # sed -i '' 's/consoleOpen: true/consoleOpen: false/g' conf/polaris-server.yaml 137 else 138 # GNU/Linux操作系统 139 echo "Run on Linux" 140 # sed -i 's/consoleOpen: \(true\|false\)/consoleOpen: false/g' conf/polaris-server.yaml 141 fi 142 143 chmod +x ./tool/*.sh 144 ./tool/start.sh 145 146 sleep 120s 147 ls -alR 148 cat ./log/stdout 2>&1 149 150 cd .. 151 ls -lstrh 152 # 先测试普通的集成测试 153 pushd ./test/integrate 154 echo "[INTEGRATION TEST] begin" 155 curl http://127.0.0.1:8090 156 go test -count=1 -v -tags integration -timeout 60m 157 echo "[INTEGRATION TEST] end" 158 popd 159 cd $work_dir 160 ./tool/stop.sh 161 cd ..