diff --git a/src/allmydata/test/no_network.py b/src/allmydata/test/no_network.py index 7c9049192..8dd9a2f95 100644 --- a/src/allmydata/test/no_network.py +++ b/src/allmydata/test/no_network.py @@ -13,7 +13,7 @@ # Tubs, so it is not useful for tests that involve a Helper, a KeyGenerator, # or the control.furl . -import os.path +import os from zope.interface import implements from twisted.application import service from twisted.internet import defer, reactor @@ -401,6 +401,12 @@ class GridTestMixin: if i_shnum in shnums: os.unlink(i_sharefile) + def delete_all_shares(self, serverdir): + sharedir = os.path.join(serverdir, "shares") + for prefixdir in os.listdir(sharedir): + if prefixdir != 'incoming': + fileutil.rm_dir(os.path.join(sharedir, prefixdir)) + def corrupt_share(self, (shnum, serverid, sharefile), corruptor_function): sharedata = open(sharefile, "rb").read() corruptdata = corruptor_function(sharedata) diff --git a/src/allmydata/test/test_upload.py b/src/allmydata/test/test_upload.py index c0ec2468f..090fa3bbe 100644 --- a/src/allmydata/test/test_upload.py +++ b/src/allmydata/test/test_upload.py @@ -1887,11 +1887,7 @@ class EncodingParameters(GridTestMixin, unittest.TestCase, SetDEPMixin, self._add_server_with_share(server_number=3, share_number=1) # Copy shares self._copy_share_to_server(3, 1) - storedir = self.get_serverdir(0) - # remove the storedir, wiping out any existing shares - shutil.rmtree(storedir) - # create an empty storedir to replace the one we just removed - os.mkdir(storedir) + self.delete_all_shares(self.get_serverdir(0)) client = self.g.clients[0] client.encoding_params['happy'] = 4 return client @@ -1928,11 +1924,8 @@ class EncodingParameters(GridTestMixin, unittest.TestCase, SetDEPMixin, self._add_server_with_share(server_number=3, share_number=1) # Copy shares self._copy_share_to_server(3, 1) - storedir = self.get_serverdir(0) - # remove the storedir, wiping out any existing shares - shutil.rmtree(storedir) - # create an empty storedir to replace the one we just removed - os.mkdir(storedir) + #Remove shares from server 0 + self.delete_all_shares(self.get_serverdir(0)) client = self.g.clients[0] client.encoding_params['happy'] = 4 return client