Skip to content

Commit

Permalink
chore: cloud test on k3d
Browse files Browse the repository at this point in the history
  • Loading branch information
JashBook committed Nov 8, 2024
1 parent 64647df commit f22294a
Show file tree
Hide file tree
Showing 2 changed files with 235 additions and 0 deletions.
126 changes: 126 additions & 0 deletions .github/workflows/cloud-test-k3d.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Cloud E2E Test on K3D

on:
workflow_call:
inputs:
APECLOUD_VERSION:
description: 'ApeCloud release version'
type: string
required: false
default: 'v0.3.5'
KUBEBLOCKS_VERSION:
description: 'kubeblocks release version'
type: string
required: false
default: 'latest'
K3S_VERSION:
description: 'k8s cluster version (e.g. 1.28)'
type: string
required: false
default: '1.28'
E2ETEST_BRANCH:
description: 'e2etest branch name'
type: string
required: false
default: 'main'
APECD_REF:
description: "The branch name of apecloud-cd"
type: string
required: false
default: 'main'
ARGS:
description: "Test args"
type: string
required: false
default: ''
workflow_dispatch:
inputs:
TEST_TYPE:
description: 'test type (e.g. wesql|postgresql|redis|mongodb)'
type: string
required: false
default: ''
APECLOUD_VERSION:
description: 'ApeCloud release version'
type: string
required: false
default: 'v0.3.5'
KUBEBLOCKS_VERSION:
description: 'kubeblocks release version'
type: string
required: false
default: 'latest'
K3S_VERSION:
description: 'k8s cluster version (e.g. 1.28)'
type: string
required: false
default: '1.28'
E2ETEST_BRANCH:
description: 'e2etest branch name'
type: string
required: false
default: 'main'
APECD_REF:
description: "The branch name of apecloud-cd"
type: string
required: false
default: 'main'
ARGS:
description: "Test args"
type: string
required: false
default: ''

run-name: ApeCloud:${{ inputs.APECLOUD_VERSION }} K3S:${{ inputs.K3S_VERSION }}

env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

permissions:
id-token: write
contents: read

jobs:
e2e-test:
uses: ./.github/workflows/test-cloud-k3d.yml
with:
release-version: ${{ inputs.APECLOUD_VERSION }}
kubeblocks-version: ${{ inputs.KUBEBLOCKS_VERSION }}
test-type: ${{ inputs.TEST_TYPE }}
test-type-name: "e2e-test"
test-args: ${{ inputs.ARGS }}
k3s-version: ${{ inputs.K3S_VERSION }}
e2etest-branch: ${{ inputs.E2ETEST_BRANCH }}
secrets: inherit

send-message:
if: ${{ always() }}
runs-on: ubuntu-latest
needs: [ e2e-test ]
steps:
- uses: actions/checkout@v4
with:
repository: apecloud/apecloud-cd
path: ./
ref: ${{ inputs.APECD_REF }}

- name: send message
id: get_trigger_mode
run: |
TEST_RESULT="deploy-cloud|${{ needs.e2e-test.outputs.deploy-result }}"
echo "$TEST_RESULT"
TEST_RESULT="${TEST_RESULT}##${{ needs.e2e-test.outputs.test-type }}|${{ needs.e2e-test.outputs.test-result }}"
echo "$TEST_RESULT"
TEST_RESULT=$( bash .github/utils/utils.sh --type 12 \
--github-repo "${{ github.repository }}" \
--github-token "${{ env.GITHUB_TOKEN }}" \
--test-result "${TEST_RESULT}" \
--run-id "$GITHUB_RUN_ID" )
date_ret=$(date +%Y-%m-%d-%T)
test_title="[${{ inputs.APECLOUD_VERSION }}] Test ApeCloud on K3S:${{ inputs.K3S_VERSION }} [${date_ret}]"
python3 .github/utils/send_mesage.py \
--url "${{ vars.TEST_BOT_WEBHOOK }}" \
--title "$test_title" \
--result "$TEST_RESULT"
109 changes: 109 additions & 0 deletions .github/workflows/test-cloud-k3d.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Test Cloud On K3D

on:
push:
workflow_dispatch:
inputs:
cloud-version:
description: 'kubeblocks cloud version (e.g. 0.28.50)'
type: string
required: false
default: '0.28.50'
k3s-version:
description: 'k3s cluster version (e.g. 1.30)'
type: string
required: false
default: '1.30'
workflow_call:
inputs:
cloud-version:
description: 'kubeblocks cloud version (e.g. 0.28.50)'
type: string
required: false
default: '0.28.50'
k3s-version:
description: 'k3s cluster version (e.g. 1.30)'
type: string
required: false
default: '1.30'
outputs:
test-result:
description: "e2e test result"
value: "${{ jobs.cloud-test-k3d.outputs.test-result }}"


env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
K3D_NAME: kbcloud

permissions:
id-token: write
contents: read

jobs:
cloud-test-k3d:
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 }}
test-type: ${{ steps.test_result.outputs.test-type }}
steps:
- name: Setup kubectl
uses: azure/setup-kubectl@v3
with:
version: "v1.30.4"

- name: Install Helm
uses: azure/setup-helm@v3
with:
version: "v3.15.4"

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: "1.22"

- name: setup k3d k3s
uses: nolar/setup-k3d-k3s@v1
with:
k3d-name: "${{ env.K3D_NAME }}"
version: "v1.30"
# version: "v${{ inputs.k3s-version }}"
github-token: ${{ env.GITHUB_TOKEN }}
k3d-args: -p 443:443@loadbalancer -p 80:80@loadbalancer --agents 2

- name: install cert-manager
run: |
helm repo add jetstack https://charts.jetstack.io --force-update
helm install \
cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--version v1.16.0 \
--set crds.enabled=true
- name: install kubeblocks cloud
run: |
helm repo add kb-chart https://apecloud.github.io/helm-charts
helm install installer kb-chart/kb-cloud-installer \
#--version ${{ inputs.k3s-version }} --set version=${{ inputs.k3s-version }} \
--version 0.28.50 --set version=0.28.50 \
--set kubernetesProvider=k3d \
--set fqdn.domain=mytest.kubeblocks.com \
--set tls.enabled=true
- name: check kubeblocks cloud
run: |
for i in {1..60}; do
if kubectl get pods -n kb-cloud | grep Running ; then
kubectl get pods -n kb-cloud | grep Running
echo "KubeBlocks Cloud is ready"
break
fi
echo "Waiting for KubeBlocks Cloud to be ready..."
sleep 2
done

0 comments on commit f22294a

Please sign in to comment.