Multi env support and Kube client integration
Kube friendly Beta
Package versions supports Kube env
Added:
- Env type detection
- New option: --use-env, for selecting env
when function supports multiple detected envs
- Updated config loading
- Each module and command type has supported env check
and stops execution if it is on unsupported env
- Functions can support multiple envs
- Kubernetes dependency
- Kubenernetes API detection: local and remote
- Package checking class hierachy for using Salt or Kube
- Remote pod execution routine
- Flexible SSH/SSH Forwarder classes: with, ssh,do(), etc
- Multithreaded SSH script execution
- Number of workers parameter, default 5
Fixed:
- Config dependency
- Command loading with supported envs list
- Unittests structure and execution flow updated
- Unittests fixes
- Fixed debug mode handling
- Unified command type/support routine
- Nested attrs getter/setter
Change-Id: I3ade693ac21536e2b5dcee4b24d511749dc72759
Related-PROD: PROD-35811
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 74928e3..9d1bd32 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -1,9 +1,22 @@
+import os
+
from unittest import mock
+from tests.mocks import _fake_kube_config_path
from tests.test_base import CfgCheckerTestBase
+os.environ['MCP_TYPE_FORCE'] = 'SALT'
+
+
class TestCliCommands(CfgCheckerTestBase):
+ def setUp(self):
+ # force env type to salt
+ os.environ['MCP_TYPE_FORCE'] = 'SALT'
+
+ def tearDown(self):
+ del os.environ['MCP_TYPE_FORCE']
+
def test_do_cli_main_command(self):
_module_name = 'cfg_checker.cfg_check'
_m = self._try_import(_module_name)
@@ -104,8 +117,13 @@
_m = self._try_import(_module_name)
_fake_args = mock.MagicMock(name="FakeArgsClass")
_command = "unknowncommand"
+ _config = None
with self.redirect_output():
- _r_value = _m.cli.command.execute_command(_fake_args, _command)
+ _r_value = _m.cli.command.execute_command(
+ _fake_args,
+ _command,
+ _config
+ )
self.assertEqual(
_r_value,
@@ -118,8 +136,9 @@
_m = self._try_import(_module_name)
_type = {}
_command = "unknowncommand"
+ _config = None
with self.redirect_output():
- _r_value = _m.cli.command.execute_command(_type, _command)
+ _r_value = _m.cli.command.execute_command(_type, _command, _config)
self.assertEqual(
_r_value,
@@ -131,9 +150,18 @@
_module_name = 'cfg_checker.cli.command'
_m = self._try_import(_module_name)
_fake_args = mock.MagicMock(name="FakeArgsClass")
+ _fake_args.kube_config_path = _fake_kube_config_path
_command = "reclass"
+
+ from cfg_checker.common.settings import CheckerConfiguration
+ _config = CheckerConfiguration(_fake_args)
+
with self.redirect_output():
- _r_value = _m.cli.command.execute_command(_fake_args, _command)
+ _r_value = _m.cli.command.execute_command(
+ _fake_args,
+ _command,
+ _config
+ )
self.assertEqual(
_r_value,