PostgresSQL regress test

PostgresSQL regress test

最近看了下pg中的回归测试相关内容,现在将看到的内容记录下来。

1.      先来一个例子

[[email protected] regress]$ make check
make -C ../../../src/port all
make[1]: Entering directory `/tmp/postgresql-9.3.4/src/port'
make -C ../backend submake-errcodes
make[2]: Entering directory `/tmp/postgresql-9.3.4/src/backend'
make[2]: Nothing to be done for `submake-errcodes'.
make[2]: Leaving directory `/tmp/postgresql-9.3.4/src/backend'
make[1]: Leaving directory `/tmp/postgresql-9.3.4/src/port'
make -C ../../../src/common all
make[1]: Entering directory `/tmp/postgresql-9.3.4/src/common'
make -C ../backend submake-errcodes
make[2]: Entering directory `/tmp/postgresql-9.3.4/src/backend'
make[2]: Nothing to be done for `submake-errcodes'.
make[2]: Leaving directory `/tmp/postgresql-9.3.4/src/backend'
make[1]: Leaving directory `/tmp/postgresql-9.3.4/src/common'
rm -rf ./testtablespace
mkdir ./testtablespace
../../../src/test/regress/pg_regress --inputdir=. --temp-install=./tmp_check --top-builddir=../../..   --dlpath=.  --schedule=./parallel_schedule
============== creating temporary installation        ==============
============== initializing database system           ==============
============== starting postmaster                    ==============
running on port 57536 with PID 2843
============== creating database "regression"         ==============
CREATE DATABASE
ALTER DATABASE
============== running regression test queries        ==============
test tablespace               ... ok
parallel group (18 tests):  boolean char name varchar oid int2 int4 float4 text float8 int8 txid enum money bit uuid numeric rangetypes
     boolean                  ... ok
     char                     ... ok
     name                     ... ok
     varchar                  ... ok
     text                     ... ok
     int2                     ... ok
     int4                     ... ok
     int8                     ... ok
     oid                      ... ok
     float4                   ... ok
     float8                   ... ok
     bit                      ... ok
     numeric                  ... ok
     txid                     ... ok
     uuid                     ... ok
     enum                     ... ok
     money                    ... ok
     rangetypes               ... ok
test strings                  ... ok
test numerology               ... ok
parallel group (19 tests):  point lseg box path circle abstime time polygon date timetz interval tinterval inet reltime macaddr comments tstypes timestamptz timestamp
     point                    ... ok
     lseg                     ... ok
     box                      ... ok
     path                     ... ok
     polygon                  ... ok
     circle                   ... ok
     date                     ... ok
     time                     ... ok
     timetz                   ... ok
     timestamp                ... ok
     timestamptz              ... ok
     interval                 ... ok
     abstime                  ... ok
     reltime                  ... ok
     tinterval                ... ok
     inet                     ... ok
     macaddr                  ... ok
     tstypes                  ... ok
     comments                 ... ok
parallel group (6 tests):  geometry regex horology type_sanity oidjoins opr_sanity
     geometry                 ... ok
     horology                 ... ok
     regex                    ... ok
     oidjoins                 ... ok
     type_sanity              ... ok
     opr_sanity               ... ok
test insert                   ... ok
test create_function_1        ... ok
test create_type              ... ok
test create_table             ... ok
test create_function_2        ... ok
parallel group (2 tests):  copyselect copy
     copy                     ... ok
     copyselect               ... ok
parallel group (2 tests):  create_operator create_misc
     create_misc              ... ok
     create_operator          ... ok
parallel group (2 tests):  create_view create_index
     create_index             ... ok
     create_view              ... ok
parallel group (11 tests):  create_aggregate create_cast create_function_3 constraints triggers typed_table inherit drop_if_exists vacuum create_table_like updatable_views
     create_aggregate         ... ok
     create_function_3        ... ok
     create_cast              ... ok
     constraints              ... ok
     triggers                 ... ok
     inherit                  ... ok
     create_table_like        ... ok
     typed_table              ... ok
     vacuum                   ... ok
     drop_if_exists           ... ok
     updatable_views          ... ok
test sanity_check             ... ok
test errors                   ... ok
test select                   ... ok
parallel group (20 tests):  select_into select_distinct select_distinct_on select_implicit select_having subselect case aggregates transactions hash_index delete random portals arrays namespace update union btree_index join prepared_xacts
     select_into              ... ok
     select_distinct          ... ok
     select_distinct_on       ... ok
     select_implicit          ... ok
     select_having            ... ok
     subselect                ... ok
     union                    ... ok
     case                     ... ok
     join                     ... ok
     aggregates               ... ok
     transactions             ... ok
     random                   ... ok
     portals                  ... ok
     arrays                   ... ok
     btree_index              ... ok
     hash_index               ... ok
     update                   ... ok
     namespace                ... ok
     prepared_xacts           ... ok
     delete                   ... ok
parallel group (4 tests):  security_label privileges matview collate
     privileges               ... ok
     security_label           ... ok
     collate                  ... ok
     matview                  ... ok
parallel group (3 tests):  psql alter_generic misc
     alter_generic            ... ok
     misc                     ... ok
     psql                     ... ok
test rules                    ... ok
test event_trigger            ... ok
parallel group (16 tests):  select_views portals_p2 dependency foreign_key guc tsearch advisory_lock cluster bitmapops combocid functional_deps xmlmap tsdicts foreign_data json window
     select_views             ... ok
     portals_p2               ... ok
     foreign_key              ... ok
     cluster                  ... ok
     dependency               ... ok
     guc                      ... ok
     bitmapops                ... ok
     combocid                 ... ok
     tsearch                  ... ok
     tsdicts                  ... ok
     foreign_data             ... ok
     window                   ... ok
     xmlmap                   ... ok
     functional_deps          ... ok
     advisory_lock            ... ok
     json                     ... ok
parallel group (19 tests):  limit copy2 prepare truncate xml domain returning without_oid rowtypes with largeobject alter_table rangefuncs polymorphism temp plancache sequence conversion plpgsql
     plancache                ... ok
     limit                    ... ok
     plpgsql                  ... ok
     copy2                    ... ok
     temp                     ... ok
     domain                   ... ok
     rangefuncs               ... ok
     prepare                  ... ok
     without_oid              ... ok
     conversion               ... ok
     truncate                 ... ok
     alter_table              ... ok
     sequence                 ... ok
     polymorphism             ... ok
     rowtypes                 ... ok
     returning                ... ok
     largeobject              ... ok
     with                     ... ok
     xml                      ... ok
test stats                    ... ok
============== shutting down postmaster               ==============

=======================
 All 136 tests passed.
=======================

通过上面的例子可以看出来,regress test的测试用例使用起来是相当的简单。下面我们来详细介绍下regress test。

2.      启动regress test

通过上面的例子,我们看出启动regress test是很容易的,只要在src/test/regress目录下执行make check即可。

3.      测试模式

例子中的执行语句如下:

../../../src/test/regress/pg_regress--inputdir=. --temp-install=./tmp_check --top-builddir=../../..   --dlpath=. --schedule=./parallel_schedule

这个--schedule=./parallel_schedule参数是什么意思呢?这是因为在PG/PGXC的regress test中,有两种测试模式,分别为:基于临时安装的数据库测试和基于已安装的数据库进行测试。两者的区别在于,临时安装的测试在测试开始之前会自行安装数据库集群,测试完成之后会将数据库集群停掉,并删除临时产物。反之则是基于已安装的集群。这就是临时安装的log:

../../../src/test/regress/pg_regress --inputdir=. --temp-install=./tmp_check --top-builddir=../../..   --dlpath=.  --schedule=./parallel_schedule
============== creating temporary installation        ==============
============== initializing database system           ==============
============== starting postmaster                    ==============
running on port 57536 with PID 2843

基于已安装的数据库进行测试的方法如下:

[[email protected] regress]$ gmake installcheck
gmake -C ../../../src/port all
gmake[1]: Entering directory `/tmp/postgresql-9.3.4/src/port'
gmake -C ../backend submake-errcodes
gmake[2]: Entering directory `/tmp/postgresql-9.3.4/src/backend'
gmake[2]: Nothing to be done for `submake-errcodes'.
gmake[2]: Leaving directory `/tmp/postgresql-9.3.4/src/backend'
gmake[1]: Leaving directory `/tmp/postgresql-9.3.4/src/port'
gmake -C ../../../src/common all
gmake[1]: Entering directory `/tmp/postgresql-9.3.4/src/common'
gmake -C ../backend submake-errcodes
gmake[2]: Entering directory `/tmp/postgresql-9.3.4/src/backend'
gmake[2]: Nothing to be done for `submake-errcodes'.
gmake[2]: Leaving directory `/tmp/postgresql-9.3.4/src/backend'
gmake[1]: Leaving directory `/tmp/postgresql-9.3.4/src/common'
rm -rf ./testtablespace
mkdir ./testtablespace
../../../src/test/regress/pg_regress --inputdir=. --psqldir='/opt/pgsql/bin'   --dlpath=.  --schedule=./serial_schedule
(using postmaster on Unix socket, default port)
============== dropping database "regression"         ==============
NOTICE:  database "regression" does not exist, skipping
DROP DATABASE
============== creating database "regression"         ==============
CREATE DATABASE
ALTER DATABASE
============== running regression test queries        ==============
test tablespace               ... ok
test boolean                  ... ok
test char                     ... ok
test name                     ... ok
test varchar                  ... ok
test text                     ... ok
test int2                     ... ok
test int4                     ... ok
test int8                     ... ok
test oid                      ... ok
test float4                   ... ok
test float8                   ... ok
test bit                      ... ok
test numeric                  ... ok
test txid                     ... ok
test uuid                     ... ok
test enum                     ... ok
test money                    ... ok
test rangetypes               ... ok
test strings                  ... ok
test numerology               ... ok
test point                    ... ok
test lseg                     ... ok
test box                      ... ok
test path                     ... ok
test polygon                  ... ok
test circle                   ... ok
test date                     ... ok
test time                     ... ok
test timetz                   ... ok
test timestamp                ... ok
test timestamptz              ... ok
test interval                 ... ok
test abstime                  ... ok
test reltime                  ... ok
test tinterval                ... ok
test inet                     ... ok
test macaddr                  ... ok
test tstypes                  ... ok
test comments                 ... ok
test geometry                 ... ok
test horology                 ... ok
test regex                    ... ok
test oidjoins                 ... ok
test type_sanity              ... ok
test opr_sanity               ... ok
test insert                   ... ok
test create_function_1        ... ok
test create_type              ... ok
test create_table             ... ok
test create_function_2        ... ok
test copy                     ... ok
test copyselect               ... ok
test create_misc              ... ok
test create_operator          ... ok
test create_index             ... ok
test create_view              ... ok
test create_aggregate         ... ok
test create_function_3        ... ok
test create_cast              ... ok
test constraints              ... ok
test triggers                 ... ok
test inherit                  ... ok
test create_table_like        ... ok
test typed_table              ... ok
test vacuum                   ... ok
test drop_if_exists           ... ok
test updatable_views          ... ok
test sanity_check             ... ok
test errors                   ... ok
test select                   ... ok
test select_into              ... ok
test select_distinct          ... ok
test select_distinct_on       ... ok
test select_implicit          ... ok
test select_having            ... ok
test subselect                ... ok
test union                    ... ok
test case                     ... ok
test join                     ... ok
test aggregates               ... ok
test transactions             ... ok
test random                   ... ok
test portals                  ... ok
test arrays                   ... ok
test btree_index              ... ok
test hash_index               ... ok
test update                   ... ok
test delete                   ... ok
test namespace                ... ok
test prepared_xacts           ... ok
test privileges               ... ok
test security_label           ... ok
test collate                  ... ok
test matview                  ... ok
test alter_generic            ... ok
test misc                     ... ok
test psql                     ... ok
test rules                    ... ok
test event_trigger            ... ok
test select_views             ... ok
test portals_p2               ... ok
test foreign_key              ... ok
test cluster                  ... ok
test dependency               ... ok
test guc                      ... ok
test bitmapops                ... ok
test combocid                 ... ok
test tsearch                  ... ok
test tsdicts                  ... ok
test foreign_data             ... ok
test window                   ... ok
test xmlmap                   ... ok
test functional_deps          ... ok
test advisory_lock            ... ok
test json                     ... ok
test plancache                ... ok
test limit                    ... ok
test plpgsql                  ... ok
test copy2                    ... ok
test temp                     ... ok
test domain                   ... ok
test rangefuncs               ... ok
test prepare                  ... ok
test without_oid              ... ok
test conversion               ... ok
test truncate                 ... ok
test alter_table              ... ok
test sequence                 ... ok
test polymorphism             ... ok
test rowtypes                 ... ok
test returning                ... ok
test largeobject              ... ok
test with                     ... ok
test xml                      ... ok
test stats                    ... ok

=======================
 All 136 tests passed.
=======================

4.      结果判断

PG的regress test的流程为:逐个执行sql/目录下的sql脚本,将执行的结果重定向到results/目录下。而expected/目录下则是预期的执行结果。将results目录下的文件逐个与expected中文件进行diff。若文件不一致,则判定为对应的sql脚本执行结果为失败,反之为成功。

5.      自做成test case的方法

根据4中介绍的regress test的执行流程可知,自做成test case的方法相当简单,可分为如下3步:

  • 在sql/目录下加入自做成的test  case的sql脚本。
  • 在expected/目录下加入自做成test case的sql脚本的正确结果。需要注意的是,由于判断是使用diff命令,因此即使空格符也会导致diff的结果失败。所以,做成expected目录下的结果文件需要十分注意。
  • 在parallel_schedule/ serial_schedule文件中添加调用sql脚本。

6.      注意事项:

在使用regress test时,有如下几点需要注意:

  • 如果使用临时安装的测试方式,pg的端口都是hard code的,使用前需要却用这些端口的占用情况。
  • 如果使用已安装的测试方式,测连接数据库时,会使用coord的默认端口5432。所以必须使用默认安装的数据库集群才能使用已安装方法的回归测试。

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-10-05 03:07:13

PostgresSQL regress test的相关文章

PostgresSql开放局域网访问

1) 确认已经退掉所有的MASF终端和MSF GUI,然后打开PostgresSQL的启动文件在文件POSTGRESQL_START参数后面添加-h 0.0.0.0,让PostgreSQL启动时绑定到所有的IP地址. 2) 打开PostgreSQL的访问控制文件pg_hba.conf在末尾处添加以下内容,开放本地局域网的数据库连接.根据自己的IP填写.如果你的IP为192.168.1.102则添写192.168.1.1/24. host all all IP段 md5 3) 重新启动Postgr

How to regress out unwanted vectors

Source: http://stats.stackexchange.com/questions/117840/how-to-regress-out-some-variables 一楼答案粘贴如下,regress out的一种简单数学方法. It seems to me that the following is the mathematically simplest way to partial-out variables from a correlated set of items. Con

postgresSQL 实现数据修改后,自动更新updated_date/ts等字段

1. 需求说明: 实现MYSQL中有on update CURRENT_TIMESTAMP 2. 需求分析 由于数据库迁移需要将MYSQL中的数据迁移到postgresSQL中,由于MYSQL中有on update CURRENT_TIMESTAMP这种功能但是PostgresSQL中并没有.需要寻找一个代替方法来做,采用触发器,来进行更新 3. 实现 1. 表的结构如下 CREATE TABLE users ( id serial not null, name varchar(100), em

PostgresSQL数据库安装及操作

PostgreSQL介绍 PostgreSQL是一个功能强大的开源对象关系数据库管理系统(ORDBMS). 用于安全地存储数据; 支持最佳做法,并允许在处理请求时检索它们. PostgreSQL(也称为Post-gress-Q-L)由PostgreSQL全球开发集团(全球志愿者团队)开发. 它不受任何公司或其他私人实体控制. 它是开源的,其源代码是免费提供的. PostgreSQL是跨平台的,可以在许多操作系统上运行,如Linux,FreeBSD,OS X,Solaris和Microsoft W

PostgresSQL常用函数

1.系统信息函数 1.会话信息函数 edbstore=# select current_catalog; #查询当前数据库名称 current_database ------------------ edbstore (1 row) edbstore=# select current_database(); #查询当前数据库名称 current_database ------------------ edbstore (1 row) edbstore=# select current_schem

PostgresSQL中的限制和级联删除

摘录自:http://www.mamicode.com/info-detail-879792.html 删除和更新时对应的操作是一样的 1 Restrict 禁止删除被引用的行 (不能将约束检查推迟到事物的晚些时候) 2 No Action 如果存在任何引用行,则抛出错误,如果不声明任何行为则No Action就是缺省行为 (允许约束检查推迟到事物的晚些时候) 3 Cascade 在删除一个被引用的行时,引用他的行被自动删除 4 Set Null (外键上才有) 删除被引用行时,引用他的字段设置

PostgresSQL使用Copy命令能大大提高数据导入速度

最近在做会员系统,其中会员系统有一份企业信息初始化的数据,需要从SQL Server数据库导入到PostgreSQL,单表的数据近30万.最开始的方案是在SQL Server上生成insert into的sql,再把生成的sql在Postgresql上导入.第一次导入时,没有删除索引,用了近2个小时才导完一张单表.后面在网上找到PostgreSQL有一个Copy命令用于大量数据的导入导出(http://www.2cto.com/database/201309/241346.html),于是就用了

postgressql

参考文章 FreeBSD10.0下ports安装postgresql9.4-server: http://download.csdn.net/detail/machen_smiling/8425613 -----------------------------------------------------------------------------------

【PostgresSQL】同时更新两个表

UPDATE table1 SET column = value FROM table2 WHERE table1.column2 = table2.column2