From a557d44877ebf656673220d8e11576abbda4c6cc Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@allmydata.com>
Date: Tue, 22 Apr 2008 18:53:20 -0700
Subject: [PATCH] test_mutable: test that all servers refusing our share means
 a publish fails

---
 src/allmydata/test/test_mutable.py | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/allmydata/test/test_mutable.py b/src/allmydata/test/test_mutable.py
index 98712070..26a708d5 100644
--- a/src/allmydata/test/test_mutable.py
+++ b/src/allmydata/test/test_mutable.py
@@ -18,7 +18,8 @@ import sha
 from allmydata.mutable.node import MutableFileNode, BackoffAgent
 from allmydata.mutable.common import DictOfSets, ResponseCache, \
      MODE_CHECK, MODE_ANYTHING, MODE_WRITE, MODE_READ, \
-     NeedMoreDataError, UnrecoverableFileError, UncoordinatedWriteError
+     NeedMoreDataError, UnrecoverableFileError, UncoordinatedWriteError, \
+     NotEnoughServersError
 from allmydata.mutable.retrieve import Retrieve
 from allmydata.mutable.publish import Publish
 from allmydata.mutable.servermap import ServerMap, ServermapUpdater
@@ -1515,6 +1516,18 @@ class Problems(unittest.TestCase, testutil.ShouldFailMixin):
         d.addCallback(lambda res: self.failUnlessEqual(res, "contents 2"))
         return d
 
+    def test_publish_all_servers_bad(self):
+        # Break all servers: the publish should fail
+        basedir = os.path.join("mutable/CollidingWrites/publish_all_servers_bad")
+        self.client = LessFakeClient(basedir, 20)
+        for connection in self.client._connections.values():
+            connection.broken = True
+        d = self.shouldFail(NotEnoughServersError,
+                            "test_publish_all_servers_bad",
+                            "Ran out of non-bad servers",
+                            self.client.create_mutable_file, "contents")
+        return d
+
     def test_privkey_query_error(self):
         # when a servermap is updated with MODE_WRITE, it tries to get the
         # privkey. Something might go wrong during this query attempt.
@@ -1583,4 +1596,3 @@ class Problems(unittest.TestCase, testutil.ShouldFailMixin):
             return res
         d.addBoth(_cancel_timer)
         return d
-
-- 
2.45.2