Failed unit test due to permission on /tmp/device_images

Bug #1911997 reported by Sabeel Ansari on 2021-01-15
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Al Bailey

Bug Description

Running unit test on local build server (cgts4) failed. Tox reports a unit test failure locally, and another user who had run tox previously owns the permissions to the target folder.

The source code writing to /tmp/device_images needs to be mocked using either a @mock.patch('os.makedirs') or similar calls.

It appears that the culprit is this line:

Captured pythonlogging:
    _host_upgrade_create system version=0.0
    None "POST /v1/device_images HTTP/1.0" status: 200 len: 0 time: 0.00612902641296 POST: NestedMultiDict([('pci_device', u'0b30'), ('bitstream_type', u'key-revocation'), ('pci_vendor', u'8086'), ('revoke_key_id', u'12345'), ('file', FieldStorage('file', u'/localdisk/designer/sansari/starlingx-0/cgcs-root/stx/config/sysinv/sysinv/sysinv/sysinv/tests/api/data/bitstream.bit'))]) host:localhost:80 agent:sysinv-test user: None tenant: None domain: None
    [Errno 13] Permission denied: '/tmp/device_images/key-revocation-8086-0b30-5ae6c262-5e03-4953-9a22-46e3595c1779.bit'
    Traceback (most recent call last):
      File "/tmp/sansari_sysinvtox/py27/lib/python2.7/site-packages/pecan/middleware/", line 78, in __call__
        return, start_response)
      File "/tmp/sansari_sysinvtox/py27/lib/python2.7/site-packages/pecan/middleware/", line 56, in __call__
        return self.application(environ, start_response)
      File "sysinv/api/middleware/", line 70, in __call__
        app_iter =, replacement_start_response)
      File "/tmp/sansari_sysinvtox/py27/lib/python2.7/site-packages/pecan/", line 840, in __call__
        return super(Pecan, self).__call__(environ, start_response)
      File "/tmp/sansari_sysinvtox/py27/lib/python2.7/site-packages/pecan/", line 683, in __call__
        self.invoke_controller(controller, args, kwargs, state)
      File "/tmp/sansari_sysinvtox/py27/lib/python2.7/site-packages/pecan/", line 574, in invoke_controller
        result = controller(*args, **kwargs)
      File "/tmp/sansari_sysinvtox/py27/lib/python2.7/site-packages/oslo_concurrency/", line 328, in inner
        return f(*args, **kwargs)
      File "sysinv/api/controllers/v1/", line 269, in post
    OSError: [Errno 13] Permission denied: '/tmp/device_images/key-revocation-8086-0b30-5ae6c262-5e03-4953-9a22-46e3595c1779.bit'

Ran: 1480 tests in 384.0000 sec.
 - Passed: 1449
 - Skipped: 28
 - Expected Fail: 0
 - Unexpected Success: 0
 - Failed: 3
Sum of execute time for each test: 15561.9743 sec.

Al Bailey (albailey1974) wrote :

The three tox unit tests that are failing are tests that invoke the device_images API and attempt to write to that folder.

The easiest way to reproduce this problem is to make an in-accessible (000 permissions) /tmp/device_images folder, and then run tox for sysinv for the tests that fail (tests.api.test_device_image)

mkdir /tmp/device_images
chmod 000 /tmp/device_images

cd $MY_REPO/stx/config/sysinv/sysinv/sysinv/
tox -e py27 -- tests.api.test_device_image

These are the three tests that fail:

Ghada Khalil (gkhalil) wrote :

Minor / low priority - issue w/ running tox on a shared server related to specific test-cases

Changed in starlingx:
importance: Undecided → Low
status: New → Triaged
tags: added: stx.config
Changed in starlingx:
assignee: nobody → Al Bailey (albailey1974)
Al Bailey (albailey1974) wrote :
Changed in starlingx:
status: Triaged → In Progress
Al Bailey (albailey1974) wrote :

This merged on Jan 26, 2021

Changed in starlingx:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers