Skip to content

chore: test cloud on k3s #9

chore: test cloud on k3s

chore: test cloud on k3s #9

Workflow file for this run

name: Test ApeCoud K3S
on:
push:
workflow_call:
inputs:
release-version:
description: 'apecloud release version'
type: string
required: false
default: 'latest'
kubeblocks-version:
description: 'kubeblocks release version'
type: string
required: false
default: 'latest'
test-type:
description: 'test type'
type: string
required: false
default: '0'
test-type-name:
description: 'test type name'
type: string
required: false
default: 'install'
test-args:
description: 'test args'
type: string
required: false
default: ''
k3s-version:
description: 'k3s cluster version (e.g. 1.26)'
type: string
required: false
default: '1.26'
testinfra-branch:
description: 'testinfra branch name'
type: string
required: false
default: 'main'
apecloud-branch:
description: 'apecloud branch name'
type: string
required: false
default: 'main'
e2etest-branch:
description: 'e2etest branch name'
type: string
required: false
default: 'main'
outputs:
test-result:
description: "test result"
value: "${{ jobs.kbcli-test-k3s.outputs.test-result }}"
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
CLOUD_CN_ENV: ${{ secrets.CLOUD_CN_ENV }}
AUTH0_ID_TOKEN: ${{ secrets.AUTH0_ID_TOKEN }}
HELM_VERSION: v3.13.1
GO_VERSION: '1.19'
K3D_NAME: default
REGION: us-central1
permissions:
id-token: write
contents: read
jobs:
apecloud-test-k3s:
name: test ${{ inputs.test-type-name }}
runs-on: ubuntu-latest
outputs:
kubeblocks-result: ${{ steps.install_kubeblocks.outputs.kubeblocks-result }}
postgresql-result: ${{ steps.create_postgresql.outputs.postgresql-result }}
steps:
- name: Setup Go
if: inputs.GO_VERSION
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Setup kubectl
uses: azure/setup-kubectl@v3
with:
version: "v1.28.3"
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: ${{ env.HELM_VERSION }}
- name: checkout testinfra
uses: actions/checkout@v4
with:
repository: apecloud/testinfra
# ref: ${{ inputs.testinfra-branch }}
ref: main
path: testinfra
token: ${{ env.GITHUB_TOKEN }}
- name: setup k3d k3s
uses: apecloud/setup-k3d-k3s@v1
with:
k3d-name: "${{ env.K3D_NAME }}"
# version: "v${{ inputs.k3s-version }}"
version: "v1.26"
github-token: ${{ env.GITHUB_TOKEN }}
k3d-args: --no-lb --k3s-node-label topology.hostpath.csi/node=k3d-${{ env.K3D_NAME }}-server-0@server:0
- name: install kubbelocks
id: install_kubeblocks
run: |
cd testinfra
file_log_kubeblocks="$(date +%Y-%m-%d-%T)".log
touch ${file_log_kubeblocks}
# KB_VERSION=$( bash .github/utils/get_kb_latest_version.sh "${{ inputs.kubeblocks-version }}" )
KB_VERSION=$( bash .github/utils/get_kb_latest_version.sh "0.7.0" )
echo KUBEBLOCKS_VERSION=${KB_VERSION} >> $GITHUB_ENV
bash .github/utils/kbcli-test.sh \
--type "0" \
--kubeblocks-version "${KB_VERSION}" \
--cloud-provider "k3s" \
--args "--check-addon false --namespace kubeblocks-cloud --random-namespace false --upgrade true ${{ inputs.test-args }} " \
--region "${{ env.REGION }}" | tee -a ${file_log_kubeblocks}
test_ret="$( grep "【FAILED】" ${file_log_kubeblocks} || true )"
if [[ -n "$test_ret" ]]; then
echo kubeblocks-result=[FAILED] >> $GITHUB_OUTPUT
exit 1
else
echo kubeblocks-result=[PASSED] >> $GITHUB_OUTPUT
fi
- name: create postgresql
id: create_postgresql
run: |
cd testinfra
file_log_postgresql="$(date +%Y-%m-%d-%T)".log
touch ${file_log_postgresql}
bash .github/utils/kbcli-test.sh \
--type "2" \
--kubeblocks-version "${KUBEBLOCKS_VERSION}" \
--args "--cluster-name apecloud-pg --replicas 1 --limit-cpu 1 --limit-memory 1 --storage 40 --cluster-version postgresql-14.8.0 --namespace kubeblocks-cloud --only-cluster true --test-mode kubeblockscloud ${{ inputs.test-args }} " \
--region "${{ env.REGION }}" | tee -a ${file_log_postgresql}
test_ret="$( grep "【FAILED】" ${file_log_postgresql} || true )"
if [[ -n "$test_ret" ]]; then
echo postgresql-result=[FAILED] >> $GITHUB_OUTPUT
exit 1
else
echo postgresql-result=[PASSED] >> $GITHUB_OUTPUT
fi
echo "port-forward apecloud-pg-postgresql Service"
nohup kubectl port-forward services/apecloud-pg-postgresql -n kubeblocks-cloud 5432:5432 &
- name: Checkout apecloud Code
uses: actions/checkout@v4
with:
repository: apecloud/apecloud
path: apecloud
# ref: ${{ inputs.apecloud-branch }}
ref: main
token: ${{ env.GITHUB_TOKEN }}
- name: run apecloud server
id: run_apecloud_server
run: |
cd apecloud
touch ./cn.env
tee ./cn.env << EOF ${{ env.CLOUD_CN_ENV }} EOF
while IFS='=' read -r name value
do
if [[ ! $name =~ ^\# && -n $name ]]; then
export $name="$value"
fi
done < ./cn.env
echo $DSN
make run
- name: Checkout e2etest Code
uses: actions/checkout@v4
with:
repository: apecloud/e2etest
path: e2etest
# ref: ${{ inputs.e2etest-branch }}
ref: main
token: ${{ env.GITHUB_TOKEN }}
- name: run e2e test
id: run_e2e_test
run: |
cd e2etest
make test-e2e-apecloud