]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: speed up Python RBD random data generation 3786/head
authorJason Dillaman <dillaman@redhat.com>
Tue, 24 Feb 2015 14:25:14 +0000 (09:25 -0500)
committerJason Dillaman <dillaman@redhat.com>
Tue, 24 Feb 2015 14:25:14 +0000 (09:25 -0500)
The RBD large_write test cases was taking multiple minutes to
run under a Fedora 21 VM.  Replaced the million+ random number
generator calls with a single call to os.urandom. The test
now completes within seconds.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/pybind/test_rbd.py

index 5d61d532232918835967b25989f92873c7e561e5..4be09085b5c22a779a40a7f9e435bdc9df23f62f 100644 (file)
@@ -1,6 +1,5 @@
 # vim: expandtab smarttab shiftwidth=4 softtabstop=4
 import functools
-import random
 import socket
 import struct
 import os
@@ -264,8 +263,7 @@ def test_rename():
     eq([image_name], rbd.list(ioctx))
 
 def rand_data(size):
-    l = [random.Random().getrandbits(64) for _ in xrange(size/8)]
-    return struct.pack((size/8)*'Q', *l)
+    return os.urandom(size)
 
 def check_stat(info, size, order):
     assert 'block_name_prefix' in info