Public bug reported:

In https://review.openstack.org/#/c/381890 we got the following failure:
| Captured traceback:
| ~~~~~~~~~~~~~~~~~~~
|     Traceback (most recent call last):
|       File 
"/home/jenkins/workspace/gate-cross-glance-python27-db-ubuntu-xenial/.tox/py27/local/lib/python2.7/site-packages/mock/mock.py",
 line 1305, in patched
|         return func(*args, **keywargs)
|       File "glance/tests/unit/v2/test_tasks_resource.py", line 367, in 
test_create_with_live_time
|         self.assertEqual(CONF.task.task_time_to_live, task_live_time_hour)
|       File 
"/home/jenkins/workspace/gate-cross-glance-python27-db-ubuntu-xenial/.tox/py27/local/lib/python2.7/site-packages/testtools/testcase.py",
 line 411, in assertEqual
|         self.assertThat(observed, matcher, message)
|       File 
"/home/jenkins/workspace/gate-cross-glance-python27-db-ubuntu-xenial/.tox/py27/local/lib/python2.7/site-packages/testtools/testcase.py",
 line 498, in assertThat
|         raise mismatch_error
|     testtools.matchers._impl.MismatchError: 48 != 47


This can happen if the exires_at and updated_at are not 2 days apart (ignoring 
seconds and microsecond) (from [2])

        # ignore second and microsecond to avoid flaky runs
        task_live_time = (success_task.expires_at.replace(second=0,
                                                          microsecond=0) -
                          success_task.updated_at.replace(second=0,
                                                          microsecond=0))

The following interactive example shows what I mean:

balder:glance tony8129$ python
Python 2.7.12 (default, Jun 29 2016, 12:46:54) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> class FakeTask(object):
...     pass
>>> success_task = FakeTask()
>>> success_task.expires_at = datetime.datetime(2016, 10, 3, 00, 00, 00)
>>> success_task.updated_at = datetime.datetime(2016, 10, 1, 00, 00, 00)
>>> task_live_time = (success_task.expires_at.replace(second=0,
>>>                                                   microsecond=0) -
...                   success_task.updated_at.replace(second=0,
...                                                   microsecond=0))
... task_live_time
>>> datetime.timedelta(2)
>>> success_task.updated_at = datetime.datetime(2016, 10, 1, 00, 01, 00)
>>> task_live_time = (success_task.expires_at.replace(second=0,
>>>                                                   microsecond=0) -
...                   success_task.updated_at.replace(second=0,
...                                                   microsecond=0))
... task_live_time
>>> datetime.timedelta(1, 86340)
task_live_time_hour = (task_live_time.days * 24 +
>>>                    task_live_time.seconds / 3600)
>>> task_live_time_hour
>>> 47

I couldn't find the specific code but I assume something like:
db.expires_at = now() + CONF.task.task_time_to_live #   mm:59
db_updated_at = now()                               # 1+mm:00

Happens causing this false positive.


[1] 
http://logs.openstack.org/90/381890/3/gate/gate-cross-glance-python27-db-ubuntu-xenial/1dff2a8/console.html#_2016-10-06_02_26_57_318997
[2] 
https://github.com/openstack/glance/blob/master/glance/tests/unit/v2/test_tasks_resource.py#L361-L364

** Affects: glance
     Importance: Undecided
         Status: New

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

Title:
  test_create_with_live_time can fail if run at "just the wrong time"

Status in Glance:
  New

Bug description:
  In https://review.openstack.org/#/c/381890 we got the following failure:
  | Captured traceback:
  | ~~~~~~~~~~~~~~~~~~~
  |     Traceback (most recent call last):
  |       File 
"/home/jenkins/workspace/gate-cross-glance-python27-db-ubuntu-xenial/.tox/py27/local/lib/python2.7/site-packages/mock/mock.py",
 line 1305, in patched
  |         return func(*args, **keywargs)
  |       File "glance/tests/unit/v2/test_tasks_resource.py", line 367, in 
test_create_with_live_time
  |         self.assertEqual(CONF.task.task_time_to_live, task_live_time_hour)
  |       File 
"/home/jenkins/workspace/gate-cross-glance-python27-db-ubuntu-xenial/.tox/py27/local/lib/python2.7/site-packages/testtools/testcase.py",
 line 411, in assertEqual
  |         self.assertThat(observed, matcher, message)
  |       File 
"/home/jenkins/workspace/gate-cross-glance-python27-db-ubuntu-xenial/.tox/py27/local/lib/python2.7/site-packages/testtools/testcase.py",
 line 498, in assertThat
  |         raise mismatch_error
  |     testtools.matchers._impl.MismatchError: 48 != 47

  
  This can happen if the exires_at and updated_at are not 2 days apart 
(ignoring seconds and microsecond) (from [2])

          # ignore second and microsecond to avoid flaky runs
          task_live_time = (success_task.expires_at.replace(second=0,
                                                            microsecond=0) -
                            success_task.updated_at.replace(second=0,
                                                            microsecond=0))

  The following interactive example shows what I mean:

  balder:glance tony8129$ python
  Python 2.7.12 (default, Jun 29 2016, 12:46:54) 
  [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import datetime
  >>> class FakeTask(object):
  ...     pass
  >>> success_task = FakeTask()
  >>> success_task.expires_at = datetime.datetime(2016, 10, 3, 00, 00, 00)
  >>> success_task.updated_at = datetime.datetime(2016, 10, 1, 00, 00, 00)
  >>> task_live_time = (success_task.expires_at.replace(second=0,
  >>>                                                   microsecond=0) -
  ...                   success_task.updated_at.replace(second=0,
  ...                                                   microsecond=0))
  ... task_live_time
  >>> datetime.timedelta(2)
  >>> success_task.updated_at = datetime.datetime(2016, 10, 1, 00, 01, 00)
  >>> task_live_time = (success_task.expires_at.replace(second=0,
  >>>                                                   microsecond=0) -
  ...                   success_task.updated_at.replace(second=0,
  ...                                                   microsecond=0))
  ... task_live_time
  >>> datetime.timedelta(1, 86340)
  task_live_time_hour = (task_live_time.days * 24 +
  >>>                    task_live_time.seconds / 3600)
  >>> task_live_time_hour
  >>> 47

  I couldn't find the specific code but I assume something like:
  db.expires_at = now() + CONF.task.task_time_to_live #   mm:59
  db_updated_at = now()                               # 1+mm:00

  Happens causing this false positive.

  
  [1] 
http://logs.openstack.org/90/381890/3/gate/gate-cross-glance-python27-db-ubuntu-xenial/1dff2a8/console.html#_2016-10-06_02_26_57_318997
  [2] 
https://github.com/openstack/glance/blob/master/glance/tests/unit/v2/test_tasks_resource.py#L361-L364

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

-- 
Mailing list: https://launchpad.net/~yahoo-eng-team
Post to     : yahoo-eng-team@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yahoo-eng-team
More help   : https://help.launchpad.net/ListHelp

Reply via email to