Skip to content

Commit

Permalink
add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
djshow832 committed Jun 27, 2024
1 parent ad78ca2 commit 078711d
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/integrate-cluster-scale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
- 'test_scale_tools'
- 'test_scale_core_tls'
- 'test_scale_tools_tls'
- 'test_scale_tiproxy'
env:
working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}
steps:
Expand Down
85 changes: 85 additions & 0 deletions tests/tiup-cluster/script/scale_tiproxy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash

set -eu

function scale_tiproxy() {
mkdir -p ~/.tiup/bin/

version=$1
test_tls=$2
native_ssh=$3

client=""
if [ $native_ssh == true ]; then
client="--ssh=system"
fi

name="test_scale_tiproxy_$RANDOM"
if [ $test_tls = true ]; then
topo=./topo/full_tls.yaml
else
topo=./topo/full.yaml
fi

check_cert_file="ls /home/tidb/deploy/tidb-4000/tls/tiproxy-session.crt /home/tidb/deploy/tidb-4000/tls/tiproxy-session.key"
check_cert_config="grep -q session-token-signing-key /home/tidb/deploy/tidb-4000/conf/tidb.toml"

tiup-cluster $client --yes deploy $name $version $topo -i ~/.ssh/id_rsa

# the session certs exist
tiup-cluster $client exec $name -N n1 --command "$check_cert_file"
# the configurations are updated
tiup-cluster $client exec $name -N n1 --command "$check_cert_config"

tiup-cluster $client list | grep "$name"

tiup-cluster $client --yes start $name

tiup-cluster $client _test $name writable

tiup-cluster $client display $name

tiup-cluster $client --yes reload $name --skip-restart

if [ $test_tls = true ]; then
total_sub_one=19
total=20
else
total_sub_one=24
total=25
fi

# disable tiproxy
echo "start scale in tiproxy"
tiup-cluster $client --yes scale-in $name -N n1:6000
wait_instance_num_reach $name $total_sub_one $native_ssh

echo "start scale out tidb"
topo=./topo/full_scale_in_tidb_2nd.yaml
tiup-cluster $client --yes scale-out $name $topo
# the session certs doesn't exist on the new tidb
! tiup-cluster $client exec $name -N n2 --command "$check_cert_file"
# the configurations are not updated on the new tidb
! tiup-cluster $client exec $name -N n2 --command "$check_cert_config"

# enable tiproxy again
echo "start scale out tiproxy"
topo=./topo/full_scale_in_tiproxy.yaml
tiup-cluster $client --yes scale-out $name $topo
# the session certs exist on the new tidb
tiup-cluster $client exec $name -N n2 --command "$check_cert_file"
# the configurations are updated on the new tidb
tiup-cluster $client exec $name -N n2 --command "$check_cert_config"

# scale in tidb and scale out again
echo "start scale in tidb"
tiup-cluster $client --yes scale-in $name -N n2:4000
wait_instance_num_reach $name $all $native_ssh
echo "start scale out tidb"
topo=./topo/full_scale_in_tidb_2nd.yaml
tiup-cluster $client --yes scale-out $name $topo
# the session certs exist on the new tidb
tiup-cluster $client exec $name -N n2 --command "$check_cert_file"
# the configurations are updated on the new tidb
tiup-cluster $client exec $name -N n2 --command "$check_cert_config"
}
8 changes: 8 additions & 0 deletions tests/tiup-cluster/test_scale_tiproxy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -eu

source script/scale_tiproxy.sh

echo "test scaling of tidb and tiproxy in cluster for version v8.1.0, via easy ssh"
scale_tiproxy v8.1.0 false false

0 comments on commit 078711d

Please sign in to comment.