]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
create_resource should return maximum length str
authorJohn Schwarz <jschwarz@redhat.com>
Thu, 2 Apr 2015 15:17:03 +0000 (18:17 +0300)
committerJohn Schwarz <jschwarz@redhat.com>
Tue, 14 Apr 2015 12:39:07 +0000 (15:39 +0300)
commit833ce26860c93bc8efb446a247c916d638a040ef
tree48ec905e009f130a362295dda27b08fd85ee107e
parentef53ce40dfde24dfedf70e1601b8ae8886247a72
create_resource should return maximum length str

Previously, get_rand_name(max_length, prefix) returned a randomized
suffix integer which was concatenated to the end of the given prefix.
Effectively, the suffix was any decimal number between 1 and
0x7fffffff, so multiple calls to the function could return strings with
different length. This is unexpected since running an already
randomized name into the same function shouldn't return a different
string.

The suggested solution is to actually fill all the space needed until
the string is 'max_length' in size. Also, a check is added to
create_resource to make sure that it only generates a new port name if
the input prefix is less than the maximum device name and if the prefix
is long enough, don't generate a random port suffix.

Change-Id: I0d5a20c676f627bce2a377e3c451043150ca734c
neutron/tests/base.py
neutron/tests/common/base.py