← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1494021] Re: tests.unit.quota.test_resource can randomly fail

 

** Changed in: neutron
       Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1494021

Title:
  tests.unit.quota.test_resource can randomly fail

Status in neutron:
  Fix Released

Bug description:
  The TestTrackedResource class is designed to inject random failures
  into the gate.  It generates random numbers within the range of
  0..10000, and will fail if it generates duplicate random numbers
  during its run.

  class TestTrackedResource(testlib_api.SqlTestCaseLight):
      def _add_data(self, tenant_id=None):
           session = db_api.get_session()
           with session.begin():
               tenant_id = tenant_id or self.tenant_id
              session.add(test_quota.MehModel(
                  meh='meh_%d' % random.randint(0, 10000),
                  tenant_id=tenant_id))
              session.add(test_quota.MehModel(
                  meh='meh_%d' % random.randint(0, 10000),
                  tenant_id=tenant_id))


   Because the test repeatedly calls _add_data(), if the calls to
  randint() ever generate the same number during a test, it will fail.
  Aggregated over hundreds, or sometimes thousands, of test runs per
  day, I would estimate that this could cause several  unnecessary
  check/gate failures in a busy day.

  I propose changing random.randint() to uuid.uuid4(), which gives us a
  much larger random number space and a much smaller probability of
  collision.

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1494021/+subscriptions


References