UT error in test_glance

Bug #1757928 reported by Jianghua Wang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
os-xenapi
Fix Released
Medium
Jianghua Wang

Bug Description

I met randomly UT failure within test_glance:

Successful log: http://logs.openstack.org/43/554543/1/check/openstack-tox-py27/91a2404/

Failed log:
http://logs.openstack.org/43/554543/1/gate/openstack-tox-py27/6883f53/job-output.txt.gz

2018-03-21 10:39:37.989937 | ubuntu-xenial | ======================================================================
2018-03-21 10:39:37.990087 | ubuntu-xenial | FAIL: os_xenapi.tests.plugins.test_glance.GlanceTestCase.test_download_ok_extract_failed
2018-03-21 10:39:37.990132 | ubuntu-xenial | tags: worker-3
2018-03-21 10:39:37.990239 | ubuntu-xenial | ----------------------------------------------------------------------
2018-03-21 10:39:37.990301 | ubuntu-xenial | Traceback (most recent call last):
2018-03-21 10:39:37.990520 | ubuntu-xenial | File "/home/zuul/src/git.openstack.org/openstack/os-xenapi/.tox/py27/local/lib/python2.7/site-packages/mock/mock.py", line 1305, in patched
2018-03-21 10:39:37.990592 | ubuntu-xenial | return func(*args, **keywargs)
2018-03-21 10:39:37.990755 | ubuntu-xenial | File "os_xenapi/tests/plugins/test_glance.py", line 121, in test_download_ok_extract_failed
2018-03-21 10:39:37.990837 | ubuntu-xenial | mock_extract_tarball.assert_called_once()
2018-03-21 10:39:37.991063 | ubuntu-xenial | File "/home/zuul/src/git.openstack.org/openstack/os-xenapi/.tox/py27/local/lib/python2.7/site-packages/mock/mock.py", line 915, in assert_called_once
2018-03-21 10:39:37.991124 | ubuntu-xenial | raise AssertionError(msg)
2018-03-21 10:39:37.991248 | ubuntu-xenial | AssertionError: Expected 'extract_tarball' to have been called once. Called 0 times.
2018-03-21 10:39:37.991297 | ubuntu-xenial | Ran 269 tests in 1.263s
2018-03-21 10:39:37.991347 | ubuntu-xenial | FAILED (id=0, failures=1)

Revision history for this message
Jianghua Wang (wjh-fresh) wrote :

It's easy to reproduce this problem with master branch also.
With some debug. I think it's due to the mock on urlopen doesn't take effective sometime (not sure why it does work sometime).

Successful#####
time: 2018-03-22 03:10:23.251676Z
tags: worker-3
test: os_xenapi.tests.plugins.test_glance.GlanceTestCase.test_download_ok_extract_failed
time: 2018-03-22 03:10:23.260027Z
successful: os_xenapi.tests.plugins.test_glance.GlanceTestCase.test_download_ok_extract_failed [ multipart
Content-Type: text/plain;charset=utf8
stdout
90^M
wjh: calling utils.extract_tarball
wjh: finally
error is 'fake_cmd' returned non-zero exit code: retcode=0, out='fake_out', stderr='fake_stderr'0^M
]

## failed####
test: os_xenapi.tests.plugins.test_glance.GlanceTestCase.test_download_ok_extract_failed
time: 2018-03-22 03:07:50.162910Z
failure: os_xenapi.tests.plugins.test_glance.GlanceTestCase.test_download_ok_extract_failed [ multipart
Content-Type: text/plain;charset=utf8
stdout
1D^M
error is <urlopen error None>0^M
Content-Type: text/x-traceback;language=python,charset=utf8
traceback
215^M
Traceback (most recent call last):
  File "/root/os-xenapi/.tox/py27/lib/python2.7/site-packages/mock/mock.py", line 1305, in patched
    return func(*args, **keywargs)
  File "os_xenapi/tests/plugins/test_glance.py", line 126, in test_download_ok_extract_failed
    mock_extract_tarball.assert_called_once()
  File "/root/os-xenapi/.tox/py27/lib/python2.7/site-packages/mock/mock.py", line 915, in assert_called_once
    raise AssertionError(msg)
AssertionError: Expected 'extract_tarball' to have been called once. Called 0 times.
0^M
]

Changed in os-xenapi:
importance: Undecided → Medium
status: New → Confirmed
assignee: nobody → Jianghua Wang (wjh-fresh)
description: updated
Revision history for this message
Jianghua Wang (wjh-fresh) wrote :

I guess we've got this issue since this change: https://review.openstack.org/#/c/544809/2/os_xenapi/dom0/etc/xapi.d/plugins/glance.py@77

which change the module to making the code compatible with both py2 and py3.

We need change the UT script to use import the same modules, so that the mocks can take effective exactly.

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

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

Changed in os-xenapi:
status: Confirmed → In Progress
Revision history for this message
Jianghua Wang (wjh-fresh) wrote :

It's to be fixed by this patch:
https://review.openstack.org/#/c/555145

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to os-xenapi (master)

Reviewed: https://review.openstack.org/555145
Committed: https://git.openstack.org/cgit/openstack/os-xenapi/commit/?id=4e26270ea83d66c37ffeea75fc2064e27f41c0c2
Submitter: Zuul
Branch: master

commit 4e26270ea83d66c37ffeea75fc2064e27f41c0c2
Author: Jianghua Wang <email address hidden>
Date: Thu Mar 22 03:48:26 2018 +0000

    Fix random failures in test_glance

    We had some change in source code (glance.py) to make os-xenapi
    be compitable with both py2 and py3. But the modules in the UT
    have not been changed accordingly. So some mocks on module's
    method don't take effective.
    This commit is to fix the failures in test_glance.

    Change-Id: I42cbe4f5dc5cec5d28394b9502196ff9c9bb8761
    Closes-Bug: 1757928

Changed in os-xenapi:
status: In Progress → Fix Released
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.