github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/lightning_examples/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  
    18  EXAMPLES_PATH=pkg/lightning/mydump/examples
    19  
    20  # Because of issue JENKINS-45544 we can't use the Unicode filename in the
    21  # examples. We are going to rename it in-place.
    22  do_rename() {
    23      mv "$EXAMPLES_PATH/mocker_test.$1-schema.sql" "$EXAMPLES_PATH/mocker_test.$2-schema.sql"
    24      mv "$EXAMPLES_PATH/mocker_test.$1.sql" "$EXAMPLES_PATH/mocker_test.$2.sql"
    25  }
    26  do_rename i ı
    27  undo_rename() {
    28      do_rename ı i
    29  }
    30  trap undo_rename EXIT
    31  
    32  do_run_lightning() {
    33      run_lightning -d $EXAMPLES_PATH --config "tests/$TEST_NAME/$1.toml"
    34  }
    35  
    36  # Perform the import
    37  run_sql 'DROP DATABASE IF EXISTS mocker_test;'
    38  do_run_lightning 512
    39  
    40  # The existing reader_test
    41  run_sql 'use mocker_test; select count(distinct ID) cnt from `tbl_autoid`'
    42  check_contains 'cnt: 10000'
    43  run_sql 'use mocker_test; select count(distinct Name) cnt from `tbl_multi_index`'
    44  check_contains 'cnt: 10000'
    45  
    46  # Check if rest of the imported data really match
    47  run_sql 'SELECT * FROM mocker_test.ı LIMIT 2'
    48  check_not_contains '* 2. row *'
    49  check_contains 'ſ: 🤪'
    50  
    51  run_sql 'SELECT * FROM mocker_test.report_case_high_risk LIMIT 2'
    52  check_not_contains '* 2. row *'
    53  check_contains 'id: 2'
    54  check_contains 'report_data: 4'
    55  check_contains 'caseType: 6'
    56  check_contains 'total_case: 8'
    57  check_contains 'today_new_case: 10'
    58  
    59  run_sql 'select count(*), sum(id), max(name), min(name), sum(crc32(name)) from mocker_test.tbl_autoid;'
    60  check_contains 'count(*): 10000'
    61  check_contains 'sum(id): 50005000'
    62  check_contains 'max(name): 4-9-9'
    63  check_contains 'min(name): 0-0-0'
    64  check_contains 'sum(crc32(name)): 21388950023608'
    65  
    66  # Ensure the AUTO_INCREMENT value is properly defined
    67  run_sql "insert into mocker_test.tbl_autoid (name) values ('new');"
    68  run_sql "select id > 10000 from mocker_test.tbl_autoid where name = 'new';"
    69  check_not_contains '* 2. row *'
    70  check_contains 'id > 10000: 1'
    71  
    72  run_sql 'select count(*), avg(age), max(name), min(name), sum(crc32(name)) from mocker_test.tbl_multi_index;'
    73  check_contains 'count(*): 10000'
    74  check_contains 'avg(age): 477.7500'
    75  check_contains 'max(name): 4+9+9'
    76  check_contains 'min(name): 0+0+0'
    77  check_contains 'sum(crc32(name)): 21433704622808'
    78  
    79  # Ensure the indices are intact
    80  run_sql "select age from mocker_test.tbl_multi_index where name = '1+2+3'"
    81  check_contains 'age: 6'
    82  run_sql "select count(*) from mocker_test.tbl_multi_index where age = 6"
    83  check_contains 'count(*): 20'
    84  
    85  # Rest of the existing reader_test
    86  run_sql 'DROP DATABASE mocker_test;'
    87  do_run_lightning 1
    88  run_sql 'use mocker_test; select count(distinct ID) cnt from `tbl_autoid`'
    89  check_contains 'cnt: 10000'
    90  run_sql 'use mocker_test; select count(distinct Name) cnt from `tbl_multi_index`'
    91  check_contains 'cnt: 10000'
    92  
    93  run_sql 'DROP DATABASE mocker_test;'
    94  do_run_lightning 131072
    95  run_sql 'use mocker_test; select count(distinct ID) cnt from `tbl_autoid`'
    96  check_contains 'cnt: 10000'
    97  run_sql 'use mocker_test; select count(distinct Name) cnt from `tbl_multi_index`'
    98  check_contains 'cnt: 10000'