fix(updates): read dnf and yum updates from the cached metadata
driver / standard (pull_request) Failing after 15s
driver / lint (pull_request) Successful in 13s
driver / types (pull_request) Successful in 1m0s
driver / test (3.12) (pull_request) Failing after 1m1s
driver / test (3.13) (pull_request) Failing after 53s
driver / lowest (pull_request) Failing after 28s
driver / build (pull_request) Successful in 33s
driver / security (pull_request) Successful in 1m9s
CI / driver (pull_request) Failing after 2m30s
driver / publish (pull_request) Skipped
driver / standard (pull_request) Failing after 15s
driver / lint (pull_request) Successful in 13s
driver / types (pull_request) Successful in 1m0s
driver / test (3.12) (pull_request) Failing after 1m1s
driver / test (3.13) (pull_request) Failing after 53s
driver / lowest (pull_request) Failing after 28s
driver / build (pull_request) Successful in 33s
driver / security (pull_request) Successful in 1m9s
CI / driver (pull_request) Failing after 2m30s
driver / publish (pull_request) Skipped
`dnf check-update` and `yum check-update`, and yum's security query, download the repositories' metadata first whenever the cached copy has expired. On an Oracle Linux host on OCI that outlasted netOrk's 120 s poll on every run, and the device went offline. They now run with --cacheonly, as apt's read uses its local index; refresh_available_updates (`dnf makecache`) still refreshes it. Without a cache the read fails at once and says to refresh the index. The README row claimed check-update ran unprivileged; it runs as root. dnf's security query is NAPALM/napalm-device-types#76. Closes #59
This commit is contained in:
1 parent
60ff9d9700
commit
d226ebf764
4 files changed
+48
-10
No files matched your search
+27
-1
@@ -1684,7 +1684,7 @@ class TestAvailableUpdates:
|
||||
# parse_dnf_security (napalm-device-types 4.7) needs the __DNF_RC marker, and
|
||||
# behind "| cat" the outer status no longer says whether yum failed.
|
||||
assert "echo __DNF_RC=$?" in _YUM_SECURITY_COMMAND
|
||||
assert "yum updateinfo list security" in _YUM_SECURITY_COMMAND
|
||||
assert "yum --cacheonly updateinfo list security" in _YUM_SECURITY_COMMAND
|
||||
|
||||
def test_yum_marks_what_a_security_advisory_covers(self, driver):
|
||||
driver._pkg_manager = "yum"
|
||||
@@ -1749,6 +1749,32 @@ class TestAvailableUpdates:
|
||||
with pytest.raises(RuntimeError):
|
||||
driver.get_available_updates()
|
||||
|
||||
@pytest.mark.parametrize("manager", ["dnf", "yum"])
|
||||
def test_rpm_reads_only_the_cached_metadata(self, driver, manager):
|
||||
"""An expired cache made check-update download the repositories' metadata
|
||||
inside the poll, which outlasted its whole budget (#59)."""
|
||||
driver._pkg_manager = manager
|
||||
driver._device.send_command.side_effect = [
|
||||
"0",
|
||||
"__NETORK_RC=0",
|
||||
"__DNF_RC=0\n__NETORK_RC=0",
|
||||
]
|
||||
|
||||
driver.get_available_updates()
|
||||
|
||||
sent = [c[0][0] for c in driver._device.send_command.call_args_list]
|
||||
assert f"{manager} --cacheonly check-update" in sent[1]
|
||||
assert f"{manager} --cacheonly updateinfo" in sent[2]
|
||||
|
||||
def test_rpm_without_a_cache_says_to_refresh_it(self, driver):
|
||||
# dnf --cacheonly fails at once without cached metadata; its stderr is
|
||||
# discarded, so the reason has to come from here.
|
||||
driver._pkg_manager = "dnf"
|
||||
driver._device.send_command.side_effect = ["0", "__NETORK_RC=1"]
|
||||
|
||||
with pytest.raises(RuntimeError, match="refresh the package index"):
|
||||
driver.get_available_updates()
|
||||
|
||||
|
||||
class TestRefreshAvailableUpdates:
|
||||
def _sent(self, driver) -> list:
|
||||
|
||||
Reference in new issue
Block a user