From db271c5e0d6cf39c6210c4356e5487961eea6d7d Mon Sep 17 00:00:00 2001 From: Konrad Kaim Date: Thu, 23 Oct 2025 13:09:53 +0000 Subject: [PATCH] feat: expose get_installed_kueue_version --- src/xpk/core/kueue_manager.py | 4 ++-- src/xpk/core/kueue_manager_test.py | 26 +++++++++----------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/xpk/core/kueue_manager.py b/src/xpk/core/kueue_manager.py index 582e27519..01f8226e0 100644 --- a/src/xpk/core/kueue_manager.py +++ b/src/xpk/core/kueue_manager.py @@ -96,7 +96,7 @@ def install_or_upgrade( Args: tolerations: An optional list of tolerations to apply to the kueue-controller-manager. """ - return_code, installed_version = self.__get_installed_kueue_version() + return_code, installed_version = self.get_installed_kueue_version() if return_code == 0: if installed_version and installed_version > self.kueue_version: @@ -116,7 +116,7 @@ def install_or_upgrade( return self.__configure(kueue_config) - def __get_installed_kueue_version(self) -> tuple[int, str | None]: + def get_installed_kueue_version(self) -> tuple[int, str | None]: command = ( "kubectl get deployment kueue-controller-manager -n kueue-system -o" " jsonpath='{.spec.template.spec.containers[0].image}'" diff --git a/src/xpk/core/kueue_manager_test.py b/src/xpk/core/kueue_manager_test.py index 7a793aedc..7f340eacd 100644 --- a/src/xpk/core/kueue_manager_test.py +++ b/src/xpk/core/kueue_manager_test.py @@ -76,9 +76,7 @@ def test_version_check_when_kueue_not_installed(self, mock_run_for_value): mock_install.assert_called_once() mock_configure.assert_called_once() - @patch( - "xpk.core.kueue_manager.KueueManager._KueueManager__get_installed_kueue_version" - ) + @patch("xpk.core.kueue_manager.KueueManager.get_installed_kueue_version") @patch("xpk.core.kueue_manager.KueueManager._KueueManager__install") @patch("xpk.core.kueue_manager.KueueManager._KueueManager__configure") def test_install_or_upgrade_when_newer_version_already_installed( @@ -95,9 +93,7 @@ def test_install_or_upgrade_when_newer_version_already_installed( mock_install.assert_not_called() mock_configure.assert_not_called() - @patch( - "xpk.core.kueue_manager.KueueManager._KueueManager__get_installed_kueue_version" - ) + @patch("xpk.core.kueue_manager.KueueManager.get_installed_kueue_version") def test_install_or_upgrade_when_outdated( self, mock_get_version, @@ -121,9 +117,7 @@ def test_install_or_upgrade_when_outdated( mock_install.assert_called_once() mock_configure.assert_called_once() - @patch( - "xpk.core.kueue_manager.KueueManager._KueueManager__get_installed_kueue_version" - ) + @patch("xpk.core.kueue_manager.KueueManager.get_installed_kueue_version") def test_install_or_upgrade_when_not_installed( self, mock_get_version, @@ -155,7 +149,7 @@ def test_installation_with_tolerations(self): return_value=0, ) as mock_run_retry, patch( - "xpk.core.kueue_manager.KueueManager._KueueManager__get_installed_kueue_version", + "xpk.core.kueue_manager.KueueManager.get_installed_kueue_version", return_value=(1, None), ), patch( @@ -199,7 +193,7 @@ def test_installation_without_tolerations(self): return_value=0, ) as mock_run_retry, patch( - "xpk.core.kueue_manager.KueueManager._KueueManager__get_installed_kueue_version", + "xpk.core.kueue_manager.KueueManager.get_installed_kueue_version", return_value=(1, None), ), patch( @@ -224,9 +218,7 @@ def test_installation_without_tolerations(self): self.assertEqual(result, 0) self.assertEqual(mock_run_retry.call_count, 0) - @patch( - "xpk.core.kueue_manager.KueueManager._KueueManager__get_installed_kueue_version" - ) + @patch("xpk.core.kueue_manager.KueueManager.get_installed_kueue_version") @patch("xpk.core.kueue_manager.KueueManager._KueueManager__apply_manifest") def test_configuration_updates_resources( self, mock_apply_manifest, mock_get_version @@ -276,7 +268,7 @@ def test_resource_update_for_small_cluster(self, mock_run_retry): ), patch.object( self.kueue_manager, - "_KueueManager__get_installed_kueue_version", + "get_installed_kueue_version", return_value=(1, None), ), patch.object( @@ -319,7 +311,7 @@ def test_resource_update_for_large_cluster(self, mock_run_retry): ), patch.object( self.kueue_manager, - "_KueueManager__get_installed_kueue_version", + "get_installed_kueue_version", return_value=(1, None), ), patch.object( @@ -553,7 +545,7 @@ def _trigger_installation(self, kueue_config: KueueConfig) -> str: """Calls Kueue installation and returns the rendered manifest.""" with ( patch.object( - self.kueue_manager, "_KueueManager__get_installed_kueue_version" + self.kueue_manager, "get_installed_kueue_version" ) as mock_get_version, patch.object( self.kueue_manager, "_KueueManager__apply_manifest"