From 262485bd14caefaf286dda8639d6d262595c42f4 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Mon, 18 Mar 2019 16:35:42 -0400 Subject: [PATCH] add a test for the conflict behavior --- integration/test_magic_folder.py | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/integration/test_magic_folder.py b/integration/test_magic_folder.py index 02f7b770a..8ae93cdbf 100644 --- a/integration/test_magic_folder.py +++ b/integration/test_magic_folder.py @@ -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 + ), + )