From 2e15c9aed2d03b7eca803c30c5d471882821567e Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@allmydata.com>
Date: Tue, 17 Apr 2007 13:40:47 -0700
Subject: [PATCH] system_test: exercise multiple segments

---
 src/allmydata/test/test_system.py | 11 +++++++++--
 src/allmydata/upload.py           | 12 ++++++------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py
index 0a92d407..b1fc0be6 100644
--- a/src/allmydata/test/test_system.py
+++ b/src/allmydata/test/test_system.py
@@ -116,12 +116,19 @@ class SystemTest(unittest.TestCase):
 
     def test_upload_and_download(self):
         self.basedir = "test_system/SystemTest/test_upload_and_download"
-        DATA = "Some data to upload\n"
+        # we use 4000 bytes of data, which will result in about 400k written
+        # to disk among all our simulated nodes
+        DATA = "Some data to upload\n" * 200
         d = self.set_up_nodes()
         def _do_upload(res):
             log.msg("UPLOADING")
             u = self.clients[0].getServiceNamed("uploader")
-            d1 = u.upload_data(DATA)
+            # we crank the max segsize down to 1024b for the duration of this
+            # test, so we can exercise multiple segments. It is important
+            # that this is not a multiple of the segment size, so that the
+            # tail segment is not the same length as the others.
+            options = {"max_segment_size": 1024}
+            d1 = u.upload_data(DATA, options)
             return d1
         d.addCallback(_do_upload)
         def _upload_done(uri):
diff --git a/src/allmydata/upload.py b/src/allmydata/upload.py
index 8a65fc43..ca5c72f5 100644
--- a/src/allmydata/upload.py
+++ b/src/allmydata/upload.py
@@ -309,9 +309,9 @@ class Uploader(service.MultiService):
         return d
 
     # utility functions
-    def upload_data(self, data):
-        return self.upload(Data(data))
-    def upload_filename(self, filename):
-        return self.upload(FileName(filename))
-    def upload_filehandle(self, filehandle):
-        return self.upload(FileHandle(filehandle))
+    def upload_data(self, data, options={}):
+        return self.upload(Data(data), options)
+    def upload_filename(self, filename, options={}):
+        return self.upload(FileName(filename), options)
+    def upload_filehandle(self, filehandle, options={}):
+        return self.upload(FileHandle(filehandle), options)
-- 
2.45.2