バージョンごとのドキュメント一覧

33.1. テストの実行 #

<title>Running the Tests</title>

The regression tests can be run against an already installed and running server, or using a temporary installation within the build tree. Furthermore, there is a <quote>parallel</quote> and a <quote>sequential</quote> mode for running the tests. The sequential method runs each test script alone, while the parallel method starts up multiple server processes to run groups of tests in parallel. Parallel testing adds confidence that interprocess communication and locking are working correctly. Some tests may run sequentially even in the <quote>parallel</quote> mode in case this is required by the test. リグレッションテストは既にインストールされ稼働中のサーバや、ビルドツリー内の一時的なインストレーションに対して実行することができます。 さらに、テストの実行には並行連続モードがあります。 連続モードでは個々のテストスクリプトを単独で実行し、並行モードでは複数のサーバプロセスを実行し、テストをグループ化して並行的に実行します。 並行テストではプロセス間通信とロック機能が正常に作動しているかをテストします。 テストの中には、テストによって要求されている場合には並行モードであっても連続的に実行するものがあるかもしれません。

33.1.1. 一時的なインストレーションに対するテストの実行 #

<title>Running the Tests Against a Temporary Installation</title>

To run the parallel regression tests after building but before installation, type: 構築後、インストール前に並行リグレッションテストを行う場合には、最上位のディレクトリで以下のように入力してください。

make check

in the top-level directory. (Or you can change to <filename>src/test/regress</filename> and run the command there.) Tests which are run in parallel are prefixed with <quote>+</quote>, and tests which run sequentially are prefixed with <quote>-</quote>. At the end you should see something like: (または、src/test/regressディレクトリに移動して、そこで実行してください。) 並行的に実行されるテストは前に+が付いていて、連続的に実行されるテストは前に-が付いています。 終了したら以下のような表示がされるはずです。


# All 213 tests passed.

or otherwise a note about which tests failed. See <xref linkend="regress-evaluation"/> below before assuming that a <quote>failure</quote> represents a serious problem. これが表示されなければ、テストは失敗したことになります。 失敗を深刻な問題であると推測する前に、以下の 33.2 を参照してください。

Because this test method runs a temporary server, it will not work if you did the build as the root user, since the server will not start as root. Recommended procedure is not to do the build as root, or else to perform testing after completing the installation. この試験方法では、一時的にサーバを起動するので、rootユーザとして構築を行なった場合には動作しません。 サーバがrootでは起動しないからです。 rootで構築をしないこと、もしくはインストール完了後に試験を実施することをお薦めします。

If you have configured <productname>PostgreSQL</productname> to install into a location where an older <productname>PostgreSQL</productname> installation already exists, and you perform <literal>make check</literal> before installing the new version, you might find that the tests fail because the new programs try to use the already-installed shared libraries. (Typical symptoms are complaints about undefined symbols.) If you wish to run the tests before overwriting the old installation, you'll need to build with <literal>configure &#45;-disable-rpath</literal>. It is not recommended that you use this option for the final installation, however. 古いPostgreSQLのインストレーションが既に存在している場所にPostgreSQLをインストールするように構築した場合、新しいバージョンをインストールする前にmake checkを行うと、新しいプログラムがインストール済みの共有ライブラリを使用しようとするために試験が失敗することになります。 (典型的な症状は、未定義シンボルに関するエラーメッセージです。) 古いインストレーションを上書きする前に試験を行いたいのであれば、configure --disable-rpathで構築する必要があります。 しかし、このオプションを最終的なインストレーションで使用することは推奨しません。

The parallel regression test starts quite a few processes under your user ID. Presently, the maximum concurrency is twenty parallel test scripts, which means forty processes: there's a server process and a <application>psql</application> process for each test script. So if your system enforces a per-user limit on the number of processes, make sure this limit is at least fifty or so, else you might get random-seeming failures in the parallel test. If you are not in a position to raise the limit, you can cut down the degree of parallelism by setting the <literal>MAX_CONNECTIONS</literal> parameter. For example: 並行リグレッションテストは、実行したユーザのユーザIDを使用して相当数のプロセスを起動します。 現在、最大で20個の並行テストスクリプトが同時に実行されますが、これは合計40個のプロセスが実行されることを意味します。 各テストスクリプトに対して、1つのサーバプロセスと1つのpsqlプロセスが存在するためです。 ですので、使用するシステムでユーザ当たりのプロセス数に制限を加えている場合は、その上限が少なくとも50程度であることを確認してください。 さもないと、並行テストにおいて、ランダムに発生しているように見える失敗が発生するかもしれません。 この上限を変更できない場合は、MAX_CONNECTIONSパラメータを編集して、並行度を減らすことができます。 例えば、以下は同時実行数を10以下で実行します。

make MAX_CONNECTIONS=10 check

runs no more than ten tests concurrently.

33.1.2. 既存のインストレーションに対するテストの実行 #

<title>Running the Tests Against an Existing Installation</title>

To run the tests after installation (see <xref linkend="installation"/>), initialize a data directory and start the server as explained in <xref linkend="runtime"/>, then type: インストール(第17章を参照)後にテストを実行するには、第19章で説明したようにデータディレクトリを初期化し、サーバを起動し、そして以下を入力してください。

make installcheck

or for a parallel test: もしくは、並行テストの場合は以下を入力してください。

make installcheck-parallel

The tests will expect to contact the server at the local host and the default port number, unless directed otherwise by <envar>PGHOST</envar> and <envar>PGPORT</envar> environment variables. The tests will be run in a database named <literal>regression</literal>; any existing database by this name will be dropped. テストでは、PGHOST環境変数とPGPORT環境変数で指定がない限り、ローカルホストのサーバに接続し、デフォルトのポート番号を使用します。 テストはregressionという名前のデータベースで行なわれます。 この名前の既存のデータベースはすべて削除されます。

The tests will also transiently create some cluster-wide objects, such as roles, tablespaces, and subscriptions. These objects will have names beginning with <literal>regress_</literal>. Beware of using <literal>installcheck</literal> mode with an installation that has any actual global objects named that way. テストは、ロールやテーブル空間、サブスクリプションのようなクラスタ全体にわたるオブジェクトも一時的に作成します。 このオブジェクトの名前はregress_で始まります。 実際のグローバルオブジェクトがそのように名付けられたインストレーションでinstallcheckモードを使う場合には注意してください。

33.1.3. 追加のテストスイート #

<title>Additional Test Suites</title>

The <literal>make check</literal> and <literal>make installcheck</literal> commands run only the <quote>core</quote> regression tests, which test built-in functionality of the <productname>PostgreSQL</productname> server. The source distribution contains many additional test suites, most of them having to do with add-on functionality such as optional procedural languages. make checkmake installcheckコマンドはコアリグレッションテストだけを実行します。 そのテストはPostgreSQLサーバに組み込まれている機能のみをテストします。 ソース配布には、オプションとなっている手続き言語のような追加機能とその多くが関係のある追加のテストスイートが多く含まれています。

To run all test suites applicable to the modules that have been selected to be built, including the core tests, type one of these commands at the top of the build tree: コアテストを含む、構築するよう選択されたモジュールに適用できるテストスイートをすべて実行するにはビルドツリーの最上位で以下のコマンドの一つを入力して下さい。

make check-world
make installcheck-world

These commands run the tests using temporary servers or an already-installed server, respectively, just as previously explained for <literal>make check</literal> and <literal>make installcheck</literal>. Other considerations are the same as previously explained for each method. Note that <literal>make check-world</literal> builds a separate instance (temporary data directory) for each tested module, so it requires more time and disk space than <literal>make installcheck-world</literal>. make checkmake installcheckで以前述べたように、このコマンドは、それぞれ、一時的なサーバもしくは既にインストールされているサーバを使ってテストを行ないます。 それ以外に考慮すべきことはそれぞれのところで以前述べたことと同じです。 make check-worldはテストするモジュール毎に別のインスタンス(一時的なデータディレクトリ)を構築しますので、make installcheck-worldよりもずっとより多くの時間とディスク容量が必要です。

On a modern machine with multiple CPU cores and no tight operating-system limits, you can make things go substantially faster with parallelism. The recipe that most PostgreSQL developers actually use for running all tests is something like 複数のCPUコアがあり、オペレーティングシステムの厳しい制限のない最近のマシンでは、並列処理でかなり速くできます。 ほとんどのPostgreSQL開発者がテストをすべて実行するのに実際に使っている方法は以下のようなものです。

make check-world -j8 >/dev/null

with a <option>-j</option> limit near to or a bit more than the number of available cores. Discarding <systemitem>stdout</systemitem> eliminates chatter that's not interesting when you just want to verify success. (In case of failure, the <systemitem>stderr</systemitem> messages are usually enough to determine where to look closer.) ここで-jの範囲は利用可能なコアの数に近い、もしくはそれより少し多い値です。 stdoutを捨てることで、成功を検証する時には興味のない出力を除きます。(失敗した場合、どこをより詳細に調べるべきか決めるにはstderrメッセージでたいてい十分です。)

Alternatively, you can run individual test suites by typing <literal>make check</literal> or <literal>make installcheck</literal> in the appropriate subdirectory of the build tree. Keep in mind that <literal>make installcheck</literal> assumes you've installed the relevant module(s), not only the core server. 代わりに、構築ツリーの適切なサブディレクトリでmake checkまたはmake installcheckと入力することで個々のテストスイートを実行することもできます。 make installcheckはコアサーバだけでなく、関係のあるモジュールもインストール済みであると仮定することを覚えておいて下さい。

The additional tests that can be invoked this way include: このように実行できる追加のテストには以下のものが含まれます。

  • Regression tests for optional procedural languages. These are located under <filename>src/pl</filename>. オプションとなっている手続き言語のリグレッションテスト。 これはsrc/plにあります。

  • Regression tests for <filename>contrib</filename> modules, located under <filename>contrib</filename>. Not all <filename>contrib</filename> modules have tests. contribの下にあるcontribモジュールのリグレッションテスト。 すべてのcontribモジュールにテストがあるわけではありません。

  • Regression tests for the interface libraries, located in <filename>src/interfaces/libpq/test</filename> and <filename>src/interfaces/ecpg/test</filename>. src/interfaces/libpq/testsrc/interfaces/ecpg/testにあるインタフェースライブラリのリグレッションテスト。

  • Tests for core-supported authentication methods, located in <filename>src/test/authentication</filename>. (See below for additional authentication-related tests.) コアがサポートする認証方式のテスト。 src/test/authenticationにあります。 (認証に関連する追加のテストについては下記を参照してください。)

  • Tests stressing behavior of concurrent sessions, located in <filename>src/test/isolation</filename>. 同時実行中のセッションの振舞いの負荷テスト。 src/test/isolationにあります。

  • Tests for crash recovery and physical replication, located in <filename>src/test/recovery</filename>. クラッシュリカバリと物理レプリケーションのテスト。 src/test/recoveryにあります。

  • Tests for logical replication, located in <filename>src/test/subscription</filename>. 論理レプリケーションのテスト。 src/test/subscriptionにあります。

  • Tests of client programs, located under <filename>src/bin</filename>. src/bin以下のクライアントプログラムのテスト。

When using <literal>installcheck</literal> mode, these tests will create and destroy test databases whose names include <literal>regression</literal>, for example <literal>pl_regression</literal> or <literal>contrib_regression</literal>. Beware of using <literal>installcheck</literal> mode with an installation that has any non-test databases named that way. installcheckモードを使う場合には、上記のテストは名前regressionを含むテストデータベースを破壊します。例えば、pl_regressioncontrib_regressionです。 非テストデータベースがそのように名付けられたインストレーションでinstallcheckモードを使う場合には注意してください。

Some of these auxiliary test suites use the TAP infrastructure explained in <xref linkend="regress-tap"/>. The TAP-based tests are run only when PostgreSQL was configured with the option <option>&#45;-enable-tap-tests</option>. This is recommended for development, but can be omitted if there is no suitable Perl installation. この補助的なテストスイートの中には33.4で説明するTAP基盤を使うものがあります。 オプション--enable-tap-testsを指定してPostgreSQLを構築した場合にのみ、TAPベースのテストが行なわれます。 これは開発にはお薦めですが、適切なPerlのインストレーションがない場合には省略できます。

Some test suites are not run by default, either because they are not secure to run on a multiuser system, because they require special software or because they are resource intensive. You can decide which test suites to run additionally by setting the <command>make</command> or environment variable <varname>PG_TEST_EXTRA</varname> to a whitespace-separated list, for example: マルチユーザシステムにおいて安全に実行できない、特別なソフトウェアを必要とする、あるいは、リソースを大量に使うといういずれかの理由により、一部のテストスイートはデフォルトでは実行されません。 どのテストスイートを追加で実行するかをmakeや環境変数PG_TEST_EXTRAに空白区切りのリストを設定することで決定できます。 以下に例を示します。

make check-world PG_TEST_EXTRA='kerberos ldap ssl load_balance'

The following values are currently supported: 現在、以下の値がサポートされます。

kerberos

Runs the test suite under <filename>src/test/kerberos</filename>. This requires an MIT Kerberos installation and opens TCP/IP listen sockets. src/test/kerberos以下のテストスイートを実行します。 これはMIT Kerberosのインストールを必要とし、TCP/IPリッスンソケットを開きます。

ldap

Runs the test suite under <filename>src/test/ldap</filename>. This requires an <productname>OpenLDAP</productname> installation and opens TCP/IP listen sockets. src/test/ldap以下のテストスイートを実行します。 これはOpenLDAPのインストールを必要としTCP/IPリッスンソケットを開きます。

ssl

Runs the test suite under <filename>src/test/ssl</filename>. This opens TCP/IP listen sockets. src/test/ssl以下のテストスイートを実行します。 これはTCP/IPリッスンソケットを開きます。

load_balance

Runs the test <filename>src/interfaces/libpq/t/004_load_balance_dns.pl</filename>. This requires editing the system <filename>hosts</filename> file and opens TCP/IP listen sockets. src/interfaces/libpq/t/004_load_balance_dns.plテストを実行します。 これには、システムのhostsファイルを編集することが必要で、TCP/IPリッスンソケットを開きます。

wal_consistency_checking

Uses <literal>wal_consistency_checking=all</literal> while running certain tests under <filename>src/test/recovery</filename>. Not enabled by default because it is resource intensive. src/test/recoveryで特定のテストを実行する際にwal_consistency_checking=allを使用します。 リソースを大量に消費するため、デフォルトでは有効になっていません。

Tests for features that are not supported by the current build configuration are not run even if they are mentioned in <varname>PG_TEST_EXTRA</varname>. 現在のビルド設定ではサポートされない機能のテストは、PG_TEST_EXTRAに記述されていても、実行されません。

In addition, there are tests in <filename>src/test/modules</filename> which will be run by <literal>make check-world</literal> but not by <literal>make installcheck-world</literal>. This is because they install non-production extensions or have other side-effects that are considered undesirable for a production installation. You can use <literal>make install</literal> and <literal>make installcheck</literal> in one of those subdirectories if you wish, but it's not recommended to do so with a non-test server. さらに、make check-worldでは実行されますが、make installcheck-worldでは実行されないテストがsrc/test/modulesにあります。 これは、実運用向けではない拡張をインストールしたり、実運用のインストレーションには望ましくない副作用があったりするためです。 お望みとあらば、そのサブディレクトリの1つでmake installmake installcheckを使うことはできますが、テスト用でないサーバでそうすることはお勧めしません。

33.1.4. ロケールと符号化方式 #

<title>Locale and Encoding</title>

By default, tests using a temporary installation use the locale defined in the current environment and the corresponding database encoding as determined by <command>initdb</command>. It can be useful to test different locales by setting the appropriate environment variables, for example: デフォルトでは、一時的なインストレーションを使うテストは、現在の環境で定義されたロケールとinitdbで決定される対応するデータベース符号化方式を使用します。 異なるロケールを試験する際は、以下の例のように適切な環境変数を設定することが有用です。

make check LANG=C
make check LC_COLLATE=en_US.utf8 LC_CTYPE=fr_CA.utf8

For implementation reasons, setting <envar>LC_ALL</envar> does not work for this purpose; all the other locale-related environment variables do work. 実装上の理由のため、LC_ALLはこの目的には動作しません。 この他のロケール関連の環境変数は動作します。

When testing against an existing installation, the locale is determined by the existing database cluster and cannot be set separately for the test run. 既存のインストレーションに対するテストでは、ロケールは既存のデータベースクラスタによって決まり、テスト実行時に別の値に設定することができません。

You can also choose the database encoding explicitly by setting the variable <envar>ENCODING</envar>, for example: また、以下の例のようにENCODING変数を設定することで明示的にデータベース符号化方式を選択することができます。

make check LANG=C ENCODING=EUC_JP

Setting the database encoding this way typically only makes sense if the locale is C; otherwise the encoding is chosen automatically from the locale, and specifying an encoding that does not match the locale will result in an error. この方法でデータベース符号化方式を設定することは、通常ロケールがCだった場合にのみ意味があります。 この他の場合、ロケールから自動的に符号化方式が選択されます。 ロケールと一致しない符号化方式を指定してもエラーになるだけです。

The database encoding can be set for tests against either a temporary or an existing installation, though in the latter case it must be compatible with the installation's locale. データベース符号化方式は一時的なインストレーションに対するテストでも既存のインストレーションに対するテストでも設定することができます。 ただし、後者の場合にはインストレーションのロケールと互換性がなければなりません。

33.1.5. カスタムサーバ設定 #

<title>Custom Server Settings</title>

Custom server settings to use when running a regression test suite can be set in the <varname>PGOPTIONS</varname> environment variable (for settings that allow this): リグレッションテストスイートを実行する際に使用するカスタムサーバ設定は、(以下を有効にするためには)PGOPTIONS環境変数で設定できます。

make check PGOPTIONS="-c debug_parallel_query=regress -c work_mem=50MB"

When running against a temporary installation, custom settings can also be set by supplying a pre-written <filename>postgresql.conf</filename>: 一時的なインストールに対して実行する際には、前もって書き込んでおいたpostgresql.confを用意することによってもカスタム設定に反映できます。

echo 'log_checkpoints = on' > test_postgresql.conf
echo 'work_mem = 50MB' >> test_postgresql.conf
make check EXTRA_REGRESS_OPTS="--temp-config=test_postgresql.conf"

This can be useful to enable additional logging, adjust resource limits, or enable extra run-time checks such as <xref linkend="guc-debug-discard-caches"/>. これは追加のログ取得、リソース制限の調整、debug_discard_cachesのような追加の実行時チェックを可能にするために有効かもしれません。

33.1.6. 追加のテスト #

<title>Extra Tests</title>

The core regression test suite contains a few test files that are not run by default, because they might be platform-dependent or take a very long time to run. You can run these or other extra test files by setting the variable <envar>EXTRA_TESTS</envar>. For example, to run the <literal>numeric_big</literal> test: プラットフォームに依存する、または非常に時間がかかる可能性があるという理由で、コアリグレッションテスト一式にはデフォルトでは動作しないテストがいくつか含まれています。 EXTRA_TESTS変数を設定することでこれらの追加テストやその他のテストを実行することができます。 例えば、numeric_bigテストを以下のように実行します。

make check EXTRA_TESTS=numeric_big