Skip to content

Commit

Permalink
Modify Linux kernel version check to require at least version 4.6 (#35)
Browse files Browse the repository at this point in the history
Modify Linux kernel version check to require kernel version 4.6 or higher
  • Loading branch information
lawrencetroup authored Oct 11, 2023
1 parent 758b9bd commit 4c13694
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

The v1 release supports Cisco IOS-XR release versions from 7.7.1 to 7.9.1.

### v1.1.13 (2023-10-11)

- Modify Linux kernel version check to require kernel version 4.6 or higher.

### v1.1.12 (2023-06-30)

- Add Docker Compose v2 support to `host-check` and `xr-compose` scripts.
Expand Down
6 changes: 3 additions & 3 deletions scripts/host-check
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,13 @@ def check_kernel_version() -> CheckFuncReturn:
except Exception:
return (
CheckState.ERROR,
f"Unable to check the kernel version with command {cmd!r} - must be at least version 4.0",
f"Unable to check the kernel version with command {cmd!r} - must be at least version 4.6",
)

if version_tuple < (4, 0):
if version_tuple < (4, 6):
return (
CheckState.FAILED,
f"The kernel version is {version}, but at least version 4.0 is required.",
f"The kernel version is {version}, but at least version 4.6 is required.",
)

# Check for RHEL/CentOS 8.3 kernel version
Expand Down
23 changes: 17 additions & 6 deletions tests/test_host_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,8 +970,8 @@ class TestKernelVersion(_CheckTestBase):

def test_success(self, capsys):
"""Test the success case."""
result, output = self.perform_check(capsys, cmd_effects="4.1")
assert textwrap.dedent(output) == "PASS -- Kernel version (4.1)\n"
result, output = self.perform_check(capsys, cmd_effects="4.6")
assert textwrap.dedent(output) == "PASS -- Kernel version (4.6)\n"
assert result is CheckState.SUCCESS

def test_subproc_error(self, capsys):
Expand All @@ -982,7 +982,7 @@ def test_subproc_error(self, capsys):
assert textwrap.dedent(output) == textwrap.dedent(
"""\
ERROR -- Kernel version
Unable to check the kernel version with command 'uname -r' - must be at least version 4.0
Unable to check the kernel version with command 'uname -r' - must be at least version 4.6
"""
)
assert result is CheckState.ERROR
Expand All @@ -995,18 +995,29 @@ def test_no_version_match(self, capsys):
assert textwrap.dedent(output) == textwrap.dedent(
"""\
ERROR -- Kernel version
Unable to check the kernel version with command 'uname -r' - must be at least version 4.0
Unable to check the kernel version with command 'uname -r' - must be at least version 4.6
"""
)
assert result is CheckState.ERROR

def test_old_version(self, capsys):
def test_old_major_version(self, capsys):
"""Test the version being too old."""
result, output = self.perform_check(capsys, cmd_effects="3.9.8")
assert textwrap.dedent(output) == textwrap.dedent(
"""\
FAIL -- Kernel version
The kernel version is 3.9, but at least version 4.0 is required.
The kernel version is 3.9, but at least version 4.6 is required.
"""
)
assert result is CheckState.FAILED

def test_old_minor_version(self, capsys):
"""Test the version being too old."""
result, output = self.perform_check(capsys, cmd_effects="4.5")
assert textwrap.dedent(output) == textwrap.dedent(
"""\
FAIL -- Kernel version
The kernel version is 4.5, but at least version 4.6 is required.
"""
)
assert result is CheckState.FAILED
Expand Down

0 comments on commit 4c13694

Please sign in to comment.