Esempio n. 1
0
 def test_init_params(self):
     '''
     Test kuebadm.init 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.init(
             apiserver_advertise_address='127.0.0.1',
             apiserver_bind_port='1234',
             apiserver_cert_extra_sans='sans',
             cert_dir='/pki',
             certificate_key='secret',
             config='/config.cfg',
             cri_socket='socket',
             experimental_upload_certs=True,
             feature_gates='k=v',
             ignore_preflight_errors='all',
             image_repository='example.org',
             kubernetes_version='version',
             node_name='node-1',
             pod_network_cidr='10.1.0.0/12',
             service_cidr='10.2.0.0/12',
             service_dns_domain='example.org',
             skip_certificate_key_print=True,
             skip_phases='all',
             skip_token_print=True,
             token='token',
             token_ttl='1h1m1s',
             rootfs='/mnt') == 'stdout'
         salt_mock['cmd.run_all'].assert_called_with(
             ['kubeadm', 'init',
              '--experimental-upload-certs',
              '--skip-certificate-key-print',
              '--skip-token-print',
              '--apiserver-advertise-address', '127.0.0.1',
              '--apiserver-bind-port', '1234',
              '--apiserver-cert-extra-sans', 'sans',
              '--cert-dir', '/pki',
              '--certificate-key', 'secret',
              '--config', '/config.cfg',
              '--cri-socket', 'socket',
              '--feature-gates', 'k=v',
              '--ignore-preflight-errors', 'all',
              '--image-repository', 'example.org',
              '--kubernetes-version', 'version',
              '--node-name', 'node-1',
              '--pod-network-cidr', '10.1.0.0/12',
              '--service-cidr', '10.2.0.0/12',
              '--service-dns-domain', 'example.org',
              '--skip-phases', 'all',
              '--token', 'token',
              '--token-ttl', '1h1m1s',
              '--rootfs', '/mnt'])
Esempio n. 2
0
 def test_init_error(self):
     '''
     Test kuebadm.init 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.init()
Esempio n. 3
0
 def test_init(self):
     '''
     Test kuebadm.init 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.init() == 'stdout'
         salt_mock['cmd.run_all'].assert_called_with(['kubeadm', 'init'])
Esempio n. 4
0
 def test_init_error(self):
     """
     Test kuebadm.init 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.init()
Esempio n. 5
0
 def test_init(self):
     """
     Test kuebadm.init 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.init() == "stdout"
         salt_mock["cmd.run_all"].assert_called_with(["kubeadm", "init"])
Esempio n. 6
0
 def test_init_params(self):
     """
     Test kuebadm.init 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.init(
             apiserver_advertise_address="127.0.0.1",
             apiserver_bind_port="1234",
             apiserver_cert_extra_sans="sans",
             cert_dir="/pki",
             certificate_key="secret",
             config="/config.cfg",
             cri_socket="socket",
             experimental_upload_certs=True,
             feature_gates="k=v",
             ignore_preflight_errors="all",
             image_repository="example.org",
             kubernetes_version="version",
             node_name="node-1",
             pod_network_cidr="10.1.0.0/12",
             service_cidr="10.2.0.0/12",
             service_dns_domain="example.org",
             skip_certificate_key_print=True,
             skip_phases="all",
             skip_token_print=True,
             token="token",
             token_ttl="1h1m1s",
             rootfs="/mnt",
         ) == "stdout")
         salt_mock["cmd.run_all"].assert_called_with([
             "kubeadm",
             "init",
             "--experimental-upload-certs",
             "--skip-certificate-key-print",
             "--skip-token-print",
             "--apiserver-advertise-address",
             "127.0.0.1",
             "--apiserver-bind-port",
             "1234",
             "--apiserver-cert-extra-sans",
             "sans",
             "--cert-dir",
             "/pki",
             "--certificate-key",
             "secret",
             "--config",
             "/config.cfg",
             "--cri-socket",
             "socket",
             "--feature-gates",
             "k=v",
             "--ignore-preflight-errors",
             "all",
             "--image-repository",
             "example.org",
             "--kubernetes-version",
             "version",
             "--node-name",
             "node-1",
             "--pod-network-cidr",
             "10.1.0.0/12",
             "--service-cidr",
             "10.2.0.0/12",
             "--service-dns-domain",
             "example.org",
             "--skip-phases",
             "all",
             "--token",
             "token",
             "--token-ttl",
             "1h1m1s",
             "--rootfs",
             "/mnt",
         ])