Ejemplo n.º 1
0
 def test_reset_params(self):
     """
     Test kuebadm.reset with parameters
     """
     result = {"retcode": 0, "stdout": "stdout"}
     salt_mock = {
         "cmd.run_all": MagicMock(return_value=result),
     }
     with patch.dict(kubeadm.__salt__, salt_mock):
         assert (kubeadm.reset(
             cert_dir="/pki",
             cri_socket="socket",
             ignore_preflight_errors="all",
             kubeconfig="/kube.cfg",
             rootfs="/mnt",
         ) == "stdout")
         salt_mock["cmd.run_all"].assert_called_with([
             "kubeadm",
             "reset",
             "--force",
             "--cert-dir",
             "/pki",
             "--cri-socket",
             "socket",
             "--ignore-preflight-errors",
             "all",
             "--kubeconfig",
             "/kube.cfg",
             "--rootfs",
             "/mnt",
         ])
Ejemplo n.º 2
0
 def test_reset_error(self):
     '''
     Test kuebadm.reset error
     '''
     result = {'retcode': 1, 'stderr': 'error'}
     salt_mock = {
         'cmd.run_all': MagicMock(return_value=result),
     }
     with patch.dict(kubeadm.__salt__, salt_mock):
         with pytest.raises(CommandExecutionError):
             assert kubeadm.reset()
Ejemplo n.º 3
0
 def test_reset_error(self):
     """
     Test kuebadm.reset error
     """
     result = {"retcode": 1, "stderr": "error"}
     salt_mock = {
         "cmd.run_all": MagicMock(return_value=result),
     }
     with patch.dict(kubeadm.__salt__, salt_mock):
         with pytest.raises(CommandExecutionError):
             assert kubeadm.reset()
Ejemplo n.º 4
0
 def test_reset(self):
     '''
     Test kuebadm.reset without parameters
     '''
     result = {'retcode': 0, 'stdout': 'stdout'}
     salt_mock = {
         'cmd.run_all': MagicMock(return_value=result),
     }
     with patch.dict(kubeadm.__salt__, salt_mock):
         assert kubeadm.reset() == 'stdout'
         salt_mock['cmd.run_all'].assert_called_with(
             ['kubeadm', 'reset', '--force'])
Ejemplo n.º 5
0
 def test_reset(self):
     """
     Test kuebadm.reset without parameters
     """
     result = {"retcode": 0, "stdout": "stdout"}
     salt_mock = {
         "cmd.run_all": MagicMock(return_value=result),
     }
     with patch.dict(kubeadm.__salt__, salt_mock):
         assert kubeadm.reset() == "stdout"
         salt_mock["cmd.run_all"].assert_called_with(
             ["kubeadm", "reset", "--force"])
Ejemplo n.º 6
0
 def test_reset_params(self):
     '''
     Test kuebadm.reset with parameters
     '''
     result = {'retcode': 0, 'stdout': 'stdout'}
     salt_mock = {
         'cmd.run_all': MagicMock(return_value=result),
     }
     with patch.dict(kubeadm.__salt__, salt_mock):
         assert kubeadm.reset(cert_dir='/pki',
                              cri_socket='socket',
                              ignore_preflight_errors='all',
                              kubeconfig='/kube.cfg',
                              rootfs='/mnt') == 'stdout'
         salt_mock['cmd.run_all'].assert_called_with([
             'kubeadm', 'reset', '--force', '--cert-dir', '/pki',
             '--cri-socket', 'socket', '--ignore-preflight-errors', 'all',
             '--kubeconfig', '/kube.cfg', '--rootfs', '/mnt'
         ])