E2E Test engine-test mysql on Env:dev Ref:main #444
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cloud E2E | |
on: | |
workflow_dispatch: | |
inputs: | |
TEST_TYPE: | |
description: "The specify version of GO (e.g. openapi-test|adminapi-test|engine-test)" | |
type: string | |
required: false | |
default: 'engine-test' | |
TEST_ENGINES: | |
description: "The specify version of GO (e.g. mysql)" | |
type: string | |
required: false | |
default: 'mysql' | |
CLOUD_ENV_NAME: | |
description: "The cloud env name of test (e.g. dev) " | |
type: string | |
required: false | |
default: 'dev' | |
CLOUD_BRANCH: | |
description: "The cloud branch name (e.g. main) " | |
type: string | |
required: false | |
default: 'main' | |
K3S_VERSION: | |
description: 'k3s cluster version (e.g. 1.30)' | |
type: string | |
required: false | |
default: '1.30' | |
APECD_REF: | |
description: "The branch name of apecloud-cd" | |
type: string | |
required: false | |
default: 'test_upload_oss' | |
CURRENT_VERSION: | |
description: "The current release version (e.g. v0.30) " | |
type: string | |
required: false | |
default: 'v0.31' | |
TEST_INSTALLER: | |
description: "Test installer (default: true)" | |
type: boolean | |
required: false | |
default: false | |
TEST_E2E: | |
description: "Test e2e (default: false)" | |
type: boolean | |
required: false | |
default: true | |
TEST_REPORT: | |
description: "Test report (default: false)" | |
type: boolean | |
required: false | |
default: true | |
workflow_call: | |
inputs: | |
TEST_TYPE: | |
description: "The specify version of GO (e.g. openapi-test|adminapi-test|engine-test)" | |
type: string | |
required: false | |
default: 'openapi-test' | |
TEST_ENGINES: | |
description: "The specify version of GO (e.g. mysql)" | |
type: string | |
required: false | |
default: 'mysql' | |
CLOUD_ENV_NAME: | |
description: "The cloud env name of test (e.g. dev) " | |
type: string | |
required: false | |
default: 'dev' | |
CLOUD_BRANCH: | |
description: "The cloud branch name (e.g. main) " | |
type: string | |
required: false | |
default: 'main' | |
K3S_VERSION: | |
description: 'k3s cluster version (e.g. 1.30)' | |
type: string | |
required: false | |
default: '1.30' | |
APECD_REF: | |
description: "The branch name of apecloud-cd" | |
type: string | |
required: false | |
default: 'test_upload_oss' | |
CURRENT_VERSION: | |
description: "The current release version (e.g. v0.30) " | |
type: string | |
required: false | |
default: '' | |
TEST_INSTALLER: | |
description: "Test installer (default: true)" | |
type: boolean | |
required: false | |
default: true | |
TEST_E2E: | |
description: "Test e2e (default: false)" | |
type: boolean | |
required: false | |
default: false | |
TEST_REPORT: | |
description: "Test report (default: false)" | |
type: boolean | |
required: false | |
default: false | |
run-name: E2E Test ${{ inputs.TEST_TYPE }} ${{ inputs.TEST_ENGINES }} on Env:${{ inputs.CLOUD_ENV_NAME }} Ref:${{ inputs.CLOUD_BRANCH }} | |
env: | |
ACK_KUBECONFIG_DEV: ${{ secrets.ACK_KUBECONFIG_DEV }} | |
ACK_KUBECONFIG_DEMO: ${{ secrets.ACK_KUBECONFIG_DEMO }} | |
IDC_KUBECONFIG: ${{ secrets.IDC_KUBECONFIG }} | |
IDC_KUBECONFIG_1: ${{ secrets.IDC_KUBECONFIG_1 }} | |
IDC_KUBECONFIG_2: ${{ secrets.IDC_KUBECONFIG_2 }} | |
IDC_KUBECONFIG_4: ${{ secrets.IDC_KUBECONFIG_4 }} | |
ACK_KUBECONFIG_PROD: ${{ secrets.ACK_KUBECONFIG_PROD }} | |
ACK_KUBECONFIG_INTL_PROD: ${{ secrets.ACK_KUBECONFIG_INTL_PROD }} | |
VKE_KUBECONFIG_TEST: ${{ secrets.VKE_KUBECONFIG_TEST }} | |
GITHUB_USER: ${{ secrets.PERSONAL_ACCESS_USER }} | |
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
K3D_NAME: kbcloud | |
CLOUD_LICENSE: ${{ secrets.CLOUD_LICENSE }} | |
DOCKER_REGISTRY_URL: docker.io | |
DOCKER_REGISTRY_USER: ${{ secrets.DOCKER_REGISTRY_USER }} | |
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} | |
OSS_KEY_ID: ${{ secrets.OSS_KEY_ID }} | |
OSS_KEY_SECRET: ${{ secrets.OSS_KEY_SECRET }} | |
OSS_ENDPOINT: "oss-cn-zhangjiakou.aliyuncs.com" | |
OSS_BUCKET: "kubeblocks-oss" | |
PYTHON_VERSION: "3.11" | |
ENGINE_REPORT_FILE_NAME: "TEST_REPORT_CLOUD_API_ENGINE.pdf" | |
jobs: | |
get-test-type: | |
runs-on: ubuntu-latest | |
outputs: | |
test-type: ${{ steps.get_test_type.outputs.test-type }} | |
cloud-branch: ${{ steps.get_test_type.outputs.cloud-branch }} | |
cloud-env-name: ${{ steps.get_test_type.outputs.cloud-env-name }} | |
test-engines: ${{ steps.get_test_type.outputs.test-engines }} | |
test-e2e: ${{ steps.get_test_type.outputs.test-e2e }} | |
test-installer: ${{ steps.get_test_type.outputs.test-installer }} | |
current-version: ${{ steps.get_test_type.outputs.current-version }} | |
steps: | |
- name: Get test type | |
id: get_test_type | |
run: | | |
TEST_TYPES="${{ inputs.TEST_TYPE }}" | |
test_type="" | |
for test_type_tmp in $(echo "${TEST_TYPES}" | sed 's/|/ /g' ); do | |
if [[ -z "${test_type}" ]]; then | |
test_type="{\"test-type\":\"${test_type_tmp}\"}" | |
else | |
test_type="${test_type},{\"test-type\":\"${test_type_tmp}\"}" | |
fi | |
done | |
echo "${test_type}" | |
echo "test-type={\"include\":[${test_type}]}" >> $GITHUB_OUTPUT | |
CLOUD_BRANCH="${{ inputs.CLOUD_BRANCH }}" | |
if [[ -z "$CLOUD_BRANCH" ]]; then | |
CLOUD_BRANCH="main" | |
fi | |
echo cloud-branch="$CLOUD_BRANCH" >> $GITHUB_OUTPUT | |
CLOUD_ENV_NAME="${{ inputs.CLOUD_ENV_NAME }}" | |
if [[ -z "$CLOUD_ENV_NAME" ]]; then | |
CLOUD_ENV_NAME="dev" | |
fi | |
echo cloud-env-name="$CLOUD_ENV_NAME" >> $GITHUB_OUTPUT | |
TEST_ENGINES="${{ inputs.TEST_ENGINES }}" | |
if [[ -z "$TEST_ENGINES" ]]; then | |
TEST_ENGINES="mysql" | |
fi | |
echo test-engines="$TEST_ENGINES" >> $GITHUB_OUTPUT | |
# check test installer | |
TEST_INSTALLER="false" | |
if [[ "${CLOUD_BRANCH}" == "v"*"."*"."* && "${{ inputs.TEST_INSTALLER }}" == "true" ]]; then | |
TEST_INSTALLER="true" | |
fi | |
echo test-installer="$TEST_INSTALLER" >> $GITHUB_OUTPUT | |
# check test e2e | |
TEST_E2E="false" | |
CURRENT_VERSION="${{ inputs.CURRENT_VERSION }}" | |
if [[ -n "${CURRENT_VERSION}" && "${{ inputs.TEST_E2E }}" == "true" ]]; then | |
if [[ "${CURRENT_VERSION}" != "v"* ]]; then | |
CURRENT_VERSION="v${CURRENT_VERSION}" | |
fi | |
echo current-version="$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
TEST_E2E="true" | |
fi | |
echo test-e2e="$TEST_E2E" >> $GITHUB_OUTPUT | |
e2e-test: | |
needs: [ get-test-type ] | |
if: ${{ needs.get-test-type.outputs.test-e2e == 'true' }} | |
name: ${{ matrix.test-type }}-${{ needs.get-test-type.outputs.cloud-env-name }} | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJSON(needs.get-test-type.outputs.test-type) }} | |
outputs: | |
openapi-test-result: ${{ steps.get_test_result.outputs.openapi-test-result }} | |
adminapi-test-result: ${{ steps.get_test_result.outputs.adminapi-test-result }} | |
engine-test-result: ${{ steps.get_test_result.outputs.engine-test-result }} | |
test-result: ${{ steps.get_test_result.outputs.test-result }} | |
openapi-summary: ${{ steps.get_test_result.outputs.openapi-summary }} | |
adminapi-summary: ${{ steps.get_test_result.outputs.adminapi-summary }} | |
engine-summary: ${{ steps.get_test_result.outputs.engine-summary }} | |
api-summary: ${{ steps.get_test_result.outputs.api-summary }} | |
test-date: ${{ steps.upload_test_result.outputs.test-date }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout testinfra Code | |
uses: actions/checkout@v4 | |
with: | |
repository: apecloud/testinfra | |
path: ./ | |
token: ${{ env.GH_TOKEN }} | |
- name: Checkout apecloud-cd Code | |
uses: actions/checkout@v4 | |
with: | |
repository: apecloud/apecloud-cd | |
path: ./apecloud-cd | |
ref: ${{ inputs.APECD_REF }} | |
- name: Checkout apecloud Code | |
uses: actions/checkout@v4 | |
with: | |
repository: apecloud/apecloud | |
path: ./apecloud | |
token: ${{ env.GH_TOKEN }} | |
ref: "${{ needs.get-test-type.outputs.cloud-branch }}" | |
fetch-depth: 0 | |
- name: Checkout pystan2 Code | |
uses: actions/checkout@v4 | |
if: ${{ always() && matrix.test-type == 'engine-test' && inputs.TEST_REPORT }} | |
with: | |
submodules: 'recursive' | |
repository: stan-dev/pystan2 | |
ref: "v2.19.1.1" | |
path: pystan2 | |
- name: install python dateutil | |
run: | | |
pip3 install python-dateutil | |
- name: Get Test Result | |
if: ${{ always() }} | |
id: get_test_result | |
run: | | |
file_log="test_result.log" | |
test_file_log_path="${{ github.workspace }}/apecloud-cd/.github/utils/${file_log}" | |
cat ${test_file_log_path} | |
TEST_TYPE="${{ matrix.test-type }}" | |
if [[ -z "$TEST_TYPE" ]]; then | |
TEST_TYPE="openapi-test" | |
fi | |
test_ret="$( grep "Test Suite Failed" ${test_file_log_path} || true )" | |
TEST_RESULT_ALL="$(cat ${test_file_log_path} | (egrep 'SUCCESS!|FAIL!' | grep -- '--' || true))" | |
echo "test result all:${TEST_RESULT_ALL}" | |
TEST_RESULT_ALL=$(python3 ${{ github.workspace }}/apecloud-cd/.github/utils/remove_ansi.py --ansi-str "$TEST_RESULT_ALL") | |
test_result=$(bash ${{ github.workspace }}/apecloud-cd/.github/utils/utils.sh --type 41 --test-result "${TEST_RESULT_ALL}") | |
echo "test result total:${test_result}" | |
if [[ -z "$test_result" ]]; then | |
test_result="$(cat ${test_file_log_path} | (egrep 'SUCCESS!|FAIL!' | grep -- '--' || true) | tail -n 1)" | |
test_result=$(python3 ${{ github.workspace }}/apecloud-cd/.github/utils/remove_ansi.py --ansi-str "$test_result") | |
fi | |
if [[ -z "$test_result" ]]; then | |
test_result="[PASSED]" | |
if [[ -n "$test_ret" || -z "${TEST_RESULT_ALL}" ]]; then | |
test_result="[FAILED]" | |
fi | |
fi | |
coverage_file_log="test_api_coverage_result.log" | |
coverage_file_log_path="${{ github.workspace }}/${coverage_file_log}" | |
touch ${coverage_file_log_path} | |
API_COVERAGE_SUMMARY="" | |
CLOUD_E2E_HACK_DIR="${{ github.workspace }}/apecloud/e2e/hack" | |
if [[ ("${{ inputs.TEST_REPORT }}" == "true" || "${{ needs.get-test-type.outputs.cloud-branch }}" == "main") && "${TEST_TYPE}" == "engine-test" ]]; then | |
API_COVERAGE_SUMMARY=$(python3 test/report/parse_ginkgo.py summary ${test_file_log_path}) | |
echo ${API_COVERAGE_SUMMARY} | |
engine_file_log="test_engine_api_result.txt" | |
ENGINE_TEST_RESULT=$(python3 test/report/parse_ginkgo.py engine ${test_file_log_path}) | |
echo "${ENGINE_TEST_RESULT}" | |
engine_file_log_path="${{ github.workspace }}/${engine_file_log}" | |
touch ${engine_file_log_path} | |
echo "${ENGINE_TEST_RESULT}" > ${engine_file_log_path} | |
cat ${engine_file_log_path} | |
echo "=======================" | |
du -sh ${engine_file_log_path} | |
echo "=======================" | |
elif [[ -d "${CLOUD_E2E_HACK_DIR}" && ("${{ inputs.TEST_REPORT }}" == "true" || "${{ needs.get-test-type.outputs.cloud-branch }}" == "main") ]]; then | |
cd ${CLOUD_E2E_HACK_DIR} | |
if [[ -f "${CLOUD_E2E_HACK_DIR}/api-coverage.sh" ]]; then | |
# api coverage summary | |
API_TYPE="openapi" | |
if [[ -n "$TEST_TYPE" && "$TEST_TYPE" == "adminapi"* ]]; then | |
API_TYPE="adminapi" | |
fi | |
bash ./api-coverage.sh --type ${API_TYPE} --log ${test_file_log_path} > ${coverage_file_log_path} | |
API_COVERAGE_SUMMARY=$(cat ${coverage_file_log_path}) | |
TOTAL_APIS=$(echo "${API_COVERAGE_SUMMARY}" | grep "Total APIs: ") | |
COVERED_APIS=$(echo "${API_COVERAGE_SUMMARY}" | grep "Covered APIs: ") | |
COVERAGE=$(echo "${API_COVERAGE_SUMMARY}" | grep "Coverage: ") | |
DEPRECATED_APIS=$(echo "${API_COVERAGE_SUMMARY}" | grep "Deprecated APIs: ") | |
TOTAL_APIS=$(echo "$TOTAL_APIS" | grep -oE '[0-9]+') | |
COVERED_APIS=$(echo "$COVERED_APIS" | grep -oE '[0-9]+') | |
COVERAGE=$(echo "$COVERAGE" | grep -oE '[0-9]+%') | |
DEPRECATED_APIS=$(echo "$DEPRECATED_APIS" | grep -oE '[0-9]+') | |
echo "Total APIs: $TOTAL_APIS" | |
echo "Covered APIs: $COVERED_APIS" | |
echo "Coverage: $COVERAGE" | |
echo "Deprecated APIs: $DEPRECATED_APIS" | |
API_COVERAGE_SUMMARY="${TOTAL_APIS}|${COVERED_APIS}|${COVERAGE}|${DEPRECATED_APIS}" | |
fi | |
fi | |
case "$TEST_TYPE" in | |
openapi-test) | |
echo openapi-test-result="${test_result}" >> $GITHUB_OUTPUT | |
echo openapi-summary="${API_COVERAGE_SUMMARY}" >> $GITHUB_OUTPUT | |
if [[ -d "${CLOUD_E2E_HACK_DIR}" ]]; then | |
check_e2e_log="e2e.log" | |
check_e2e_log_path="${CLOUD_E2E_HACK_DIR}/${check_e2e_log}" | |
touch ${check_e2e_log_path} | |
cp -r ${test_file_log_path} ${check_e2e_log_path} | |
echo "=======================" | |
du -sh ${check_e2e_log_path} | |
echo "=======================" | |
cat ${check_e2e_log_path} | |
fi | |
;; | |
adminapi-test) | |
echo adminapi-test-result="${test_result}" >> $GITHUB_OUTPUT | |
echo adminapi-summary="${API_COVERAGE_SUMMARY}" >> $GITHUB_OUTPUT | |
;; | |
engine-test) | |
echo engine-test-result="${test_result}" >> $GITHUB_OUTPUT | |
echo engine-summary="${API_COVERAGE_SUMMARY}" >> $GITHUB_OUTPUT | |
if [[ -d "${CLOUD_E2E_HACK_DIR}" ]]; then | |
check_e2e_log="e2e.log" | |
check_e2e_log_path="${CLOUD_E2E_HACK_DIR}/${check_e2e_log}" | |
touch ${check_e2e_log_path} | |
cp -r ${test_file_log_path} ${check_e2e_log_path} | |
echo "=======================" | |
du -sh ${check_e2e_log_path} | |
echo "=======================" | |
fi | |
;; | |
*) | |
echo test-result="${test_result}" >> $GITHUB_OUTPUT | |
echo api-summary="${API_COVERAGE_SUMMARY}" >> $GITHUB_OUTPUT | |
;; | |
esac | |
if [[ -n "$test_ret" ]]; then | |
exit 1 | |
fi | |
- name: Get ${{ matrix.test-type }} API Coverage List | |
if: ${{ always() && matrix.test-type == 'engine-test' }} | |
run: | | |
coverage_file_log="test_api_coverage_result.log" | |
coverage_file_log_path="${{ github.workspace }}/${coverage_file_log}" | |
if [[ -f ${coverage_file_log_path} ]]; then | |
cat ${coverage_file_log_path} | |
fi | |
- name: Check e2e log and create issue | |
if: ${{ always() && matrix.test-type == 'engine-test' }} | |
run: | | |
CLOUD_E2E_HACK_DIR="${{ github.workspace }}/apecloud/e2e/hack" | |
if [[ -d "${CLOUD_E2E_HACK_DIR}" && -f "${CLOUD_E2E_HACK_DIR}/log-checker.sh" ]]; then | |
CI_JOB_URL=$(bash ${{ github.workspace }}/apecloud-cd/.github/utils/utils.sh \ | |
--type 44 \ | |
--github-repo "${{ github.repository }}" \ | |
--github-token "${{ env.GH_TOKEN }}" \ | |
--run-id "$GITHUB_RUN_ID" \ | |
--test-result "openapi-test-dev") | |
echo ${CI_JOB_URL} | |
export CI_JOB_URL="${CI_JOB_URL}" | |
cd ${CLOUD_E2E_HACK_DIR} | |
ls -ll | |
bash ./log-checker.sh | |
check_e2e_log="e2e.log" | |
check_e2e_log_path="${CLOUD_E2E_HACK_DIR}/${check_e2e_log}" | |
cat ${check_e2e_log_path} | |
fi | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
if: ${{ always() && matrix.test-type == 'engine-test' && inputs.TEST_REPORT }} | |
with: | |
python-version: "${{ env.PYTHON_VERSION }}" | |
- name: install gen report env | |
if: ${{ always() && matrix.test-type == 'engine-test' && inputs.TEST_REPORT }} | |
run: | | |
# locale gen zh_CN.UTF-8 | |
sudo locale-gen zh_CN.UTF-8 | |
sudo update-locale | |
locale -a | |
# install wkhtmltopdf | |
sudo rm /etc/apt/sources.list.d/microsoft-prod.list | |
sudo apt-get update | |
sudo apt-get install -y --no-install-recommends wkhtmltopdf fonts-wqy-zenhei fonts-wqy-microhei | |
# install Cython and NumPy | |
pip3 install Cython==3.0.9 NumPy==1.24.3 | |
# install pystan 2.19.1.1 | |
cd pystan2 | |
python3 setup.py install | |
# install python requirements | |
cd ${{ github.workspace }}/test/report | |
sed -i 's/^appscript==.*/#appscript==/' requirements.txt | |
pip3 install -r requirements.txt | |
- name: Setup ossutil | |
uses: manyuanrong/[email protected] | |
if: ${{ always() && matrix.test-type == 'engine-test' && inputs.TEST_REPORT }} | |
with: | |
access-key-id: "${{ env.OSS_KEY_ID }}" | |
access-key-secret: "${{ env.OSS_KEY_SECRET }}" | |
endpoint: "${{ env.OSS_ENDPOINT }}" | |
- name: Upload engine report to oss | |
if: ${{ always() && matrix.test-type == 'engine-test' && inputs.TEST_REPORT }} | |
id: upload_test_result | |
run: | | |
engine_file_log="test_engine_api_result.txt" | |
engine_file_log_path="${{ github.workspace }}/${engine_file_log}" | |
cat ${engine_file_log_path} | |
ENGINE_REPORT_FILE_NAME="${{ env.ENGINE_REPORT_FILE_NAME }}" | |
cd test/report | |
bash update_test_period.sh ./md | |
mkdir -p reports/cn | |
for i in $(seq 1 3); do | |
python3 ./report.py \ | |
--type=engine \ | |
--raw=${engine_file_log_path} \ | |
--main_report=${ENGINE_REPORT_FILE_NAME} | |
gen_ret=$? | |
if [[ $gen_ret -eq 0 ]]; then | |
break | |
fi | |
sleep 1 | |
done | |
export TZ='Asia/Shanghai' | |
TEST_DATE="$(date +%Y%m%d)" | |
echo test-date=${TEST_DATE} >> $GITHUB_OUTPUT | |
APECLOUD_CURRENT_VERSION="${{ needs.get-test-type.outputs.current-version }}" | |
OSS_DIR="oss://${{ env.OSS_BUCKET }}/reports/apecloud/${APECLOUD_CURRENT_VERSION}/${TEST_DATE}" | |
upload_file_name="${{ github.workspace }}/test/report/reports/cn/${ENGINE_REPORT_FILE_NAME}" | |
if [[ ! -f "${upload_file_name}" ]]; then | |
echo "$(tput -T xterm setaf 3)::warning title=not found upload file$(tput -T xterm sgr0)" | |
exit 1 | |
fi | |
for i in $(seq 1 3); do | |
ossutil cp -rf "${upload_file_name}" "${OSS_DIR}/${ENGINE_REPORT_FILE_NAME}" | |
upload_ret=$? | |
if [[ $upload_ret -eq 0 ]]; then | |
echo "$(tput -T xterm setaf 2)upload ${ENGINE_REPORT_FILE_NAME} to oss successfully$(tput -T xterm sgr0)" | |
break | |
else | |
echo "$(tput -T xterm setaf 3)::warning title=upload ${ENGINE_REPORT_FILE_NAME} to oss failure$(tput -T xterm sgr0)" | |
fi | |
sleep 1 | |
done | |