[openstack-dev] [oslo] Propose support generate IPv4 and IPv6 random address( or network) for documentation(test?)

Joshua Harlow harlowja at fastmail.com
Tue Oct 18 15:52:40 UTC 2016


Ihar Hrachyshka wrote:
> In Neutron, we have a need to allocate random but unique addresses and
> such. For that matter, we have a concept of exclusive resources:
> https://github.com/openstack/neutron/tree/master/neutron/tests/common/exclusive_resources
> that are relying on locks and shared file based resource allocation
> storage. This is used in fullstack tests where all allocation is limited
> to a single node.
>
> Another place where we randomize addresses is in our NeutronObject tests
> where we just want to generate values good enough to pass
> oslo.versionedobjects fields constraints:
> https://github.com/openstack/neutron/blob/master/neutron/tests/unit/objects/test_base.py#L494
> We have some hacks there to guarantee uniqueness where may be needed
> (f.e. in case of lists of ip networks), but otherwise it’s just random
> addresses. It’s good enough for unit tests because each test has its own
> testing environment isolated from others.
>
> Ihar
>

Ok good/interesting to know, if a test fails and someone wants to 
reproduce it 'at home' what's the recommended way to do that if these 
are all randomized (and the source of the failure say is in one of these 
randomized data 'using' tests)

Do you output the random number gen seed (this seems like it would work, 
although a little PITA) so that people can use the same initially seed 
(and then get the same random numbers as a result)?

-Josh





More information about the OpenStack-dev mailing list