Random unit test inputs are not random across test runs

Bug #1639755 reported by Alistair Coles
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Fix Released
Low
Unassigned

Bug Description

Unit tests use the random module in places to randomise test inputs, but once the tests in test_builder.py or test_ring_builder_analyzer.py have been run the random seed is left in a repeatable state because calls are made to RingBuilder.balance with a seed value. Consequently, subsequent calls to random in other tests get repeatable results from one test run to another.

I proposed a fix [1] to reset the seed value, but it revealed some intermittently failing tests in test_builder.py - I suspect those tests are relying on non-random input :/ If someone wants to figure that out then please add to my patch.

[1] https://review.openstack.org/#/c/371564/

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (master)

Reviewed: https://review.openstack.org/371564
Committed: https://git.openstack.org/cgit/openstack/swift/commit/?id=7fa9d6e5b4fb74ad95f059742d8844e7c12fa235
Submitter: Jenkins
Branch: master

commit 7fa9d6e5b4fb74ad95f059742d8844e7c12fa235
Author: Alistair Coles <email address hidden>
Date: Fri Sep 16 14:31:44 2016 +0100

    Unset random seed after rebalancing ring

    Unit tests use the random module in places to randomise
    test inputs, but once the tests in test_builder.py or
    test_ring_builder_analyzer.py have been run the random
    seed is left in a repeatable state because calls are made
    to RingBuilder.balance with a seed value. Consequently,
    subsequent calls to random in other tests get repeatable
    results from one test run to another.

    This patch resets the state of the random module before
    returning from RingBuilder.rebalance.

    Closes-Bug: #1639755
    Change-Id: I4b74030afc654e60452e65b3e0f1b45a189c16e3

Changed in swift:
status: New → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/swift 2.15.1

This issue was fixed in the openstack/swift 2.15.1 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.