|
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 | 44 | def util_is_executable(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,27 @@ def test_init_after_cleanup(self): |
91 | 91 | node.cleanup() |
92 | 92 | node.init().start().execute('select 1') |
93 | 93 |
|
| 94 | + @unittest.skipUnless(pg_version_ge('9.6'), 'query works on 9.6+') |
| 95 | + def test_init_unique_system_id(self): |
| 96 | + with scoped_config( |
| 97 | + cache_initdb=True, cached_initdb_unique=True) as config: |
| 98 | + |
| 99 | + self.assertTrue(config.cache_initdb) |
| 100 | + self.assertTrue(config.cached_initdb_unique) |
| 101 | + |
| 102 | + # spawn two nodes; ids must be different |
| 103 | + with get_new_node().init().start() as node1, \ |
| 104 | + get_new_node().init().start() as node2: |
| 105 | + |
| 106 | + # this function exists in PostgreSQL 9.6+ |
| 107 | + query = 'select system_identifier from pg_control_system()' |
| 108 | + |
| 109 | + id1 = node1.execute(query)[0] |
| 110 | + id2 = node2.execute(query)[0] |
| 111 | + |
| 112 | + # ids must increase |
| 113 | + self.assertGreater(id2, id1) |
| 114 | + |
94 | 115 | def test_node_exit(self): |
95 | 116 | base_dir = None |
96 | 117 |
|
@@ -486,8 +507,7 @@ def test_logging(self): |
486 | 507 | master.restart() |
487 | 508 | self.assertTrue(master._logger.is_alive()) |
488 | 509 |
|
489 | | - @unittest.skipUnless( |
490 | | - util_is_executable("pgbench"), "pgbench may be missing") |
| 510 | + @unittest.skipUnless(util_is_executable('pgbench'), 'might be missing') |
491 | 511 | def test_pgbench(self): |
492 | 512 | with get_new_node().init().start() as node: |
493 | 513 |
|
|
0 commit comments