Skip to content

Commit 7eba6f3

Browse files
committedMar 18, 2020
[Issue #174] added new test: tests.archive.ArchiveTest.test_archive_push_sanity
1 parent 8705a6f commit 7eba6f3

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed
 

‎tests/archive.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,6 +1832,79 @@ def test_archiving_and_slots(self):
18321832
# Clean after yourself
18331833
self.del_test_dir(module_name, fname)
18341834

1835+
def test_archive_push_sanity(self):
1836+
""""""
1837+
fname = self.id().split('.')[3]
1838+
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
1839+
node = self.make_simple_node(
1840+
base_dir=os.path.join(module_name, fname, 'node'),
1841+
set_replication=True,
1842+
initdb_params=['--data-checksums'],
1843+
pg_options={
1844+
'archive_mode': 'on',
1845+
'archive_command': 'exit 1'})
1846+
1847+
self.init_pb(backup_dir)
1848+
self.add_instance(backup_dir, 'node', node)
1849+
1850+
node.slow_start()
1851+
1852+
node.pgbench_init(scale=50)
1853+
node.stop()
1854+
1855+
self.set_archiving(backup_dir, 'node', node)
1856+
os.remove(os.path.join(node.logs_dir, 'postgresql.log'))
1857+
node.slow_start()
1858+
1859+
self.backup_node(backup_dir, 'node', node)
1860+
1861+
with open(os.path.join(node.logs_dir, 'postgresql.log'), 'r') as f:
1862+
postgres_log_content = f.read()
1863+
1864+
# print(postgres_log_content)
1865+
# make sure that .backup file is not compressed
1866+
self.assertNotIn('.backup.gz', postgres_log_content)
1867+
self.assertNotIn('WARNING', postgres_log_content)
1868+
1869+
replica = self.make_simple_node(
1870+
base_dir=os.path.join(module_name, fname, 'replica'))
1871+
replica.cleanup()
1872+
1873+
self.restore_node(
1874+
backup_dir, 'node', replica,
1875+
data_dir=replica.data_dir, options=['-R'])
1876+
1877+
#self.set_archiving(backup_dir, 'replica', replica, replica=True)
1878+
self.set_auto_conf(replica, {'port': replica.port})
1879+
self.set_auto_conf(replica, {'archive_mode': 'always'})
1880+
self.set_auto_conf(replica, {'hot_standby': 'on'})
1881+
replica.slow_start(replica=True)
1882+
1883+
self.wait_until_replica_catch_with_master(node, replica)
1884+
1885+
node.pgbench_init(scale=5)
1886+
1887+
replica.promote()
1888+
replica.pgbench_init(scale=10)
1889+
1890+
with open(os.path.join(replica.logs_dir, 'postgresql.log'), 'r') as f:
1891+
replica_log_content = f.read()
1892+
1893+
# make sure that .partial file is not compressed
1894+
self.assertNotIn('.partial.gz', replica_log_content)
1895+
# make sure that .history file is not compressed
1896+
self.assertNotIn('.history.gz', replica_log_content)
1897+
self.assertNotIn('WARNING', replica_log_content)
1898+
1899+
output = self.show_archive(
1900+
backup_dir, 'node', as_json=False, as_text=True,
1901+
options=['--log-level-console=VERBOSE'])
1902+
1903+
self.assertNotIn('WARNING', output)
1904+
1905+
# Clean after yourself
1906+
self.del_test_dir(module_name, fname)
1907+
18351908
# TODO test with multiple not archived segments.
18361909

18371910
# important - switchpoint may be NullOffset LSN and not actually existing in archive to boot.

0 commit comments

Comments
 (0)
Please sign in to comment.