From 811d597cd884e104e6ede172a4c828f381624a5a Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Mon, 14 Mar 2016 16:15:40 +0000 Subject: [PATCH] Add WIP test_download_retry. Signed-off-by: Daira Hopwood --- src/allmydata/test/test_magic_folder.py | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/allmydata/test/test_magic_folder.py b/src/allmydata/test/test_magic_folder.py index 8dd0687ed..98f3b90d7 100644 --- a/src/allmydata/test/test_magic_folder.py +++ b/src/allmydata/test/test_magic_folder.py @@ -462,6 +462,36 @@ class MagicFolderAliceBobTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, Rea yield self._check_version_in_dmd(self.alice_magicfolder, u"blam", 1) self._check_version_in_local_db(self.alice_magicfolder, u"blam", 1) + @defer.inlineCallbacks + def test_download_retry(self): + alice_fname = os.path.join(self.alice_magic_dir, 'blam') + bob_fname = os.path.join(self.bob_magic_dir, 'blam') + + # alice creates a file, bob downloads it + fileutil.write(alice_fname, 'contents0\n') + yield self.notify(to_filepath(alice_fname), self.inotify.IN_CLOSE_WRITE, magic=self.alice_magicfolder) + + yield iterate(self.alice_magicfolder) + + for server_id in self.g.get_all_serverids(): + self.g.break_server(server_id, count=1) + yield iterate(self.bob_magicfolder) + #yield iterate(self.bob_magicfolder) + + # check the state + yield self._check_version_in_dmd(self.alice_magicfolder, u"blam", 0) + self._check_version_in_local_db(self.alice_magicfolder, u"blam", 0) + yield self._check_version_in_dmd(self.bob_magicfolder, u"blam", 0) + self._check_version_in_local_db(self.bob_magicfolder, u"blam", 0) + self.failUnlessReallyEqual( + self._get_count('downloader.objects_failed', client=self.bob_magicfolder._client), + 0 + ) + self.failUnlessReallyEqual( + self._get_count('downloader.objects_downloaded', client=self.bob_magicfolder._client), + 1 + ) + @defer.inlineCallbacks def test_alice_delete_and_restore(self): alice_fname = os.path.join(self.alice_magic_dir, 'blam')