cloudinit tests fail when running as root

Bug #1825027 reported by Anh Vo (MSFT)
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
Wishlist
Unassigned

Bug Description

The tests under cloudinit/cmd/tests/test_query.py will fail if run as root.

sudo nosetests3 test_query.py --debug=query

query: WARNING: Missing root-readable /tmp/ci-TestQuery.0ztjrur1/run_dir/instance-data-sensitive.json. Using redacted /tmp/ci-TestQuery.0ztjrur1/run_dir/instance-data.json instead.
query: ERROR: Missing instance-data file: /tmp/ci-TestQuery.0ztjrur1/run_dir/instance-data.json
.Equery: ERROR: Missing instance-data file: /tmp/ci-TestQuery.2_qzzunv/absent
.query: ERROR: Expected one of the options: --all, --format, --list-keys or varname
.query: ERROR: No read permission on '/tmp/ci-TestQuery.faxmaofy/unreadable'. Try sudo
.EEEEEEquery: WARNING: Missing root-readable /tmp/ci-TestQuery.rhy7l_rq/run_dir/instance-data-sensitive.json. Using redacted /tmp/ci-TestQuery.rhy7l_rq/run_dir/instance-data.json instead.
query: ERROR: Missing instance-data file: /tmp/ci-TestQuery.rhy7l_rq/run_dir/instance-data.json
..
======================================================================
ERROR: cloudinit.cmd.tests.test_query.TestQuery.test_handle_args_dumps_all_instance_data
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/anhvo/repos/cloud-init/cloudinit/cmd/tests/test_query.py", line 153, in test_handle_args_dumps_all_instance_data
    self.assertEqual(0, query.handle_args('anyname', args))
  File "/home/anhvo/repos/cloud-init/cloudinit/cmd/query.py", line 124, in handle_args
    instance_data['userdata'] = util.load_file(user_data_fn)
  File "/home/anhvo/repos/cloud-init/cloudinit/util.py", line 1359, in load_file
    with open(fname, 'rb') as ifh:
FileNotFoundError: [Errno 2] No such file or directory: 'ud'

======================================================================
ERROR: cloudinit.cmd.tests.test_query.TestQuery.test_handle_args_list_keys_errors_when_varname_is_not_a_dict
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/anhvo/repos/cloud-init/cloudinit/cmd/tests/test_query.py", line 255, in test_handle_args_list_keys_errors_when_varname_is_not_a_dict
    self.assertEqual(1, query.handle_args('anyname', args))
  File "/home/anhvo/repos/cloud-init/cloudinit/cmd/query.py", line 124, in handle_args
    instance_data['userdata'] = util.load_file(user_data_fn)
  File "/home/anhvo/repos/cloud-init/cloudinit/util.py", line 1359, in load_file
    with open(fname, 'rb') as ifh:
FileNotFoundError: [Errno 2] No such file or directory: 'ud'

Revision history for this message
Ryan Harper (raharper) wrote :

Hi, thanks for the bug. We generally want to avoid running any tests as root so as not to modify anything sensitive on the host.

Changed in cloud-init:
importance: Undecided → Wishlist
status: New → Triaged
Revision history for this message
Brett Holman (holmanb) wrote : Fixed in cloud-init version 22.1.

This bug is believed to be fixed in cloud-init in version 22.1. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

Changed in cloud-init:
status: Triaged → Fix Released
Revision history for this message
James Falcon (falcojr) wrote :
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.