-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
211 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,211 @@ | ||
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: '0' | ||
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' | ||
e2etest-branch: | ||
description: 'e2etest branch name' | ||
type: string | ||
required: false | ||
default: 'main' | ||
apecloud-branch: | ||
description: 'apecloud branch name' | ||
type: string | ||
required: false | ||
default: 'main' | ||
outputs: | ||
deploy-result: | ||
description: "deploy result" | ||
value: ${{ jobs.cloud-test-k3s.outputs.deploy-result }} | ||
test-result: | ||
description: "e2e test result" | ||
value: "${{ jobs.cloud-test-k3s.outputs.test-result }}" | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
HELM_VERSION: v3.13.1 | ||
K3D_NAME: default | ||
REGION: us-central1 | ||
AUTH0_ID_TOKEN: ${{ secrets.AUTH0_ID_TOKEN }} | ||
DSN: "postgres://kubeblockscloud:kubeblockscloudhk2143232@localhost:5432/kubeblockscloud?sslmode=disable" | ||
CLOUD_CN_ENV: ${{ secrets.CLOUD_CN_ENV }} | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
cloud-test-k3s: | ||
name: run ${{ inputs.test-type-name }} | ||
runs-on: ubuntu-latest | ||
outputs: | ||
deploy-result: ${{ steps.deploy_cloud.outputs.deploy-result }} | ||
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.21" | ||
|
||
- 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 "--config-s3 true --enable-csi-hostpath-driver false --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 | ||
while IFS='=' read -r name value; do | ||
if [[ ! $name =~ ^\# && -n $name ]]; then | ||
export $name="$value" | ||
fi | ||
done < ./cn.env | ||
echo $DSN | ||
nohup make run > ./make_run.log 2>&1 & | ||
times=1 | ||
while true; do | ||
if [[ $times -gt 300 ]]; 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 | ||
cat ./make_run.log | ||
- 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: curl cloud server api | ||
run: | | ||
curl -X GET "http://127.0.0.1:8080/api/v1/user" -H "accept: application/json" -H "authorization:Bearer ${AUTH0_ID_TOKEN}" | ||
- 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 |