Postgressql regress Test
Recently read the regression test in PG, and now record what you see.
1. Let's start with an example
[[email protected] regress]$ make checkmake-c. /.. /.. /src/port allmake[1]: Entering directory '/tmp/postgresql-9.3.4/src/port ' make-c. /backend submake-errcodesmake[2]: Entering directory '/tmp/postgresql-9.3.4/src/backend ' make[2]: Nothing to being 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 allmake[1]: Entering directory '/tmp/postgresql-9.3.4/src/common ' make-c. /backend submake-errcodesmake[2]: Entering directory '/tmp/postgresql-9.3.4/src/backend ' make[2]: Nothing to being 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./testtablespacemkdir./testtablespace. /.. /.. /src/test/regress/pg_regress--inputdir=. --temp-install=./tmp_check--top-builddir=. /.. /.. --dlpath=. --schedule=./parallel_schedule ============== Creating temporary InstaLlation ============================ Initializing database system ============================ starting P Ostmaster ==============running on port 57536 with PID 2843============== creating database "regression "==============create databasealter database============== running regression test queries ==============t EST tablespace ... okparallel Group (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 num Eric:.. Ok Txid ... ok uuid ... ok enum ... ok money ... ok rangetypes ... oktest strings ... oktest numerology Okparallel Group (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 Timetz ... ok timestamp ... ok timestamptz ... ok interval ... ok Abstime ... ok reltime ... ok tinterval ... ok inet ... ok Macaddr ... ok tstypes ... ok comments ... okparallel Group ( 6 tests): Geometry regex horology type_sanity oidjoins opr_sanity geometry ... ok horology ... ok regex ... ok oidjoins ... ok type_sanity ... Ok opr_sanity ... oktest insert ... oktest create_function_1 ... oktest create_ Type ... oktest create_table oktest create_function_2 ... okparallel group (2 tests): Copyselect copy copy ... ok copyselect okparallel Group (2 tests): Create_ Operator Create_misc Create_misc ... ok create_operator ... okparallel group (2 tests): CRE Ate_view create_index create_index ... ok create_view ... okparallel group (tests): C Reate_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 updatab Le_views ... oktest sanity_check ... oktest errors ... oktest select Okparallel Group (Tests): Select_into select_distinct select_distinct_on select_implicit select_having Subsele CT Case Aggregates Transactions hash_index Delete random portals arrays namespace Update Union Btree_index join prepared_x Acts Select_into. Ok select_distinct ... ok select_distinct_on ... ok selec T_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 ... okparallel group (4 tests): Secur Ity_label Privileges Matview collate privileges ... ok Security_label ... ok collate ... ok matview ... okparallel group (3 Tests): Psql alter_generic Misc Alter_gen Eric ... ok misc ... ok psql ... oktest rules ... oktest Event_triGger Okparallel Group (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 ... okparallel group (tests): Limit copy2 prepare truncate XML domain Returnin G 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 rowtype s ... ok returning ... ok largeobject ... ok with ... ok xml ... oktest stats ... ok============== shutting down postmaster ===================================== all 136 tests passed. =======================
As can be seen from the above example, the test case of regress test is quite simple to use. Let's take a detailed introduction to the next regress test.
2. Start regress test
From the example above, we see that it is very easy to start regress test as long as you execute make check in the Src/test/regress directory.
3. Test mode
The execution statements in the example are as follows:
.. /.. /.. /src/test/regress/pg_regress--inputdir=. --temp-install=./tmp_check--top-builddir=. /.. /.. --dlpath=. --schedule=./parallel_schedule
What does this--schedule=./parallel_schedule parameter mean? This is because in Pg/pgxc's regress test, there are two test modes: a database test based on a temporary installation and a test based on an installed database. The difference between the two is that the temporarily installed test will install the DB cluster itself before the test starts, and the database cluster will be stopped after the test is completed and temporary artifacts removed. The reverse is based on the installed cluster. This is the temporary installation 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
The methods for testing based on an installed database are as follows:
[[email protected] regress]$ gmake installcheckgmake-c. /.. /.. /src/port allgmake[1]: Entering directory '/tmp/postgresql-9.3.4/src/port ' gmake-c. /backend submake-errcodesgmake[2]: Entering directory '/tmp/postgresql-9.3.4/src/backend ' gmake[2]: nothing to being 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 allgmake[1]: Entering directory '/tmp/postgresql-9.3.4/src/common ' gmake-c. /backend submake-errcodesgmake[2]: Entering directory '/tmp/postgresql-9.3.4/src/backend ' gmake[2]: nothing to being 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./testtablespacemkdir./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, Skipp Ingdrop database============== creating DATABASE "regression" ==============create databasealter database========= ===== running regression test queries ==============test tablespace ... oktest boolean ... oktest char ... oktest name ... oktest varchar ... oktest Text ... oktest int2 ... oktest int4 ... oktest int8 ... oktest oid ... oktest float4 ... oktest float8. . Oktest bit ... oktest numeric ... oktest txid ... oktest uuid ... oktest enum ... oktest money ... oktest rangetypes ... oktest Strings ... oktest numerology ... oktest point ... oktest lseg ... oktest box ... oktest path ... oktest polygon ... oktest Circle ... oktest date ... oktest time ... oktest Timetz ... oktest timestamp ... oktest timestamptz ... oktest interval. . Oktest abstime ... oktest reltime ... oktest tinterval ... oktest inet ... oktest macaddr ... oktest tstypes ... oktest comments ... oktest geometry ... oktest horology ... oktest regex ... oktest Oidjoins ... oktest type_sanity ... oktest opr_sanity ... oktest insert ... oktestCreate_function_1 ... oktest create_type ... oktest create_table ... oktest create_functio N_2 ... oktest copy ... oktest copyselect ... oktest create_misc. . Oktest create_operator ... oktest create_index ... oktest create_view ... oktest create_ Aggregate ... oktest create_function_3 ... oktest create_cast ... oktest constraints ... oktest triggers ... oktest inherit ... oktest create_table_like ... oktest Typed_table ... oktest vacuum ... oktest drop_if_exists ... oktest updatable_vie WS ... oktest sanity_check ... oktest errors ... oktest select. . Oktest select_into ... oktest select_distinct ... oktest select_distinct_on ... oktest select_ Implicit ... Oktest select_having. Oktest subselect ... oktest union ... oktest case ... oktest join ... oktest aggregates ... oktest transactions ... oktest random ... oktest portals ... oktest arrays ... oktes T btree_index ... oktest hash_index ... oktest update ... oktest delete ... oktest namespace ... oktest prepared_xacts ... oktest privileges. .. Oktest Security_label ... oktest collate ... oktest matview ... oktest alter_g Eneric ... oktest misc ... oktest psql ... oktest rules ... oktest event_trigger ... oktest select_views ... oktest portals_p2 ... oktest Foreign_key ... oktest cluster ... oktest dependency ... oktest guc ... oktes T bitmapops ... oktest combocid ... oktest tsearch ... oktest tsdicts ... oktest foreign_data ... oktest window ... oktest xmlmap. .. Oktest functional_deps ... oktest advisory_lock ... oktest json ... oktest PLANCAC He ... oktest limit ... oktest plpgsql ... oktest copy2 ... oktest temp ... oktest domain ... oktest rangefuncs ... oktest Prepare ... oktest without_oid ... oktest conversion ... oktest truncate ... oktest alter_table ... oktest sequence ... oktest polymorphism. . Oktest Rowtypes ... oktest returning ... oktest largeobject ... oktest with. .. Oktest xml ... oktest stats ... ok======================= all 136 tests passed. =======================
4. Result judgment
The regress test of PG is executed by executing the SQL script in the sql/directory one by one, redirecting the results of execution to the results/directory. The expected/directory is the expected execution result. diff The files in the results directory with the files in expected. If the file is inconsistent, it is determined that the corresponding SQL script execution result is unsuccessful, and vice versa.
5. The method of self-made test case
According to the execution flow of regress test described in 4, the method of making test case is quite simple and can be divided into 3 steps as follows:
- In the sql/directory, add the SQL script of the self-made test case.
- In the expected/directory, add the correct result from the SQL script that made the test case. It is important to note that because the diff command is used, even a space character can cause a diff result to fail. Therefore, it is important to pay attention to the result files made in expected directory.
- Add a call to the SQL script in the Parallel_schedule/serial_schedule file.
6. Precautions:
There are several points to note when using regress test:
- If you use a temporary installation of the test method, the PG port is hard code, before using the use of these ports.
- If you use an installed test method, the default port 5432 for coord is used when you test the connection database. Therefore, you must use the default installed DB cluster to use the regression test for the installed method.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Postgressql regress Test