gooderp18绿色标准版
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

278 lines
19KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>32.1. Running the Tests</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="regress.html" title="Chapter 32. Regression Tests" /><link rel="next" href="regress-evaluation.html" title="32.2. Test Evaluation" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">32.1. Running the Tests</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="regress.html" title="Chapter 32. Regression Tests">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="regress.html" title="Chapter 32. Regression Tests">Up</a></td><th width="60%" align="center">Chapter 32. Regression Tests</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="regress-evaluation.html" title="32.2. Test Evaluation">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="REGRESS-RUN"><div class="titlepage"><div><div><h2 class="title" style="clear: both">32.1. Running the Tests</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="regress-run.html#id-1.6.19.5.3">32.1.1. Running the Tests Against a Temporary Installation</a></span></dt><dt><span class="sect2"><a href="regress-run.html#id-1.6.19.5.4">32.1.2. Running the Tests Against an Existing Installation</a></span></dt><dt><span class="sect2"><a href="regress-run.html#id-1.6.19.5.5">32.1.3. Additional Test Suites</a></span></dt><dt><span class="sect2"><a href="regress-run.html#id-1.6.19.5.6">32.1.4. Locale and Encoding</a></span></dt><dt><span class="sect2"><a href="regress-run.html#id-1.6.19.5.7">32.1.5. Extra Tests</a></span></dt><dt><span class="sect2"><a href="regress-run.html#id-1.6.19.5.8">32.1.6. Testing Hot Standby</a></span></dt></dl></div><p>
  3. The regression tests can be run against an already installed and
  4. running server, or using a temporary installation within the build
  5. tree. Furthermore, there is a <span class="quote">“<span class="quote">parallel</span>”</span> and a
  6. <span class="quote">“<span class="quote">sequential</span>”</span> mode for running the tests. The
  7. sequential method runs each test script alone, while the
  8. parallel method starts up multiple server processes to run groups
  9. of tests in parallel. Parallel testing adds confidence that
  10. interprocess communication and locking are working correctly.
  11. </p><div class="sect2" id="id-1.6.19.5.3"><div class="titlepage"><div><div><h3 class="title">32.1.1. Running the Tests Against a Temporary Installation</h3></div></div></div><p>
  12. To run the parallel regression tests after building but before installation,
  13. type:
  14. </p><pre class="screen">
  15. make check
  16. </pre><p>
  17. in the top-level directory. (Or you can change to
  18. <code class="filename">src/test/regress</code> and run the command there.)
  19. At the end you should see something like:
  20. </p><pre class="screen">
  21. <code class="computeroutput">
  22. =======================
  23. All 193 tests passed.
  24. =======================
  25. </code>
  26. </pre><p>
  27. or otherwise a note about which tests failed. See <a class="xref" href="regress-evaluation.html" title="32.2. Test Evaluation">Section 32.2</a> below before assuming that a
  28. <span class="quote">“<span class="quote">failure</span>”</span> represents a serious problem.
  29. </p><p>
  30. Because this test method runs a temporary server, it will not work
  31. if you did the build as the root user, since the server will not start as
  32. root. Recommended procedure is not to do the build as root, or else to
  33. perform testing after completing the installation.
  34. </p><p>
  35. If you have configured <span class="productname">PostgreSQL</span> to install
  36. into a location where an older <span class="productname">PostgreSQL</span>
  37. installation already exists, and you perform <code class="literal">make check</code>
  38. before installing the new version, you might find that the tests fail
  39. because the new programs try to use the already-installed shared
  40. libraries. (Typical symptoms are complaints about undefined symbols.)
  41. If you wish to run the tests before overwriting the old installation,
  42. you'll need to build with <code class="literal">configure --disable-rpath</code>.
  43. It is not recommended that you use this option for the final installation,
  44. however.
  45. </p><p>
  46. The parallel regression test starts quite a few processes under your
  47. user ID. Presently, the maximum concurrency is twenty parallel test
  48. scripts, which means forty processes: there's a server process and a
  49. <span class="application">psql</span> process for each test script.
  50. So if your system enforces a per-user limit on the number of processes,
  51. make sure this limit is at least fifty or so, else you might get
  52. random-seeming failures in the parallel test. If you are not in
  53. a position to raise the limit, you can cut down the degree of parallelism
  54. by setting the <code class="literal">MAX_CONNECTIONS</code> parameter. For example:
  55. </p><pre class="screen">
  56. make MAX_CONNECTIONS=10 check
  57. </pre><p>
  58. runs no more than ten tests concurrently.
  59. </p></div><div class="sect2" id="id-1.6.19.5.4"><div class="titlepage"><div><div><h3 class="title">32.1.2. Running the Tests Against an Existing Installation</h3></div></div></div><p>
  60. To run the tests after installation (see <a class="xref" href="installation.html" title="Chapter 16. Installation from Source Code">Chapter 16</a>),
  61. initialize a data directory and start the
  62. server as explained in <a class="xref" href="runtime.html" title="Chapter 18. Server Setup and Operation">Chapter 18</a>, then type:
  63. </p><pre class="screen">
  64. make installcheck
  65. </pre><p>
  66. or for a parallel test:
  67. </p><pre class="screen">
  68. make installcheck-parallel
  69. </pre><p>
  70. The tests will expect to contact the server at the local host and the
  71. default port number, unless directed otherwise by <code class="envar">PGHOST</code> and
  72. <code class="envar">PGPORT</code> environment variables. The tests will be run in a
  73. database named <code class="literal">regression</code>; any existing database by this name
  74. will be dropped.
  75. </p><p>
  76. The tests will also transiently create some cluster-wide objects, such as
  77. roles, tablespaces, and subscriptions. These objects will have names
  78. beginning with <code class="literal">regress_</code>. Beware of
  79. using <code class="literal">installcheck</code> mode with an installation that has
  80. any actual global objects named that way.
  81. </p></div><div class="sect2" id="id-1.6.19.5.5"><div class="titlepage"><div><div><h3 class="title">32.1.3. Additional Test Suites</h3></div></div></div><p>
  82. The <code class="literal">make check</code> and <code class="literal">make installcheck</code> commands
  83. run only the <span class="quote">“<span class="quote">core</span>”</span> regression tests, which test built-in
  84. functionality of the <span class="productname">PostgreSQL</span> server. The source
  85. distribution contains many additional test suites, most of them having
  86. to do with add-on functionality such as optional procedural languages.
  87. </p><p>
  88. To run all test suites applicable to the modules that have been selected
  89. to be built, including the core tests, type one of these commands at the
  90. top of the build tree:
  91. </p><pre class="screen">
  92. make check-world
  93. make installcheck-world
  94. </pre><p>
  95. These commands run the tests using temporary servers or an
  96. already-installed server, respectively, just as previously explained
  97. for <code class="literal">make check</code> and <code class="literal">make installcheck</code>. Other
  98. considerations are the same as previously explained for each method.
  99. Note that <code class="literal">make check-world</code> builds a separate instance
  100. (temporary data directory) for each tested module, so it requires more
  101. time and disk space than <code class="literal">make installcheck-world</code>.
  102. </p><p>
  103. On a modern machine with multiple CPU cores and no tight operating-system
  104. limits, you can make things go substantially faster with parallelism.
  105. The recipe that most PostgreSQL developers actually use for running all
  106. tests is something like
  107. </p><pre class="screen">
  108. make check-world -j8 &gt;/dev/null
  109. </pre><p>
  110. with a <code class="option">-j</code> limit near to or a bit more than the number
  111. of available cores. Discarding <span class="systemitem">stdout</span>
  112. eliminates chatter that's not interesting when you just want to verify
  113. success. (In case of failure, the <span class="systemitem">stderr</span>
  114. messages are usually enough to determine where to look closer.)
  115. </p><p>
  116. Alternatively, you can run individual test suites by typing
  117. <code class="literal">make check</code> or <code class="literal">make installcheck</code> in the appropriate
  118. subdirectory of the build tree. Keep in mind that <code class="literal">make
  119. installcheck</code> assumes you've installed the relevant module(s), not
  120. only the core server.
  121. </p><p>
  122. The additional tests that can be invoked this way include:
  123. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
  124. Regression tests for optional procedural languages.
  125. These are located under <code class="filename">src/pl</code>.
  126. </p></li><li class="listitem"><p>
  127. Regression tests for <code class="filename">contrib</code> modules,
  128. located under <code class="filename">contrib</code>.
  129. Not all <code class="filename">contrib</code> modules have tests.
  130. </p></li><li class="listitem"><p>
  131. Regression tests for the ECPG interface library,
  132. located in <code class="filename">src/interfaces/ecpg/test</code>.
  133. </p></li><li class="listitem"><p>
  134. Tests for core-supported authentication methods,
  135. located in <code class="filename">src/test/authentication</code>.
  136. (See below for additional authentication-related tests.)
  137. </p></li><li class="listitem"><p>
  138. Tests stressing behavior of concurrent sessions,
  139. located in <code class="filename">src/test/isolation</code>.
  140. </p></li><li class="listitem"><p>
  141. Tests for crash recovery and physical replication,
  142. located in <code class="filename">src/test/recovery</code>.
  143. </p></li><li class="listitem"><p>
  144. Tests for logical replication,
  145. located in <code class="filename">src/test/subscription</code>.
  146. </p></li><li class="listitem"><p>
  147. Tests of client programs, located under <code class="filename">src/bin</code>.
  148. </p></li></ul></div><p>
  149. When using <code class="literal">installcheck</code> mode, these tests will create
  150. and destroy test databases whose names
  151. include <code class="literal">regression</code>, for
  152. example <code class="literal">pl_regression</code>
  153. or <code class="literal">contrib_regression</code>. Beware of
  154. using <code class="literal">installcheck</code> mode with an installation that has
  155. any non-test databases named that way.
  156. </p><p>
  157. Some of these auxiliary test suites use the TAP infrastructure explained
  158. in <a class="xref" href="regress-tap.html" title="32.4. TAP Tests">Section 32.4</a>.
  159. The TAP-based tests are run only when PostgreSQL was configured with the
  160. option <code class="option">--enable-tap-tests</code>. This is recommended for
  161. development, but can be omitted if there is no suitable Perl installation.
  162. </p><p>
  163. Some test suites are not run by default, either because they are not secure
  164. to run on a multiuser system or because they require special software. You
  165. can decide which test suites to run additionally by setting the
  166. <code class="command">make</code> or environment variable
  167. <code class="varname">PG_TEST_EXTRA</code> to a whitespace-separated list, for
  168. example:
  169. </p><pre class="programlisting">
  170. make check-world PG_TEST_EXTRA='kerberos ldap ssl'
  171. </pre><p>
  172. The following values are currently supported:
  173. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">kerberos</code></span></dt><dd><p>
  174. Runs the test suite under <code class="filename">src/test/kerberos</code>. This
  175. requires an MIT Kerberos installation and opens TCP/IP listen sockets.
  176. </p></dd><dt><span class="term"><code class="literal">ldap</code></span></dt><dd><p>
  177. Runs the test suite under <code class="filename">src/test/ldap</code>. This
  178. requires an <span class="productname">OpenLDAP</span> installation and opens
  179. TCP/IP listen sockets.
  180. </p></dd><dt><span class="term"><code class="literal">ssl</code></span></dt><dd><p>
  181. Runs the test suite under <code class="filename">src/test/ssl</code>. This opens TCP/IP listen sockets.
  182. </p></dd></dl></div><p>
  183. Tests for features that are not supported by the current build
  184. configuration are not run even if they are mentioned in
  185. <code class="varname">PG_TEST_EXTRA</code>.
  186. </p><p>
  187. In addition, there are tests in <code class="filename">src/test/modules</code>
  188. which will be run by <code class="literal">make check-world</code> but not
  189. by <code class="literal">make installcheck-world</code>. This is because they
  190. install non-production extensions or have other side-effects that are
  191. considered undesirable for a production installation. You can
  192. use <code class="literal">make install</code> and <code class="literal">make
  193. installcheck</code> in one of those subdirectories if you wish,
  194. but it's not recommended to do so with a non-test server.
  195. </p></div><div class="sect2" id="id-1.6.19.5.6"><div class="titlepage"><div><div><h3 class="title">32.1.4. Locale and Encoding</h3></div></div></div><p>
  196. By default, tests using a temporary installation use the
  197. locale defined in the current environment and the corresponding
  198. database encoding as determined by <code class="command">initdb</code>. It
  199. can be useful to test different locales by setting the appropriate
  200. environment variables, for example:
  201. </p><pre class="screen">
  202. make check LANG=C
  203. make check LC_COLLATE=en_US.utf8 LC_CTYPE=fr_CA.utf8
  204. </pre><p>
  205. For implementation reasons, setting <code class="envar">LC_ALL</code> does not
  206. work for this purpose; all the other locale-related environment
  207. variables do work.
  208. </p><p>
  209. When testing against an existing installation, the locale is
  210. determined by the existing database cluster and cannot be set
  211. separately for the test run.
  212. </p><p>
  213. You can also choose the database encoding explicitly by setting
  214. the variable <code class="envar">ENCODING</code>, for example:
  215. </p><pre class="screen">
  216. make check LANG=C ENCODING=EUC_JP
  217. </pre><p>
  218. Setting the database encoding this way typically only makes sense
  219. if the locale is C; otherwise the encoding is chosen automatically
  220. from the locale, and specifying an encoding that does not match
  221. the locale will result in an error.
  222. </p><p>
  223. The database encoding can be set for tests against either a temporary or
  224. an existing installation, though in the latter case it must be
  225. compatible with the installation's locale.
  226. </p></div><div class="sect2" id="id-1.6.19.5.7"><div class="titlepage"><div><div><h3 class="title">32.1.5. Extra Tests</h3></div></div></div><p>
  227. The core regression test suite contains a few test files that are not
  228. run by default, because they might be platform-dependent or take a
  229. very long time to run. You can run these or other extra test
  230. files by setting the variable <code class="envar">EXTRA_TESTS</code>. For
  231. example, to run the <code class="literal">numeric_big</code> test:
  232. </p><pre class="screen">
  233. make check EXTRA_TESTS=numeric_big
  234. </pre><p>
  235. To run the collation tests:
  236. </p><pre class="screen">
  237. make check EXTRA_TESTS='collate.linux.utf8 collate.icu.utf8' LANG=en_US.utf8
  238. </pre><p>
  239. The <code class="literal">collate.linux.utf8</code> test works only on Linux/glibc
  240. platforms. The <code class="literal">collate.icu.utf8</code> test only works when
  241. support for ICU was built. Both tests will only succeed when run in a
  242. database that uses UTF-8 encoding.
  243. </p></div><div class="sect2" id="id-1.6.19.5.8"><div class="titlepage"><div><div><h3 class="title">32.1.6. Testing Hot Standby</h3></div></div></div><p>
  244. The source distribution also contains regression tests for the static
  245. behavior of Hot Standby. These tests require a running primary server
  246. and a running standby server that is accepting new WAL changes from the
  247. primary (using either file-based log shipping or streaming replication).
  248. Those servers are not automatically created for you, nor is replication
  249. setup documented here. Please check the various sections of the
  250. documentation devoted to the required commands and related issues.
  251. </p><p>
  252. To run the Hot Standby tests, first create a database
  253. called <code class="literal">regression</code> on the primary:
  254. </p><pre class="screen">
  255. psql -h primary -c "CREATE DATABASE regression"
  256. </pre><p>
  257. Next, run the preparatory script
  258. <code class="filename">src/test/regress/sql/hs_primary_setup.sql</code>
  259. on the primary in the regression database, for example:
  260. </p><pre class="screen">
  261. psql -h primary -f src/test/regress/sql/hs_primary_setup.sql regression
  262. </pre><p>
  263. Allow these changes to propagate to the standby.
  264. </p><p>
  265. Now arrange for the default database connection to be to the standby
  266. server under test (for example, by setting the <code class="envar">PGHOST</code> and
  267. <code class="envar">PGPORT</code> environment variables).
  268. Finally, run <code class="literal">make standbycheck</code> in the regression directory:
  269. </p><pre class="screen">
  270. cd src/test/regress
  271. make standbycheck
  272. </pre><p>
  273. </p><p>
  274. Some extreme behaviors can also be generated on the primary using the
  275. script <code class="filename">src/test/regress/sql/hs_primary_extremes.sql</code>
  276. to allow the behavior of the standby to be tested.
  277. </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="regress.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="regress.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="regress-evaluation.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 32. Regression Tests </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 32.2. Test Evaluation</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1