Skip to content

Commit

Permalink
Merge pull request #2 from ChenHuajun/main
Browse files Browse the repository at this point in the history
优化归档逻辑和添加测试集等
  • Loading branch information
cloud-sn2 authored Feb 15, 2021
2 parents c4733b5 + 88fb866 commit b9e44ee
Show file tree
Hide file tree
Showing 29 changed files with 7,171 additions and 1,114 deletions.
925 changes: 925 additions & 0 deletions README.md

Large diffs are not rendered by default.

405 changes: 0 additions & 405 deletions Readme.md

This file was deleted.

1,510 changes: 805 additions & 705 deletions cigration--1.0.sql → cigration--1.1.sql

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions cigration.control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# cigration
# Cigration extension
comment = 'Citus shards migration tool'
default_version = '1.0'
default_version = '1.1'
requires = 'citus,dblink'
superuser = true
relocatable = true
relocatable = false
schema = pg_catalog
28 changes: 28 additions & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Local binaries
/pg_regress

# Generated subdirectories
/tmp_check/
/tmp_upgrade/
/build/
/results/
/log/
/bin/test/results/

# Regression test output
/regression.diffs
/regression.out
/test_times.log

# Regression test timing
/test_times.log

# Failure test side effets
/proxy.output

# python
*.pyc

# output from diff normalization that shouldn't be commited
*.unmodified
*.modified
1 change: 1 addition & 0 deletions test/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +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
63 changes: 63 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Makefile for tests of the Citus extension

print-% : ; @echo $* = $($*)

#citus_top_builddir = ../../..

#include Makefile.global
cur_dir:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))

citus_abs_srcdir:=${cur_dir}
citus_abs_top_srcdir:=${cur_dir}
#postgres_abs_srcdir:=/var/lib/pgsql/rpm10/BUILD/postgresql-10.2
#postgres_abs_builddir:=/var/lib/pgsql/rpm10/BUILD/postgresql-10.2

PG_CONFIG:=pg_config
PGXS:=$(shell $(PG_CONFIG) --pgxs)

# Citus is built using PostgreSQL's pgxs
USE_PGXS=1
include $(PGXS)

# ensure MAJORVERSION is defined (missing in older versions)
ifndef MAJORVERSION
MAJORVERSION := $(basename $(VERSION))
endif

##
## Citus regression support
##
MULTI_INSTALLDIR=$(CURDIR)/tmp_check/install
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)"
MULTI_REGRESS_OPTS = --inputdir=$(citus_abs_srcdir) $(pg_regress_locale_flags)

# XXX: Can't actually do useful testruns against install - $libdir
# etc will point to the directory configured during postgres'
# build. We could copy the installed tree around, but that's quite
# likely to be mixed with other binaries and such...
cleandir-main:
### echo rm -rf '$(CURDIR)'/tmp_check/install
###
tempinstall-main: cleandir-main
#### mkdir -p $(MULTI_INSTALLDIR)
### $(MAKE) DESTDIR=$(MULTI_INSTALLDIR) -C $(citus_top_builddir) install > tmp_check/install.log 2>&1

# Test input and expected files. These are created by pg_regress itself, so we
# don't have a rule to create them. We do need rules to clean them however.
input_files := $(patsubst $(citus_abs_srcdir)/input/%.source,sql/%.sql, $(wildcard $(citus_abs_srcdir)/input/*.source))
output_files := $(patsubst $(citus_abs_srcdir)/output/%.source,expected/%.out, $(wildcard $(citus_abs_srcdir)/output/*.source))

# have make check actually run all tests, but keep check-full as an
# intermediate, for muscle memory backward compatibility.
check: all tempinstall-main
$(pg_regress_multi_check) --load-extension=citus \
-- $(MULTI_REGRESS_OPTS) --schedule=$(citus_abs_srcdir)/shard_migration $(EXTRA_TESTS)

check_base: all tempinstall-main
$(pg_regress_multi_check) --load-extension=citus \
-- $(MULTI_REGRESS_OPTS) --schedule=$(citus_abs_srcdir)/check_base $(EXTRA_TESTS)

clean distclean maintainer-clean:
rm -f $(output_files) $(input_files)
rm -rf tmp_check/

26 changes: 26 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#Citus分片迁移测试说明
---
# 1. 环境准备

将postgrsql的安装目录加入到PATH环境变量,比如

```
export PATH=/usr/pgsql-12/bin:$PATH
```

# 2. 执行回归测试

cd test
make check

# 3. 执行指定回归测试

通过`EXTRA_TESTS`代入要测试的case名称

```
make check_base EXTRA_TESTS=single_task_execute
make check_base EXTRA_TESTS='single_task_execute replica_identity_check'
```

注意:执行指定测试case时,可能由于序列值的差异,导致diff结果误判,需要人工判断。

1 change: 1 addition & 0 deletions test/check_base
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test: init
Loading

0 comments on commit b9e44ee

Please sign in to comment.