From cf08f2fe60aca8d163a0c5ff1193ec285061a628 Mon Sep 17 00:00:00 2001 From: kennytm Date: Sat, 20 Jul 2019 01:47:49 +0800 Subject: [PATCH] tests: add test case for simple partitioned tables (#206) --- tests/partitioned-table/config.toml | 20 +++++++++++++ .../data/partitioned-schema-create.sql | 1 + .../data/partitioned.a-schema.sql | 1 + .../partitioned-table/data/partitioned.a.sql | 2 ++ tests/partitioned-table/run.sh | 29 +++++++++++++++++++ 5 files changed, 53 insertions(+) create mode 100644 tests/partitioned-table/config.toml create mode 100644 tests/partitioned-table/data/partitioned-schema-create.sql create mode 100644 tests/partitioned-table/data/partitioned.a-schema.sql create mode 100644 tests/partitioned-table/data/partitioned.a.sql create mode 100755 tests/partitioned-table/run.sh diff --git a/tests/partitioned-table/config.toml b/tests/partitioned-table/config.toml new file mode 100644 index 000000000..2833a6666 --- /dev/null +++ b/tests/partitioned-table/config.toml @@ -0,0 +1,20 @@ +[lightning] +check-requirements = false +file = "/tmp/lightning_test_result/lightning.log" +level = "warning" + +[tikv-importer] +addr = "127.0.0.1:8808" + +[mydumper] +data-source-dir = "tests/partitioned-table/data" + +[tidb] +host = "127.0.0.1" +user = "root" +status-port = 10080 +log-level = "error" + +[post-restore] +checksum = true +analyze = true diff --git a/tests/partitioned-table/data/partitioned-schema-create.sql b/tests/partitioned-table/data/partitioned-schema-create.sql new file mode 100644 index 000000000..1e2c5a991 --- /dev/null +++ b/tests/partitioned-table/data/partitioned-schema-create.sql @@ -0,0 +1 @@ +create database partitioned; \ No newline at end of file diff --git a/tests/partitioned-table/data/partitioned.a-schema.sql b/tests/partitioned-table/data/partitioned.a-schema.sql new file mode 100644 index 000000000..5c1a33a18 --- /dev/null +++ b/tests/partitioned-table/data/partitioned.a-schema.sql @@ -0,0 +1 @@ +create table a (a int) partition by hash(a) partitions 5; diff --git a/tests/partitioned-table/data/partitioned.a.sql b/tests/partitioned-table/data/partitioned.a.sql new file mode 100644 index 000000000..23786b356 --- /dev/null +++ b/tests/partitioned-table/data/partitioned.a.sql @@ -0,0 +1,2 @@ +insert into a values (268435456), (1), (262144), (32), (4), (65536), (8388608); + diff --git a/tests/partitioned-table/run.sh b/tests/partitioned-table/run.sh new file mode 100755 index 000000000..f1990fac3 --- /dev/null +++ b/tests/partitioned-table/run.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# +# Copyright 2019 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, +# See the License for the specific language governing permissions and +# limitations under the License. + +# Basic check for whether partitioned tables work. + +set -eu + +run_sql 'DROP DATABASE IF EXISTS partitioned;' + +run_lightning + +run_sql 'SELECT count(1), sum(a) FROM partitioned.a;' +check_contains 'count(1): 7' +check_contains 'sum(a): 277151781' + +run_sql "SHOW TABLE STATUS FROM partitioned WHERE name = 'a';" +check_contains 'Create_options: partitioned'