-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "temporarily disable create test"
This reverts commit 51eeb2f.
- Loading branch information
1 parent
51eeb2f
commit 797966c
Showing
1 changed file
with
121 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,121 @@ | ||
name: Serverless Create Test | ||
|
||
on: | ||
schedule: | ||
- cron: "0/30 * * * *" # every 30 minutes | ||
workflow_dispatch: | ||
|
||
jobs: | ||
setup: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up ticloud | ||
uses: tidbcloud/setup-tidbcloud-cli@v0 | ||
with: | ||
api_public_key: ${{ secrets.CREATE_TEST_PUBLIC_KEY }} | ||
api_private_key: ${{ secrets.CREATE_TEST_PRIVATE_KEY }} | ||
|
||
- name: Delete all serverless | ||
run: | | ||
# delete all serverless | ||
set +e | ||
ticloud cluster list 1372813089447741295 -o json > cluster | ||
exitcode="$?" | ||
if [[ "$exitcode" != "0" ]]; then | ||
cat cluster | ||
exit "$exitcode" | ||
fi | ||
total=$(jq '.total' cluster); | ||
for i in $(seq 1 $total); | ||
do | ||
id=`echo $(jq ".items[$i-1].id" cluster) | sed 's/"//g'` | ||
ticloud cluster delete -p 1372813089447741295 -c $id --force; | ||
exitcode="$?" | ||
if [[ "$exitcode" != "0" ]]; then | ||
exit "$exitcode" | ||
fi | ||
done | ||
create-test: | ||
needs: setup | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
region: [ us-east-1, us-west-2, ap-northeast-1, ap-southeast-1, eu-central-1 ] | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up ticloud | ||
uses: tidbcloud/setup-tidbcloud-cli@v0 | ||
with: | ||
api_public_key: ${{ secrets.CREATE_TEST_PUBLIC_KEY}} | ||
api_private_key: ${{ secrets.CREATE_TEST_PRIVATE_KEY }} | ||
|
||
- name: Create cluster | ||
run: | | ||
set +e | ||
PROJECT_ID=1372813089447741295 | ||
result=`ticloud cluster create -p $PROJECT_ID --cluster-name ${{ matrix.region }} --cloud-provider AWS -r ${{ matrix.region }} --root-password ${{ secrets.TIDB_CLOUD_PASSWORD }} --cluster-type SERVERLESS` | ||
exitcode="$?" | ||
if [[ "$exitcode" != "0" ]]; then | ||
echo $result | ||
exit "$exitcode" | ||
fi | ||
echo $result | ||
id=`echo $result | sed 's/[^0-9]//g'` | ||
ticloud cluster get -p $PROJECT_ID -c $id > ${{ matrix.region }} | ||
exitcode="$?" | ||
if [[ "$exitcode" != "0" ]]; then | ||
cat ${{ matrix.region }} | ||
exit "$exitcode" | ||
fi | ||
cat ${{ matrix.region }} | ||
echo "PROJECT_ID=$PROJECT_ID" >> $GITHUB_ENV | ||
echo "CLUSTER_ID=`echo $(jq '.id' ${{ matrix.region }}) | sed 's/"//g'`" >> $GITHUB_ENV | ||
echo "CLUSTER_USER=$(jq '.status.connection_strings.default_user' ${{ matrix.region }})" >> $GITHUB_ENV | ||
echo "CLUSTER_HOST=$(jq '.status.connection_strings.standard.host' ${{ matrix.region }})" >> $GITHUB_ENV | ||
- name: Create branch | ||
run: | | ||
set +e | ||
result=`ticloud branch create -c ${{ env.CLUSTER_ID }} --branch-name ${{ matrix.region }}` | ||
exitcode="$?" | ||
if [[ "$exitcode" != "0" ]]; then | ||
echo $result | ||
exit "$exitcode" | ||
fi | ||
echo $result | ||
id=`echo $result | grep -o 'bran-[a-zA-Z0-9]*'` | ||
ticloud branch get -c ${{ env.CLUSTER_ID }} -b $id > ${{ matrix.region }} | ||
exitcode="$?" | ||
if [[ "$exitcode" != "0" ]]; then | ||
cat ${{ matrix.region }} | ||
exit "$exitcode" | ||
fi | ||
cat ${{ matrix.region }} | ||
echo "BRANCH_ID=`echo $(jq '.id' ${{ matrix.region }}) | sed 's/"//g'`" >> $GITHUB_ENV | ||
echo "BRANCH_USER=$(jq '.user_prefix' ${{ matrix.region }})".root"" >> $GITHUB_ENV | ||
echo "BRANCH_HOST=$(jq '.endpoints.public_endpoint.host' ${{ matrix.region }})" >> $GITHUB_ENV | ||
- name: Setup mysql | ||
uses: shogo82148/actions-setup-mysql@v1 | ||
|
||
- name: Run test | ||
run: | | ||
mysql -u ${{ env.CLUSTER_USER }} -h ${{ env.CLUSTER_HOST }} -P 4000 -D test --ssl-mode=VERIFY_IDENTITY --ssl-ca=/etc/ssl/certs/ca-certificates.crt -p${{ secrets.TIDB_CLOUD_PASSWORD }} | ||
- name: Delete cluster & branch | ||
run: | | ||
ticloud branch delete -c ${{ env.CLUSTER_ID }} -b ${{ env.BRANCH_ID }} --force | ||
ticloud cluster delete -p ${{ env.PROJECT_ID }} -c ${{ env.CLUSTER_ID }} --force |