github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/br_shuffle_region/run.sh (about)

     1  #!/bin/sh
     2  #
     3  # Copyright 2019 PingCAP, Inc.
     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  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  
    16  set -eu
    17  DB="$TEST_NAME"
    18  TABLE="usertable"
    19  
    20  run_sql "CREATE DATABASE $DB;"
    21  
    22  go-ycsb load mysql -P tests/$TEST_NAME/workload -p mysql.host=$TIDB_IP -p mysql.port=$TIDB_PORT -p mysql.user=root -p mysql.db=$DB
    23  
    24  row_count_ori=$(run_sql "SELECT COUNT(*) FROM $DB.$TABLE;" | awk '/COUNT/{print $2}')
    25  
    26  # add shuffle region scheduler
    27  echo "add shuffle-region-scheduler"
    28  run_pd_ctl -u https://$PD_ADDR sched add shuffle-region-scheduler
    29  
    30  # backup with shuffle region
    31  echo "backup start..."
    32  run_br --pd $PD_ADDR backup table -s "local://$TEST_DIR/$DB" --db $DB -t $TABLE
    33  
    34  run_sql "DROP TABLE $DB.$TABLE;"
    35  
    36  # restore with shuffle region
    37  echo "restore start..."
    38  run_br restore table --db $DB --table $TABLE -s "local://$TEST_DIR/$DB" --pd $PD_ADDR
    39  
    40  # remove shuffle region scheduler
    41  run_pd_ctl -u https://$PD_ADDR sched remove shuffle-region-scheduler
    42  
    43  row_count_new=$(run_sql "SELECT COUNT(*) FROM $DB.$TABLE;" | awk '/COUNT/{print $2}')
    44  
    45  echo "[original] row count: $row_count_ori, [after br] row count: $row_count_new"
    46  
    47  if [ "$row_count_ori" -ne "$row_count_new" ];then
    48      echo "TEST: [$TEST_NAME] failed!"
    49      exit 1
    50  fi
    51  
    52  run_sql "DROP DATABASE $DB;"