The following tests do no mock /proc/cmdline but rather end up reading the actual /proc/cmdline from the host erroneously-
> host_config_daemon = hostcfgd.HostConfigDaemon()
tests/hostcfgd/hostcfgd_fips_test.py:98:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
scripts/hostcfgd:2171: in __init__
self.kdumpCfg = KdumpCfg(self.config_db)
scripts/hostcfgd:1177: in __init__
self.init_kdump_config_from_cmdline()
scripts/hostcfgd:1195: in init_kdump_config_from_cmdline
kdump_config = self.config_db.get_entry("KDUMP", "config")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <tests.common.mock_configdb.MockConfigDb object at 0x7f5117baec10>, key = 'KDUMP', field = 'config'
def get_entry(self, key, field):
> return MockConfigDb.CONFIG_DB[key][field]
E KeyError: 'KDUMP'
The following tests do no mock /proc/cmdline but rather end up reading the actual /proc/cmdline from the host erroneously-
Even though a cmdline file is committed it was never used by the tests other than
hostcfgd_test.py, instead the code ends up using the/proc/cmdlineof the machine on which the test runs. The tests fail if the KDUMP is enabled on the machine where test is running, with a keyerror which is a false positive. As the test does not expect kdump to be enabled, the mocked config db for these tests does not have KDUMP configured as a result hostcfgd fails to retrieve KDUMP from config_db after it sees crashkernel parameteres in /proc/cmdline at this point https://github.com/sonic-net/sonic-host-services/blob/master/scripts/hostcfgd#L1195The proposed fix is to mock /proc/cmdline for every test instead of reading the "real" /proc/cmdline.