MCPcopy Create free account
hub / github.com/wal-e/wal-e / test_backup_push_fetch

Function test_backup_push_fetch

tests/test_blackbox.py:101–140  ·  view source on GitHub ↗
(tmpdir, small_push_dir, monkeypatch, config,
                           noop_pg_backup_statements)

Source from the content-addressed store, hash-verified

99
100
101def test_backup_push_fetch(tmpdir, small_push_dir, monkeypatch, config,
102 noop_pg_backup_statements):
103 import wal_e.tar_partition
104
105 # check that _fsync_files() is called with the right
106 # arguments. There's a separate unit test in test_tar_hacks.py
107 # that it actually fsyncs the right files.
108 fsynced_files = []
109 monkeypatch.setattr(wal_e.tar_partition, '_fsync_files',
110 lambda filenames: fsynced_files.extend(filenames))
111
112 config.main('backup-push', str(small_push_dir))
113
114 fetch_dir = tmpdir.join('fetch-to').ensure(dir=True)
115
116 # Spin around backup-fetch LATEST for a while to paper over race
117 # conditions whereby a backup may not be visible to backup-fetch
118 # immediately.
119 from boto import exception
120 start = datetime.datetime.now()
121 deadline = start + datetime.timedelta(seconds=15)
122 while True:
123 try:
124 config.main('backup-fetch', str(fetch_dir), 'LATEST')
125 except exception.S3ResponseError:
126 if datetime.datetime.now() > deadline:
127 raise
128 else:
129 continue
130 else:
131 break
132
133 assert fetch_dir.join('arbitrary-file').read() == \
134 small_push_dir.join('arbitrary-file').read()
135
136 for filename in fetch_dir.listdir():
137 if filename.check(link=0):
138 assert str(filename) in fsynced_files
139 elif filename.check(link=1):
140 assert str(filename) not in fsynced_files
141
142
143def test_delete_everything(config, small_push_dir, noop_pg_backup_statements):

Callers

nothing calls this directly

Calls 3

mainMethod · 0.45
joinMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected