mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-21 22:07:51 +00:00
add a test for the conflict behavior
This commit is contained in:
parent
9bc00c4f76
commit
262485bd14
@ -395,3 +395,55 @@ def test_edmond_uploads_then_restarts(reactor, request, temp_dir, introducer_fur
|
||||
assert exists(join(magic_folder, "its_a_file"))
|
||||
assert not exists(join(magic_folder, "its_a_file.backup"))
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
@pytest_twisted.inlineCallbacks
|
||||
def test_alice_adds_files_while_bob_is_offline(reactor, request, temp_dir, magic_folder):
|
||||
"""
|
||||
Alice can add new files to a magic folder while Bob is offline. When Bob
|
||||
comes back online his copy is updated to reflect the new files.
|
||||
"""
|
||||
alice_magic_dir, bob_magic_dir = magic_folder
|
||||
alice_node_dir = join(temp_dir, "alice")
|
||||
bob_node_dir = join(temp_dir, "bob")
|
||||
|
||||
# Take Bob offline.
|
||||
yield util.cli(reactor, bob_node_dir, "stop")
|
||||
|
||||
# Create a couple files in Alice's local directory.
|
||||
some_files = ["foo", "bar", "baz"]
|
||||
for name in some_files:
|
||||
with open(join(alice_magic_dir, name), "w") as f:
|
||||
f.write(name + " some content")
|
||||
|
||||
while True:
|
||||
status = yield util.magic_folder_cli(reactor, alice_node_dir, "status")
|
||||
if status.count("good, version=0") == len(some_files) * 2:
|
||||
# We saw each file as having a local good state and a remote good
|
||||
# state. That means we're ready to involve Bob.
|
||||
break
|
||||
else:
|
||||
time.sleep(1.0)
|
||||
|
||||
# Start Bob up again
|
||||
magic_text = 'Completed initial Magic Folder scan successfully'
|
||||
yield util._run_node(reactor, bob_node_dir, request, magic_text)
|
||||
|
||||
yield util.await_files_exist(
|
||||
list(
|
||||
join(bob_magic_dir, name)
|
||||
for name
|
||||
in some_files
|
||||
),
|
||||
await_all=True,
|
||||
)
|
||||
# Let it settle.
|
||||
time.sleep(1.0)
|
||||
conflict_files = list(name + ".conflict" for name in some_files)
|
||||
assert all(
|
||||
list(
|
||||
not exists(join(bob_magic_dir, name))
|
||||
for name
|
||||
in conflict_files
|
||||
),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user