On python-tripleoclient the tests fail if running without root user.

Bug #1816446 reported by Natal Ngétal on 2019-02-18
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tripleo
Medium
Emilien Macchi

Bug Description

Currently the tests fail on master if running without root user, because we try to create a symlink on the system:

=========================
Failures during discovery
=========================
--- import errors ---
Failed to import test module: tripleoclient.tests.v1.tripleo.test_tripleo_deploy
Traceback (most recent call last):
  File "/home/hobbestigrou/python-tripleoclient/.tox/py27/lib/python2.7/site-packages/unittest2/loader.py", line 456, in _find_test_path
    module = self._get_module_from_name(name)
  File "/home/hobbestigrou/python-tripleoclient/.tox/py27/lib/python2.7/site-packages/unittest2/loader.py", line 395, in _get_module_from_name
    __import__(name)
  File "tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py", line 30, in <module>
    from tripleoclient.v1 import tripleo_deploy
  File "tripleoclient/v1/tripleo_deploy.py", line 92, in <module>
    class Deploy(command.Command):
  File "tripleoclient/v1/tripleo_deploy.py", line 119, in Deploy
    '/usr/local/bin/' + ansible_playbook_cmd)
OSError: [Errno 13] Permission denied

Failed to import test module: tripleoclient.tests.v1.tripleo.test_tripleo_upgrade
Traceback (most recent call last):
  File "/home/hobbestigrou/python-tripleoclient/.tox/py27/lib/python2.7/site-packages/unittest2/loader.py", line 456, in _find_test_path
    module = self._get_module_from_name(name)
  File "/home/hobbestigrou/python-tripleoclient/.tox/py27/lib/python2.7/site-packages/unittest2/loader.py", line 395, in _get_module_from_name
    __import__(name)
  File "tripleoclient/tests/v1/tripleo/test_tripleo_upgrade.py", line 24, in <module>
    from tripleoclient.v1 import tripleo_upgrade
  File "tripleoclient/v1/tripleo_upgrade.py", line 18, in <module>
    from tripleoclient.v1.tripleo_deploy import Deploy
  File "tripleoclient/v1/tripleo_deploy.py", line 92, in <module>
    class Deploy(command.Command):
  File "tripleoclient/v1/tripleo_deploy.py", line 119, in Deploy
    '/usr/local/bin/' + ansible_playbook_cmd)
OSError: [Errno 13] Permission denied

Failed to import test module: tripleoclient.tests.v1.undercloud.test_deploy
Traceback (most recent call last):
  File "/home/hobbestigrou/python-tripleoclient/.tox/py27/lib/python2.7/site-packages/unittest2/loader.py", line 456, in _find_test_path
    module = self._get_module_from_name(name)
  File "/home/hobbestigrou/python-tripleoclient/.tox/py27/lib/python2.7/site-packages/unittest2/loader.py", line 395, in _get_module_from_name
    __import__(name)
  File "tripleoclient/tests/v1/undercloud/test_deploy.py", line 21, in <module>
    from tripleoclient.v1 import undercloud_deploy
  File "tripleoclient/v1/undercloud_deploy.py", line 19, in <module>
    from tripleoclient.v1.tripleo_deploy import Deploy
  File "tripleoclient/v1/tripleo_deploy.py", line 92, in <module>
    class Deploy(command.Command):
  File "tripleoclient/v1/tripleo_deploy.py", line 119, in Deploy
    '/usr/local/bin/' + ansible_playbook_cmd)
OSError: [Errno 13] Permission denied

So the solution it's run a first time with root user to create the symlink, then tests can be run with normal user. A simple workaround is check the user is root before try create the symlink.

Changed in tripleo:
assignee: nobody → Natal Ngétal (hobbestigrou)

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

Changed in tripleo:
status: New → In Progress

Reviewed: https://review.openstack.org/637564
Committed: https://git.openstack.org/cgit/openstack/python-tripleoclient/commit/?id=03df1ffe750316b7c87161d6f3bf9d98cffe3ca5
Submitter: Zuul
Branch: master

commit 03df1ffe750316b7c87161d6f3bf9d98cffe3ca5
Author: Natal Ngétal <email address hidden>
Date: Mon Feb 18 16:08:12 2019 +0100

    Check if the user is root.

    Before try to create the symlink check if the user is root.

    Change-Id: I869c3e6a3eadaf33bdab2745635e9db23dfc8cbb
    Partial-Bug: #1816446

Changed in tripleo:
importance: Undecided → Medium

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

Changed in tripleo:
assignee: Natal Ngétal (hobbestigrou) → Cédric Jeanneret (cjeanner)
Changed in tripleo:
assignee: Cédric Jeanneret (cjeanner) → Natal Ngétal (hobbestigrou)
Changed in tripleo:
assignee: Natal Ngétal (hobbestigrou) → Cédric Jeanneret (cjeanner)

Change abandoned by Natal Ngétal (<email address hidden>) on branch: master
Review: https://review.openstack.org/638399
Reason: Integrate in another patch.

Changed in tripleo:
milestone: none → stein-3
Changed in tripleo:
assignee: Cédric Jeanneret (cjeanner) → Emilien Macchi (emilienm)

Reviewed: https://review.openstack.org/639077
Committed: https://git.openstack.org/cgit/openstack/python-tripleoclient/commit/?id=88d3dfd5e74ab738983d8d79b6a1b0eb88a9e167
Submitter: Zuul
Branch: master

commit 88d3dfd5e74ab738983d8d79b6a1b0eb88a9e167
Author: Cédric Jeanneret <email address hidden>
Date: Mon Feb 25 13:16:28 2019 +0100

    Ensure created symlink is in $PATH

    With "sudo", the $PATH is overriden an really basic:
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    It doesn't list the /usr/local/(s)bin, hence the created
    symlink wasn't seen by the script.

    It also push that symlink creation in the __new__ special
    method in order to make it cleaner.

    Finaly, it takes care of lint/pep8 failures, not related to
    this change (how is that even possible?!)

    Co-Authored-By: Natal Ngétal <email address hidden>
    Closes-Bug: 1817365
    Partial-Bug: 1816446

    Change-Id: If09eb32f43b2c26c8cd8a89f2e862db1dd91dfed

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

Other bug subscribers