Skip to content

Commit

Permalink
Optimize Create test error output (#29)
Browse files Browse the repository at this point in the history
* test

* test

* test

* test

* test

* test

* test

* test

* test

* test

* use set +e

* use set +e

* use set +e

* use set +e

* use set +e

* use set +e

* use set +e

* use set +e

* use set +e

* use set +e

* use set +e

* use set +e

* use set +e
  • Loading branch information
shiyuhang0 committed Jul 21, 2023
1 parent b85ca63 commit 77e6fb0
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 6 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/compatibility-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,45 @@ jobs:
- name: Get Connection Info
run: |
# delete cluster if exists
set +e
ticloud cluster list 1372813089206721319 -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 1372813089206721319 -c $id --force;
exitcode="$?"
if [[ "$exitcode" != "0" ]]; then
exit "$exitcode"
fi
done
# create cluster
ticloud cluster create --project-id 1372813089206721319 --cluster-name tls-test --cloud-provider AWS -r us-east-1 --root-password ${{ secrets.TIDB_CLOUD_PASSWORD }} --cluster-type SERVERLESS;
exitcode="$?"
if [[ "$exitcode" != "0" ]]; then
exit "$exitcode"
fi
# get connection info
ticloud cluster list 1372813089206721319 -o json > cluster
exitcode="$?"
if [[ "$exitcode" != "0" ]]; then
cat cluster
exit "$exitcode"
fi
cat cluster
echo "TIDB_CLOUD_USER=$(jq '.items[0].status.connection_strings.default_user' cluster)" >> $GITHUB_ENV
echo "TIDB_CLOUD_HOST=$(jq '.items[0].status.connection_strings.standard.host' cluster)" >> $GITHUB_ENV
outputs:
TiDB_CLOUD_USER: ${{ env.TIDB_CLOUD_USER }}
TiDB_CLOUD_HOST: ${{ env.TIDB_CLOUD_HOST }}
Expand Down
49 changes: 43 additions & 6 deletions .github/workflows/create-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,23 @@ jobs:
- 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:
Expand All @@ -49,10 +60,23 @@ jobs:

- name: Create cluster
run: |
set +e
PROJECT_ID=1372813089447741295
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 > ${{ matrix.region }}
cat ${{ matrix.region }}
ticloud cluster get -p $PROJECT_ID -c `cat ${{ matrix.region }} | sed 's/[^0-9]//g'` > ${{ matrix.region }}
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
Expand All @@ -61,9 +85,22 @@ jobs:
- name: Create branch
run: |
ticloud branch create -c ${{ env.CLUSTER_ID }} --branch-name ${{ matrix.region }} > ${{ matrix.region }}
cat ${{ matrix.region }}
ticloud branch get -c ${{ env.CLUSTER_ID }} -b `cat ${{ matrix.region }} | grep -o 'bran-[a-zA-Z0-9]*'` > ${{ matrix.region }}
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
Expand Down

0 comments on commit 77e6fb0

Please sign in to comment.