unit tests try access fstab on live system

Bug #1981737 reported by Hicham El Gharbi
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
charm-fstab-config
Fix Released
Undecided
Sudeep Bhandari

Bug Description

When running unit tests on a live system without an /etc/fstab file, unit tests fails.
It is normal that the unit tests want to access live system /etc/fstab.

step to reproduce:
create a jammy lxd container
run unit test will error with the following

======================================================================
ERROR: test_001_config_changed_call (tests.unit.test_fstab_config.TestCharm)
Test that mounting new filesystems works upon config-changed.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/charm-fstab-config/src/.tox/unit/lib/python3.10/site-packages/mock/mock.py", line 1346, in patched
    return func(*newargs, **newkeywargs)
  File "/root/charm-fstab-config/src/tests/unit/test_fstab_config.py", line 102, in test_001_config_changed_call
    config_changed()
  File "/root/charm-fstab-config/src/reactive/fstab_config.py", line 129, in config_changed
    now = get_last_modification_fstab()
  File "/root/charm-fstab-config/src/reactive/fstab_config.py", line 16, in get_last_modification_fstab
    stat = os.path.getmtime("/etc/fstab")
  File "/usr/lib/python3.10/genericpath.py", line 55, in getmtime
    return os.stat(filename).st_mtime
FileNotFoundError: [Errno 2] No such file or directory: '/etc/fstab'

Tags: bseng-351
Eric Chen (eric-chen)
tags: added: bseng-351
Changed in charm-fstab-config:
assignee: nobody → Sudeep Bhandari (sudeephb)
Changed in charm-fstab-config:
status: New → Fix Committed
Changed in charm-fstab-config:
milestone: none → 22.08
Changed in charm-fstab-config:
status: Fix Committed → 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.