mirror of
https://github.com/ceph/s3-tests.git
synced 2025-05-13 05:18:16 +00:00
Correctly generate non-mod 1024 parts in generator
Also move implementation to utils and add unit tests.
This commit is contained in:
parent
4a67f6c0f3
commit
ca2c0dc283
3 changed files with 33 additions and 20 deletions
|
@ -1,4 +1,6 @@
|
|||
import random
|
||||
import requests
|
||||
import string
|
||||
import time
|
||||
|
||||
from nose.tools import eq_ as eq
|
||||
|
@ -18,6 +20,25 @@ def assert_raises(excClass, callableObj, *args, **kwargs):
|
|||
excName = str(excClass)
|
||||
raise AssertionError("%s not raised" % excName)
|
||||
|
||||
def generate_random(size, part_size=5*1024*1024):
|
||||
"""
|
||||
Generate the specified number random data.
|
||||
(actually each MB is a repetition of the first KB)
|
||||
"""
|
||||
chunk = 1024
|
||||
allowed = string.ascii_letters
|
||||
for x in range(0, size, part_size):
|
||||
strpart = ''.join([allowed[random.randint(0, len(allowed) - 1)] for _ in xrange(chunk)])
|
||||
s = ''
|
||||
left = size - x
|
||||
this_part_size = min(left, part_size)
|
||||
for y in range(this_part_size / chunk):
|
||||
s = s + strpart
|
||||
s = s + strpart[:(this_part_size % chunk)]
|
||||
yield s
|
||||
if (x == size):
|
||||
return
|
||||
|
||||
# syncs all the regions except for the one passed in
|
||||
def region_sync_meta(targets, region):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue