Skip to content

Commit

Permalink
lighning: add foreign key test
Browse files Browse the repository at this point in the history
Signed-off-by: crazycs520 <[email protected]>
  • Loading branch information
crazycs520 committed Dec 22, 2022
1 parent 0f4bd73 commit f05058c
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 0 deletions.
Empty file.
1 change: 1 addition & 0 deletions br/tests/lightning_foreign_key/data/fk-schema-create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create database foreign_key;
1 change: 1 addition & 0 deletions br/tests/lightning_foreign_key/data/fk.child-schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create table child (id int key, pid int, constraint fk_1 foreign key (pid) references parent(id));
1 change: 1 addition & 0 deletions br/tests/lightning_foreign_key/data/fk.child.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
insert into child values (1,1),(2,2),(3,3),(4,4);
1 change: 1 addition & 0 deletions br/tests/lightning_foreign_key/data/fk.parent-schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create table parent(id int key, a int);
1 change: 1 addition & 0 deletions br/tests/lightning_foreign_key/data/fk.parent.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
insert into parent values (1,1),(2,2),(3,3),(4,4);
37 changes: 37 additions & 0 deletions br/tests/lightning_foreign_key/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
#
# Copyright 2022 PingCAP, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Basic check for whether partitioned tables work.

set -eu

for BACKEND in tidb local; do
if [ "$BACKEND" = 'local' ]; then
check_cluster_version 4 0 0 'local backend' || continue
fi

run_sql 'DROP DATABASE IF EXISTS foreign_key;'

run_lightning --backend $BACKEND

run_sql 'SELECT count(1), sum(a) FROM foreign_key.parent;'
check_contains 'count(1): 4'
check_contains 'sum(a): 10'

run_sql 'SELECT count(1), sum(pid) FROM foreign_key.child;'
check_contains 'count(1): 4'
check_contains 'sum(pid): 10'
done

0 comments on commit f05058c

Please sign in to comment.