unittest test_basic_report fail because negative thread id

Bug #1264906 reported by ZhiQiang Fan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo-incubator
Fix Released
Undecided
ZhiQiang Fan

Bug Description

I'm not sure is this a bug, since all tests in gate are ok, but this problem occurs both in my notebook and pc.

OS: ubuntu 12.04

tox -epy27 install dependency sucessfully, and only fail on this test.
Ran 1132 tests in 68.032s (-0.524s)
FAILED (id=1, failures=2, skips=14)

$ tox -epy27 -- test_guru_meditation_report
FAIL: unit.reports.test_guru_meditation_report.TestGuruMeditationReport.test_basic_report
tags: worker-0
----------------------------------------------------------------------
Empty attachments:
  pythonlogging:'openstack.common'
  stderr
  stdout

Traceback (most recent call last):
  File "/home/zqfan/openstack/oslo-incubator/tests/unit/reports/test_guru_meditation_report.py", line 86, in test_basic_report
    report_lines[len(target_str_header)]))
  File "/usr/lib/python2.7/unittest/case.py", line 420, in assertTrue
    raise self.failureException(msg)
AssertionError: None is not true

After insert `print(report_lines[len(target_str_header)], file=sys.stderr)` in front of line 86:
$ tox -epy27 -- test_guru_meditation_report
FAIL: unit.reports.test_guru_meditation_report.TestGuruMeditationReport.test_basic_report
tags: worker-0
----------------------------------------------------------------------
Empty attachments:
  pythonlogging:'openstack.common'
  stdout

stderr: {{{------ Thread #-1221338368 ------}}}

Traceback (most recent call last):
  File "/home/zqfan/openstack/oslo-incubator/tests/unit/reports/test_guru_meditation_report.py", line 87, in test_basic_report
    report_lines[len(target_str_header)]))
  File "/usr/lib/python2.7/unittest/case.py", line 420, in assertTrue
    raise self.failureException(msg)
AssertionError: None is not true

Fix in line 86:
self.assertTrue(re.match(r'------(\s+)Thread #-?\d+\1\s?------',
                                 report_lines[len(target_str_header)]))
$ tox -epy27 -- test_guru_meditation_report
  py27: commands succeeded
  congratulations :)

In openstack/common/report/generators/threading.py:L44, sys._current_frames() return a negative thread_id, but I couldn't locate the original error location, so I report this and provide a temp fix.

ZhiQiang Fan (aji-zqfan)
Changed in oslo:
assignee: nobody → ZhiQiang Fan (aji-zqfan)
ZhiQiang Fan (aji-zqfan)
description: updated
Revision history for this message
ZhiQiang Fan (aji-zqfan) wrote :

Tested in 64 bit OS, sys._current_frames() will return a very large thread id which exceeds max value of 32bit int.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo-incubator (master)

Fix proposed to branch: master
Review: https://review.openstack.org/64385

Changed in oslo:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo-incubator (master)

Reviewed: https://review.openstack.org/64385
Committed: https://git.openstack.org/cgit/openstack/oslo-incubator/commit/?id=c6a6fa75b876b0f42cfcf28d170ba711f30b4962
Submitter: Jenkins
Branch: master

commit c6a6fa75b876b0f42cfcf28d170ba711f30b4962
Author: ZhiQiang Fan <email address hidden>
Date: Mon Dec 30 10:30:22 2013 +0800

    Avoid failure of test_basic_report on 32 bit OS

    report.generators.threading module uses sys._current_frames() to
    get thread id, but it will get a negative number on 32 bit operating
    system, which will cause test_guru_meditation_report.test_basic_report
    fail since it expects a positive number.

    This patch add an optional character '-' to pattern parameter of
    re.match to avoid such problem.

    Change-Id: If844894dc1f1032c78d6ed78d221aac27c42712e
    Closes-Bug: #1264906

Changed in oslo:
status: In Progress → Fix Committed
Changed in oslo:
milestone: none → icehouse-3
Thierry Carrez (ttx)
Changed in oslo:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in oslo:
milestone: icehouse-3 → 2014.1
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.