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

     1  #!/bin/sh
     2  #
     3  # Copyright 2020 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  
    19  run_sql "CREATE DATABASE $DB;"
    20  
    21  run_sql "CREATE TABLE $DB.USERTABLE1 ( \
    22    YCSB_KEY varchar(64) NOT NULL, \
    23    FIELD0 varchar(1) DEFAULT NULL, \
    24    PRIMARY KEY (YCSB_KEY) \
    25  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;"
    26  
    27  run_sql "INSERT INTO $DB.USERTABLE1 VALUES (\"a\", \"b\");"
    28  run_sql "INSERT INTO $DB.USERTABLE1 VALUES (\"aa\", \"b\");"
    29  
    30  # backup table with upper name
    31  echo "backup start..."
    32  run_br --pd $PD_ADDR backup table --db "$DB" --table "USERTABLE1" -s "local://$TEST_DIR/$DB"
    33  
    34  run_sql "DROP DATABASE $DB;"
    35  
    36  # restore table with upper name success
    37  echo "restore start..."
    38  run_br --pd $PD_ADDR restore table --db "$DB" --table "USERTABLE1" -s "local://$TEST_DIR/$DB"
    39  
    40  table_count=$(run_sql "use $DB; show tables;" | grep "Tables_in" | wc -l)
    41  if [ "$table_count" -ne "1" ];then
    42      echo "TEST: [$TEST_NAME] failed!"
    43      exit 1
    44  fi
    45  
    46  run_sql "DROP DATABASE $DB;"