|
93 | 93 |
|
94 | 94 | from .standby import First |
95 | 95 |
|
| 96 | +from . import utils |
| 97 | + |
96 | 98 | from .utils import \ |
97 | 99 | PgVer, \ |
98 | 100 | eprint, \ |
@@ -265,14 +267,17 @@ def _get_os_ops() -> OsOperations: |
265 | 267 | if testgres_config.os_ops: |
266 | 268 | return testgres_config.os_ops |
267 | 269 |
|
268 | | - return LocalOperations() |
| 270 | + return LocalOperations.get_single_instance() |
269 | 271 |
|
270 | 272 | @staticmethod |
271 | 273 | def _get_port_manager(os_ops: OsOperations) -> PortManager: |
272 | 274 | assert os_ops is not None |
273 | 275 | assert isinstance(os_ops, OsOperations) |
274 | 276 |
|
275 | | - if isinstance(os_ops, LocalOperations): |
| 277 | + if os_ops is LocalOperations.get_single_instance(): |
| 278 | + assert utils._old_port_manager is not None |
| 279 | + assert type(utils._old_port_manager) == PortManager__Generic # noqa: E721 |
| 280 | + assert utils._old_port_manager._os_ops is os_ops |
276 | 281 | return PortManager__ThisHost.get_single_instance() |
277 | 282 |
|
278 | 283 | # TODO: Throw the exception "Please define a port manager." ? |
@@ -816,10 +821,13 @@ def init(self, initdb_params=None, cached=True, **kwargs): |
816 | 821 | """ |
817 | 822 |
|
818 | 823 | # initialize this PostgreSQL node |
| 824 | + assert self._os_ops is not None |
| 825 | + assert isinstance(self._os_ops, OsOperations) |
| 826 | + |
819 | 827 | cached_initdb( |
820 | 828 | data_dir=self.data_dir, |
821 | 829 | logfile=self.utils_log_file, |
822 | | - os_ops=self.os_ops, |
| 830 | + os_ops=self._os_ops, |
823 | 831 | params=initdb_params, |
824 | 832 | bin_path=self.bin_dir, |
825 | 833 | cached=False) |
@@ -2186,7 +2194,14 @@ def _escape_config_value(value): |
2186 | 2194 |
|
2187 | 2195 | class NodeApp: |
2188 | 2196 |
|
2189 | | - def __init__(self, test_path=None, nodes_to_cleanup=None, os_ops=LocalOperations()): |
| 2197 | + def __init__(self, test_path=None, nodes_to_cleanup=None, os_ops=None): |
| 2198 | + assert os_ops is None or isinstance(os_ops, OsOperations) |
| 2199 | + |
| 2200 | + if os_ops is None: |
| 2201 | + os_ops = LocalOperations.get_single_instance() |
| 2202 | + |
| 2203 | + assert isinstance(os_ops, OsOperations) |
| 2204 | + |
2190 | 2205 | if test_path: |
2191 | 2206 | if os.path.isabs(test_path): |
2192 | 2207 | self.test_path = test_path |
|
0 commit comments