chore: adjust run cloud server #31
Workflow file for this run
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: Test Cloud On K3S | ||
on: | ||
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: '' | ||
test-type-name: | ||
description: 'test type name' | ||
type: string | ||
required: false | ||
default: '' | ||
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: "e2e test result" | ||
value: "${{ jobs.cloud-test-k3s.outputs.test-result }}" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
CLOUD_CN_ENV: ${{ secrets.CLOUD_CN_ENV }} | ||
HELM_VERSION: v3.13.1 | ||
K3D_NAME: default | ||
REGION: us-central1 | ||
permissions: | ||
id-token: write | ||
contents: read | ||
jobs: | ||
cloud-test-k3s: | ||
name: run ${{ inputs.test-type-name }} | ||
runs-on: ubuntu-latest | ||
outputs: | ||
test-result: ${{ steps.test_result.outputs.test-result }} | ||
steps: | ||
- 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: Setup Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: "1.19" | ||
- name: checkout testinfra | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: apecloud/testinfra | ||
ref: ${{ inputs.testinfra-branch }} | ||
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 }}" | ||
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 | ||
run: | | ||
echo E2E_TEST_RESULT=0 >> $GITHUB_ENV | ||
cd testinfra | ||
KB_VERSION=$( bash .github/utils/get_kb_latest_version.sh "${{ inputs.kubeblocks-version }}" ) | ||
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 }}" | ||
- name: create postgresql | ||
run: | | ||
cd testinfra | ||
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 }}" | ||
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 }} | ||
token: ${{ env.GITHUB_TOKEN }} | ||
- name: run cloud server | ||
run: | | ||
cd apecloud/apiserver | ||
go mod tidy | ||
touch ./cn.env | ||
echo "${{ env.CLOUD_CN_ENV }}" > ./cn.env | ||
cat << EOF > run.sh | ||
#!/bin/bash | ||
while IFS='=' read -r name value | ||
do | ||
if [[ ! $name =~ ^\# && -n $name ]]; then | ||
export $name=$value | ||
fi | ||
done < ./cn.env | ||
echo "DSN:"$DSN | ||
nohup make run > ./make_run.log 2>&1 & | ||
EOF | ||
chmod +x run.sh | ||
./run.sh | ||
times=1 | ||
while true; do | ||
if [[ $times -gt 600 ]]; then | ||
break | ||
fi | ||
run_ret="$( grep "Listen and Server on 0.0.0.0:8080" ./make_run.log || true )" | ||
if [[ -n "$run_ret" ]]; then | ||
echo "run cloud server success" | ||
break | ||
fi | ||
times=$(( $times + 1 )) | ||
sleep 1 | ||
echo "checking cloud server..." | ||
done | ||
- name: initial postgresql configuration | ||
run: | | ||
cd testinfra | ||
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 apecloud ${{ inputs.test-args }} " \ | ||
--region "${{ env.REGION }}" | ||
- name: Setup Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: "1.21" | ||
- name: Checkout e2etest Code | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: apecloud/e2etest | ||
path: e2etest | ||
ref: ${{ inputs.e2etest-branch }} | ||
token: ${{ env.GITHUB_TOKEN }} | ||
- name: run e2e test | ||
id: run_e2e_test | ||
run: | | ||
cd e2etest | ||
make test-e2e-apecloud | ||
echo E2E_TEST_RESULT=1 >> $GITHUB_ENV | ||
- name: return cloud e2e test result | ||
id: test_result | ||
if: ${{ always() }} | ||
run: | | ||
if [[ "${E2E_TEST_RESULT}" == '1' ]]; then | ||
echo test-result=[PASSED] >> $GITHUB_OUTPUT | ||
else | ||
echo test-result=[FAILED] >> $GITHUB_OUTPUT | ||
fi |