From bd40f23d7db947b83033a85a1385cf29496be517 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Tue, 24 Feb 2015 09:25:14 -0500 Subject: [PATCH] tests: speed up Python RBD random data generation 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 --- src/test/pybind/test_rbd.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/test/pybind/test_rbd.py b/src/test/pybind/test_rbd.py index 5d61d5322329..4be09085b5c2 100644 --- a/src/test/pybind/test_rbd.py +++ b/src/test/pybind/test_rbd.py @@ -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 -- 2.47.3