From Dan Kenigsberg <danken(a)redhat.com>:
Dan Kenigsberg has posted comments on this change.
Change subject: python3: Fix UUID packing/unpacking on python 3
......................................................................
Patch Set 9:
(1 comment)
https://gerrit.ovirt.org/#/c/78632/9/tests/storage/misc_test.py
File tests/storage/misc_test.py:
Line 459: Test that the uuid that was packed can be unpacked without being
Line 460: changed
Line 461: """
Line 462: for i in range(1000):
Line 463: origUuid = str(uuid.uuid4())
We test here 1000 random uuids, better than small list of random
uuids. And
I have nothing against testing 1000 numbers. What I don't like is
surprises in tests.
Assume your test fails on a single random uuid on a single CI run by a single developer.
Nobody would notice. All they'd see is a fluke -1, and they'd re-trigger the job.
A safe approach is to have a predictable list of number. If we introduce a bug that makes
the test fail on one of them, it would keep on failing.
r = random.Random(42)
for _ in range(1000):
origUiid = str(uuid.UUID(int=r.randint(0, 2**128-1)))
...
it's not terribly important for this simple test, but I think that uncontrolled
randomness is a bad practice for testing, and it should be avoided.
Line 464: packedUuid = misc.packUuid(origUuid)
Line 465: self.assertEqual(misc.unpackUuid(packedUuid), origUuid)
Line 466:
Line 467:
--
To view, visit
https://gerrit.ovirt.org/78632
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I41cfa5e54e76dfcad267792daebc54e80bf2a022
Gerrit-PatchSet: 9
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: Adam Litke <alitke(a)redhat.com>
Gerrit-Reviewer: Ala Hino <ahino(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Freddy Rolland <frolland(a)redhat.com>
Gerrit-Reviewer: Irit Goihman <igoihman(a)redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Maor Lipchuk <mlipchuk(a)redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation(a)ovirt.org>
Gerrit-HasComments: Yes