(cls)
| 466 | |
| 467 | @classmethod |
| 468 | def setup_cluster(cls): |
| 469 | cls.master_cluster = cls.new_cluster(pg_cluster.TempCluster) |
| 470 | cls.start_cluster( |
| 471 | cls.master_cluster, |
| 472 | server_settings={ |
| 473 | 'max_wal_senders': 10, |
| 474 | 'wal_level': 'hot_standby' |
| 475 | } |
| 476 | ) |
| 477 | |
| 478 | con = None |
| 479 | |
| 480 | try: |
| 481 | con = cls.loop.run_until_complete( |
| 482 | cls.master_cluster.connect( |
| 483 | database='postgres', user='postgres', loop=cls.loop)) |
| 484 | |
| 485 | cls.loop.run_until_complete( |
| 486 | con.execute(''' |
| 487 | CREATE ROLE replication WITH LOGIN REPLICATION |
| 488 | ''')) |
| 489 | |
| 490 | cls.master_cluster.trust_local_replication_by('replication') |
| 491 | |
| 492 | conn_spec = cls.master_cluster.get_connection_spec() |
| 493 | |
| 494 | cls.standby_cluster = cls.new_cluster( |
| 495 | pg_cluster.HotStandbyCluster, |
| 496 | cluster_kwargs={ |
| 497 | 'master': conn_spec, |
| 498 | 'replication_user': 'replication' |
| 499 | } |
| 500 | ) |
| 501 | cls.start_cluster( |
| 502 | cls.standby_cluster, |
| 503 | server_settings={ |
| 504 | 'hot_standby': True |
| 505 | } |
| 506 | ) |
| 507 | |
| 508 | finally: |
| 509 | if con is not None: |
| 510 | cls.loop.run_until_complete(con.close()) |
| 511 | |
| 512 | @classmethod |
| 513 | def get_cluster_connection_spec(cls, cluster, kwargs={}): |
nothing calls this directly
no test coverage detected