Skip to content

Commit b9e44ee

Browse files
authored
Merge pull request #2 from ChenHuajun/main
优化归档逻辑和添加测试集等
2 parents c4733b5 + 88fb866 commit b9e44ee

29 files changed

+7171
-1114
lines changed

README.md

Lines changed: 925 additions & 0 deletions
Large diffs are not rendered by default.

Readme.md

Lines changed: 0 additions & 405 deletions
This file was deleted.
Lines changed: 805 additions & 705 deletions
Large diffs are not rendered by default.

cigration.control

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# cigration
1+
# Cigration extension
22
comment = 'Citus shards migration tool'
3-
default_version = '1.0'
3+
default_version = '1.1'
44
requires = 'citus,dblink'
5-
superuser = true
6-
relocatable = true
5+
relocatable = false
6+
schema = pg_catalog

test/.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Local binaries
2+
/pg_regress
3+
4+
# Generated subdirectories
5+
/tmp_check/
6+
/tmp_upgrade/
7+
/build/
8+
/results/
9+
/log/
10+
/bin/test/results/
11+
12+
# Regression test output
13+
/regression.diffs
14+
/regression.out
15+
/test_times.log
16+
17+
# Regression test timing
18+
/test_times.log
19+
20+
# Failure test side effets
21+
/proxy.output
22+
23+
# python
24+
*.pyc
25+
26+
# output from diff normalization that shouldn't be commited
27+
*.unmodified
28+
*.modified

test/LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pg_regress_multi.pl is come from Citus(https://github.com/citusdata/citus/), so follow the Citus's AGPL license, other files follow the Apache 2.0 license

test/Makefile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Makefile for tests of the Citus extension
2+
3+
print-% : ; @echo $* = $($*)
4+
5+
#citus_top_builddir = ../../..
6+
7+
#include Makefile.global
8+
cur_dir:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
9+
10+
citus_abs_srcdir:=${cur_dir}
11+
citus_abs_top_srcdir:=${cur_dir}
12+
#postgres_abs_srcdir:=/var/lib/pgsql/rpm10/BUILD/postgresql-10.2
13+
#postgres_abs_builddir:=/var/lib/pgsql/rpm10/BUILD/postgresql-10.2
14+
15+
PG_CONFIG:=pg_config
16+
PGXS:=$(shell $(PG_CONFIG) --pgxs)
17+
18+
# Citus is built using PostgreSQL's pgxs
19+
USE_PGXS=1
20+
include $(PGXS)
21+
22+
# ensure MAJORVERSION is defined (missing in older versions)
23+
ifndef MAJORVERSION
24+
MAJORVERSION := $(basename $(VERSION))
25+
endif
26+
27+
##
28+
## Citus regression support
29+
##
30+
MULTI_INSTALLDIR=$(CURDIR)/tmp_check/install
31+
pg_regress_multi_check = $(PERL) $(citus_abs_srcdir)/pg_regress_multi.pl --pgxsdir="$(pgxsdir)" --bindir="$(bindir)" --libdir="$(libdir)" --majorversion="$(MAJORVERSION)" --postgres-builddir="$(postgres_abs_builddir)" --postgres-srcdir="$(postgres_abs_srcdir)"
32+
MULTI_REGRESS_OPTS = --inputdir=$(citus_abs_srcdir) $(pg_regress_locale_flags)
33+
34+
# XXX: Can't actually do useful testruns against install - $libdir
35+
# etc will point to the directory configured during postgres'
36+
# build. We could copy the installed tree around, but that's quite
37+
# likely to be mixed with other binaries and such...
38+
cleandir-main:
39+
### echo rm -rf '$(CURDIR)'/tmp_check/install
40+
###
41+
tempinstall-main: cleandir-main
42+
#### mkdir -p $(MULTI_INSTALLDIR)
43+
### $(MAKE) DESTDIR=$(MULTI_INSTALLDIR) -C $(citus_top_builddir) install > tmp_check/install.log 2>&1
44+
45+
# Test input and expected files. These are created by pg_regress itself, so we
46+
# don't have a rule to create them. We do need rules to clean them however.
47+
input_files := $(patsubst $(citus_abs_srcdir)/input/%.source,sql/%.sql, $(wildcard $(citus_abs_srcdir)/input/*.source))
48+
output_files := $(patsubst $(citus_abs_srcdir)/output/%.source,expected/%.out, $(wildcard $(citus_abs_srcdir)/output/*.source))
49+
50+
# have make check actually run all tests, but keep check-full as an
51+
# intermediate, for muscle memory backward compatibility.
52+
check: all tempinstall-main
53+
$(pg_regress_multi_check) --load-extension=citus \
54+
-- $(MULTI_REGRESS_OPTS) --schedule=$(citus_abs_srcdir)/shard_migration $(EXTRA_TESTS)
55+
56+
check_base: all tempinstall-main
57+
$(pg_regress_multi_check) --load-extension=citus \
58+
-- $(MULTI_REGRESS_OPTS) --schedule=$(citus_abs_srcdir)/check_base $(EXTRA_TESTS)
59+
60+
clean distclean maintainer-clean:
61+
rm -f $(output_files) $(input_files)
62+
rm -rf tmp_check/
63+

test/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#Citus分片迁移测试说明
2+
---
3+
# 1. 环境准备
4+
5+
将postgrsql的安装目录加入到PATH环境变量,比如
6+
7+
```
8+
export PATH=/usr/pgsql-12/bin:$PATH
9+
```
10+
11+
# 2. 执行回归测试
12+
13+
cd test
14+
make check
15+
16+
# 3. 执行指定回归测试
17+
18+
通过`EXTRA_TESTS`代入要测试的case名称
19+
20+
```
21+
make check_base EXTRA_TESTS=single_task_execute
22+
make check_base EXTRA_TESTS='single_task_execute replica_identity_check'
23+
```
24+
25+
注意:执行指定测试case时,可能由于序列值的差异,导致diff结果误判,需要人工判断。
26+

test/check_base

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test: init

0 commit comments

Comments
 (0)