def test_join(self): ''' Test kuebadm.join 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.join() == 'stdout' salt_mock['cmd.run_all'].assert_called_with(['kubeadm', 'join'])
def test_join_error(self): ''' Test kuebadm.join 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.join()
def test_join_error(self): """ Test kuebadm.join 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.join()
def test_join(self): """ Test kuebadm.join 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.join() == "stdout" salt_mock["cmd.run_all"].assert_called_with(["kubeadm", "join"])
def test_join_params(self): ''' Test kuebadm.join 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.join( api_server_endpoint='10.160.65.165:6443', apiserver_advertise_address='127.0.0.1', apiserver_bind_port='1234', certificate_key='secret', config='/config.cfg', cri_socket='socket', discovery_file='/discovery.cfg', discovery_token='token', discovery_token_ca_cert_hash='type:value', discovery_token_unsafe_skip_ca_verification=True, experimental_control_plane=True, ignore_preflight_errors='all', node_name='node-1', skip_phases='all', tls_bootstrap_token='token', token='token', rootfs='/mnt') == 'stdout' salt_mock['cmd.run_all'].assert_called_with( ['kubeadm', 'join', '10.160.65.165:6443', '--discovery-token-unsafe-skip-ca-verification', '--experimental-control-plane', '--apiserver-advertise-address', '127.0.0.1', '--apiserver-bind-port', '1234', '--certificate-key', 'secret', '--config', '/config.cfg', '--cri-socket', 'socket', '--discovery-file', '/discovery.cfg', '--discovery-token', 'token', '--discovery-token-ca-cert-hash', 'type:value', '--ignore-preflight-errors', 'all', '--node-name', 'node-1', '--skip-phases', 'all', '--tls-bootstrap-token', 'token', '--token', 'token', '--rootfs', '/mnt'])
def test_join_params(self): """ Test kuebadm.join 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.join( api_server_endpoint="10.160.65.165:6443", apiserver_advertise_address="127.0.0.1", apiserver_bind_port="1234", certificate_key="secret", config="/config.cfg", cri_socket="socket", discovery_file="/discovery.cfg", discovery_token="token", discovery_token_ca_cert_hash="type:value", discovery_token_unsafe_skip_ca_verification=True, experimental_control_plane=True, ignore_preflight_errors="all", node_name="node-1", skip_phases="all", tls_bootstrap_token="token", token="token", rootfs="/mnt", ) == "stdout") salt_mock["cmd.run_all"].assert_called_with([ "kubeadm", "join", "10.160.65.165:6443", "--discovery-token-unsafe-skip-ca-verification", "--experimental-control-plane", "--apiserver-advertise-address", "127.0.0.1", "--apiserver-bind-port", "1234", "--certificate-key", "secret", "--config", "/config.cfg", "--cri-socket", "socket", "--discovery-file", "/discovery.cfg", "--discovery-token", "token", "--discovery-token-ca-cert-hash", "type:value", "--ignore-preflight-errors", "all", "--node-name", "node-1", "--skip-phases", "all", "--tls-bootstrap-token", "token", "--token", "token", "--rootfs", "/mnt", ])