Change in vdsm[master]: Test randomness when running under mock

nsoffer at redhat.com nsoffer at redhat.com
Tue Aug 4 14:42:37 UTC 2015


Nir Soffer has uploaded a new change for review.

Change subject: Test randomness when running under mock
......................................................................

Test randomness when running under mock

Add two tests that will always fail, showing random values generated by
random.randint() and os.urandom().

If we get different random values on each run, this it shows that we
don't need the randomness hack added in https://gerrit.ovirt.org/41079

Change-Id: I90fbc6cbc6ef9a9acbdc2964b92f1c4eb72df97d
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M tests/testlibTests.py
1 file changed, 9 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/56/44356/1

diff --git a/tests/testlibTests.py b/tests/testlibTests.py
index d631aaf..b2a6489 100644
--- a/tests/testlibTests.py
+++ b/tests/testlibTests.py
@@ -149,3 +149,12 @@
     def test_expanded_attributes(self):
         fn = getattr(self._Permutations, 'fn(False)')
         self.assertNotIn(PERMUTATION_ATTR, dir(fn))
+
+
+class TestRandomness(VdsmTestCase):
+    def test_randint(self):
+        import random
+        self.assertEqual([0] * 10, [random.randint(0, 1000) for _ in range(10)])
+    def test_urandom(self):
+        import os
+        self.assertEqual("0" * 20, os.urandom(10).encode('hex'))


-- 
To view, visit https://gerrit.ovirt.org/44356
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I90fbc6cbc6ef9a9acbdc2964b92f1c4eb72df97d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list