Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion coriolis/osmorphing/osdetect/centos.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def detect_os(self):
release_info = self._read_file(
redhat_release_path).decode().splitlines()
if release_info:
m = re.match(r"^(.*) release ([0-9](\.[0-9])*)( \(.*\))?.*$",
m = re.match(r"^(.*) release ([0-9]+(\.[0-9]+)*)( \(.*\))?.*$",
release_info[0].strip())
if m:
distro, version, _, _ = m.groups()
Expand Down
2 changes: 1 addition & 1 deletion coriolis/osmorphing/osdetect/rocky.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def detect_os(self):
release_info = self._read_file(
redhat_release_path).decode().splitlines()
if release_info:
m = re.match(r"^(.*) release ([0-9](\.[0-9])*)( \(.*\))?.*$",
m = re.match(r"^(.*) release ([0-9]+(\.[0-9]+)*)( \(.*\))?.*$",
release_info[0].strip())
if m:
distro, version, _, _ = m.groups()
Expand Down
18 changes: 18 additions & 0 deletions coriolis/tests/osmorphing/osdetect/test_centos.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ def test_detect_os_centos_stream(self, mock_read_file, mock_test_path):

self.assertEqual(result, expected_info)

@mock.patch.object(base.BaseLinuxOSDetectTools, '_test_path')
@mock.patch.object(base.BaseLinuxOSDetectTools, '_read_file')
def test_detect_os_centos_stream_10(self, mock_read_file, mock_test_path):
mock_test_path.return_value = True
mock_read_file.return_value = b"CentOS Stream release 10"

expected_info = {
"os_type": centos.constants.OS_TYPE_LINUX,
"distribution_name": centos.CENTOS_STREAM_DISTRO_IDENTIFIER,
"release_version": '10',
"friendly_release_name": "%s Version %s" % (
centos.CENTOS_STREAM_DISTRO_IDENTIFIER, '10')
}

result = self.centos_os_detect_tools.detect_os()

self.assertEqual(result, expected_info)

@mock.patch.object(base.BaseLinuxOSDetectTools, '_test_path')
@mock.patch.object(base.BaseLinuxOSDetectTools, '_read_file')
def test_detect_os_not_centos(self, mock_read_file, mock_test_path):
Expand Down
22 changes: 22 additions & 0 deletions coriolis/tests/osmorphing/osdetect/test_rocky.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,28 @@ def test_detect_os(self, mock_read_file, mock_test_path):

self.assertEqual(result, expected_info)

@mock.patch.object(base.BaseLinuxOSDetectTools, '_test_path')
@mock.patch.object(base.BaseLinuxOSDetectTools, '_read_file')
def test_detect_os_rocky_10(self, mock_read_file, mock_test_path):
mock_test_path.return_value = True
mock_read_file.return_value = (
b"Rocky Linux release 10.1 (Red Quartz)")

expected_info = {
"os_type": rocky.constants.OS_TYPE_LINUX,
"distribution_name": rocky.ROCKY_LINUX_DISTRO_IDENTIFIER,
"release_version": '10.1',
"friendly_release_name": "Rocky Linux Version 10.1"
}

rocky_os_detect_tools = rocky.RockyLinuxOSDetectTools(
mock.sentinel.conn, mock.sentinel.os_root_dir,
mock.sentinel.operation_timeout)

result = rocky_os_detect_tools.detect_os()

self.assertEqual(result, expected_info)

@mock.patch.object(base.BaseLinuxOSDetectTools, '_test_path')
@mock.patch.object(base.BaseLinuxOSDetectTools, '_read_file')
def test_detect_os_no_rocky(self, mock_read_file, mock_test_path):
Expand Down
Loading