vitess.io/vitess@v0.16.2/test/local_example.sh (about) 1 #!/bin/bash 2 3 # Copyright 2020 The Vitess Authors. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 # This test runs through the scripts in examples/local to make sure they work. 18 # It should be kept in sync with the steps in https://vitess.io/docs/get-started/local/ 19 # So we can detect if a regression affecting a tutorial is introduced. 20 21 source build.env 22 23 set -xeo pipefail 24 25 cd "$VTROOT/examples/local" 26 unset VTROOT # ensure that the examples can run without VTROOT now. 27 28 source ../common/env.sh # Required so that "mysql" works from alias 29 30 ./101_initial_cluster.sh 31 32 sleep 5 # Give vtgate time to really start. 33 34 mysql < ../common/insert_commerce_data.sql 35 mysql --table < ../common/select_commerce_data.sql 36 37 ./201_customer_tablets.sh 38 39 for shard in "customer/0"; do 40 while true; do 41 if (mysql "$shard" -e 'show tables' &>/dev/null); then 42 break 43 fi 44 echo -e "waiting for shard: $shard ..." 45 sleep 1 46 done 47 done 48 49 ./202_move_tables.sh 50 sleep 3 # required for now 51 52 ./203_switch_reads.sh 53 54 ./204_switch_writes.sh 55 56 mysql --table < ../common/select_customer0_data.sql 57 58 # We expect this to fail due to the denied tables 59 # rules in place. 60 # For some reason this succeeds... 61 # $(mysql --table < ../common/select_commerce_data.sql &>/dev/null || true) 62 63 ./205_clean_commerce.sh 64 # We expect this to fail as the keyspace is now gone. 65 (mysql --table < ../common/select_commerce_data.sql &>/dev/null || true) 66 67 ./301_customer_sharded.sh 68 ./302_new_shards.sh 69 70 # Wait for the schema to be targetable before proceeding 71 # TODO: Eliminate this race in the examples' scripts 72 for shard in "customer/-80" "customer/80-"; do 73 while true; do 74 if (mysql "$shard" -e 'show tables' &>/dev/null); then 75 break 76 fi 77 echo -e "waiting for shard: $shard ..." 78 sleep 1 79 done 80 done 81 82 ./303_reshard.sh 83 sleep 3 # TODO: Required for now! 84 85 ./304_switch_reads.sh 86 ./305_switch_writes.sh 87 88 mysql --table < ../common/select_customer-80_data.sql 89 mysql --table < ../common/select_customer80-_data.sql 90 91 ./306_down_shard_0.sh 92 93 ./401_teardown.sh 94