github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/lightning_alter_random/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  
    18  # FIXME: auto-random is only stable on master currently.
    19  check_cluster_version 4 0 0 AUTO_RANDOM || exit 0
    20  
    21  # test lightning with autocommit disabled
    22  run_sql "SET @@global.autocommit = '0';"
    23  
    24  for backend in tidb importer local; do
    25      if [ "$backend" = 'local' ]; then
    26          check_cluster_version 4 0 0 'local backend' || continue
    27      fi
    28  
    29      run_sql 'DROP DATABASE IF EXISTS alter_random;'
    30      run_lightning --backend $backend
    31  
    32      run_sql "SELECT count(*) from alter_random.t"
    33      check_contains "count(*): 3"
    34  
    35      run_sql "SELECT id & b'000001111111111111111111111111111111111111111111111111111111111' as inc FROM alter_random.t"
    36      check_contains 'inc: 1'
    37      check_contains 'inc: 2'
    38      check_contains 'inc: 3'
    39  
    40      # auto random base is 4
    41      run_sql "INSERT INTO alter_random.t VALUES ();commit;"
    42      run_sql "SELECT id & b'000001111111111111111111111111111111111111111111111111111111111' as inc FROM alter_random.t"
    43      if [ "$backend" = 'tidb' ]; then
    44        check_contains 'inc: 30002'
    45      else
    46        check_contains 'inc: 4'
    47      fi
    48  done
    49  
    50  run_sql "SET @@global.autocommit = '1';"