-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (106 loc) · 4.2 KB
/
create-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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