|
38 | 38 | get_pg_config |
39 | 39 |
|
40 | 40 | from testgres import bound_ports |
| 41 | +from testgres.utils import pg_version_ge |
41 | 42 |
|
42 | 43 |
|
43 | | -def util_is_executable(util): |
| 44 | +def util_exists(util): |
44 | 45 | def good_properties(f): |
45 | | - return ( |
46 | | - os.path.exists(f) and |
47 | | - os.path.isfile(f) and |
48 | | - os.access(f, os.X_OK) |
49 | | - ) |
| 46 | + # yapf: disable |
| 47 | + return (os.path.exists(f) and |
| 48 | + os.path.isfile(f) and |
| 49 | + os.access(f, os.X_OK)) |
50 | 50 |
|
51 | 51 | # try to resolve it |
52 | 52 | if good_properties(get_bin_path(util)): |
@@ -91,6 +91,34 @@ def test_init_after_cleanup(self): |
91 | 91 | node.cleanup() |
92 | 92 | node.init().start().execute('select 1') |
93 | 93 |
|
| 94 | + @unittest.skipUnless(util_exists('pg_resetwal'), 'might be missing') |
| 95 | + @unittest.skipUnless(pg_version_ge('9.6'), 'query works on 9.6+') |
| 96 | + def test_init_unique_system_id(self): |
| 97 | + # this function exists in PostgreSQL 9.6+ |
| 98 | + query = 'select system_identifier from pg_control_system()' |
| 99 | + |
| 100 | + with scoped_config(cache_initdb=False): |
| 101 | + with get_new_node().init().start() as node0: |
| 102 | + id0 = node0.execute(query)[0] |
| 103 | + |
| 104 | + # yapf: disable |
| 105 | + with scoped_config(cache_initdb=True, |
| 106 | + cached_initdb_unique=True) as config: |
| 107 | + |
| 108 | + self.assertTrue(config.cache_initdb) |
| 109 | + self.assertTrue(config.cached_initdb_unique) |
| 110 | + |
| 111 | + # spawn two nodes; ids must be different |
| 112 | + with get_new_node().init().start() as node1, \ |
| 113 | + get_new_node().init().start() as node2: |
| 114 | + |
| 115 | + id1 = node1.execute(query)[0] |
| 116 | + id2 = node2.execute(query)[0] |
| 117 | + |
| 118 | + # ids must increase |
| 119 | + self.assertGreater(id1, id0) |
| 120 | + self.assertGreater(id2, id1) |
| 121 | + |
94 | 122 | def test_node_exit(self): |
95 | 123 | base_dir = None |
96 | 124 |
|
@@ -486,8 +514,7 @@ def test_logging(self): |
486 | 514 | master.restart() |
487 | 515 | self.assertTrue(master._logger.is_alive()) |
488 | 516 |
|
489 | | - @unittest.skipUnless( |
490 | | - util_is_executable("pgbench"), "pgbench may be missing") |
| 517 | + @unittest.skipUnless(util_exists('pgbench'), 'might be missing') |
491 | 518 | def test_pgbench(self): |
492 | 519 | with get_new_node().init().start() as node: |
493 | 520 |
|
|
0 commit comments