|
@@ -51,62 +51,6 @@ class TestExecuteHadoopResource(TestCase):
|
|
|
'path': [],
|
|
|
'environment': {}})
|
|
|
|
|
|
-
|
|
|
- @patch("resource_management.core.providers.system.ExecuteProvider")
|
|
|
- def test_run_unknown_conf(self, execute_mock):
|
|
|
- '''
|
|
|
- Test when UnknownConfiguration passed
|
|
|
- '''
|
|
|
- with Environment() as env:
|
|
|
- ExecuteHadoop("command",
|
|
|
- kinit_path_local=UnknownConfiguration(name="kinit_path_local"),
|
|
|
- conf_dir="conf_dir",
|
|
|
- user="user",
|
|
|
- keytab=UnknownConfiguration(name="keytab"),
|
|
|
- security_enabled=False,
|
|
|
- principal=UnknownConfiguration(name="principal")
|
|
|
- )
|
|
|
- self.assertEqual(execute_mock.call_count, 1)
|
|
|
- self.assertEqual(execute_mock.call_args[0][0].command,'hadoop --config conf_dir command')
|
|
|
- self.assertEqual(execute_mock.call_args[0][0].arguments,
|
|
|
- {'logoutput': None,
|
|
|
- 'tries': 1,
|
|
|
- 'user': 'user',
|
|
|
- 'try_sleep': 0,
|
|
|
- 'path': [],
|
|
|
- 'environment': {}})
|
|
|
-
|
|
|
-
|
|
|
- @patch("resource_management.core.providers.system.ExecuteProvider")
|
|
|
- def test_run_defined_args(self, execute_mock):
|
|
|
- '''
|
|
|
- Test if defined arguments are passed to Execute
|
|
|
- '''
|
|
|
- with Environment("/") as env:
|
|
|
- ExecuteHadoop("command",
|
|
|
- action="run",
|
|
|
- kinit_path_local="path",
|
|
|
- conf_dir="conf_dir",
|
|
|
- user="user",
|
|
|
- tries=2,
|
|
|
- keytab="keytab",
|
|
|
- security_enabled=False,
|
|
|
- kinit_override=False,
|
|
|
- try_sleep=2,
|
|
|
- logoutput=True,
|
|
|
- principal="principal"
|
|
|
- )
|
|
|
- self.assertEqual(execute_mock.call_count, 1)
|
|
|
- self.assertEqual(execute_mock.call_args[0][0].command,'hadoop --config conf_dir command')
|
|
|
- self.assertEqual(execute_mock.call_args[0][0].arguments,
|
|
|
- {'logoutput': True,
|
|
|
- 'tries': 2,
|
|
|
- 'user': 'user',
|
|
|
- 'try_sleep': 2,
|
|
|
- 'path': [],
|
|
|
- 'environment': {}})
|
|
|
-
|
|
|
-
|
|
|
@patch("resource_management.core.providers.system.ExecuteProvider")
|
|
|
def test_run_command_list(self, execute_mock):
|
|
|
'''
|
|
@@ -115,10 +59,8 @@ class TestExecuteHadoopResource(TestCase):
|
|
|
with Environment("/") as env:
|
|
|
ExecuteHadoop(["command1","command2"],
|
|
|
action="run",
|
|
|
- kinit_path_local="path",
|
|
|
conf_dir="conf_dir",
|
|
|
user="user",
|
|
|
- keytab="keytab"
|
|
|
)
|
|
|
self.assertEqual(execute_mock.call_count, 2)
|
|
|
self.assertEqual(execute_mock.call_args_list[0][0][0].command,
|
|
@@ -149,96 +91,9 @@ class TestExecuteHadoopResource(TestCase):
|
|
|
with Environment("/") as env:
|
|
|
ExecuteHadoop(("command1","command2","command3"),
|
|
|
action="run",
|
|
|
- kinit_path_local="path",
|
|
|
conf_dir="conf_dir",
|
|
|
user="user",
|
|
|
- keytab="keytab"
|
|
|
)
|
|
|
self.assertEqual(execute_mock.call_count, 1)
|
|
|
self.assertEqual(execute_mock.call_args[0][0].command,
|
|
|
- 'hadoop --config conf_dir command1 command2 command3')
|
|
|
-
|
|
|
-
|
|
|
- @patch("resource_management.core.providers.system.ExecuteProvider")
|
|
|
- def test_run_secured(self, execute_mock):
|
|
|
- '''
|
|
|
- Test security_enabled=True behaviour
|
|
|
- '''
|
|
|
- with Environment("/") as env:
|
|
|
- ExecuteHadoop("command",
|
|
|
- action="run",
|
|
|
- kinit_path_local="path",
|
|
|
- conf_dir="conf_dir",
|
|
|
- user="user",
|
|
|
- principal="principal",
|
|
|
- tries=1,
|
|
|
- keytab="keytab",
|
|
|
- security_enabled=True,
|
|
|
- kinit_override=False,
|
|
|
- try_sleep=0,
|
|
|
- logoutput=True
|
|
|
- )
|
|
|
- self.assertEqual(execute_mock.call_count, 2)
|
|
|
- self.assertEqual(str(execute_mock.call_args_list[0][0][0]),
|
|
|
- 'Execute[\'path -kt keytab principal\']')
|
|
|
- self.assertEqual(execute_mock.call_args_list[0][0][0].command,
|
|
|
- 'path -kt keytab principal')
|
|
|
- self.assertEqual(execute_mock.call_args_list[0][0][0].arguments,
|
|
|
- {'path': ['/bin'], 'user': 'user'})
|
|
|
- self.assertEqual(execute_mock.call_args_list[1][0][0].command,
|
|
|
- 'hadoop --config conf_dir command')
|
|
|
- self.assertEqual(execute_mock.call_args_list[1][0][0].arguments,
|
|
|
- {'logoutput': True,
|
|
|
- 'tries': 1,
|
|
|
- 'user': 'user',
|
|
|
- 'try_sleep': 0,
|
|
|
- 'path': [],
|
|
|
- 'environment': {}})
|
|
|
-
|
|
|
-
|
|
|
- @patch("resource_management.core.providers.system.ExecuteProvider")
|
|
|
- def test_run_secured_kinit_override(self, execute_mock):
|
|
|
- '''
|
|
|
- Test security_enabled=True and kinit_override=True behaviour
|
|
|
- '''
|
|
|
- with Environment("/") as env:
|
|
|
- ExecuteHadoop("command",
|
|
|
- action="run",
|
|
|
- kinit_path_local="path",
|
|
|
- conf_dir="conf_dir",
|
|
|
- user="user",
|
|
|
- tries=1,
|
|
|
- keytab="keytab",
|
|
|
- security_enabled=True,
|
|
|
- kinit_override=True,
|
|
|
- try_sleep=0,
|
|
|
- logoutput=True
|
|
|
- )
|
|
|
- self.assertEqual(execute_mock.call_count, 1)
|
|
|
- self.assertEqual(execute_mock.call_args_list[0][0][0].command,
|
|
|
- 'hadoop --config conf_dir command')
|
|
|
-
|
|
|
-
|
|
|
- @patch("resource_management.core.providers.system.ExecuteProvider")
|
|
|
- def test_run_secured_principal(self, execute_mock):
|
|
|
- '''
|
|
|
- Test with "principal" argument
|
|
|
- '''
|
|
|
- with Environment("/") as env:
|
|
|
- ExecuteHadoop("command",
|
|
|
- action="run",
|
|
|
- kinit_path_local="path",
|
|
|
- conf_dir="conf_dir",
|
|
|
- user="user",
|
|
|
- tries=1,
|
|
|
- keytab="keytab",
|
|
|
- security_enabled=True,
|
|
|
- kinit_override=False,
|
|
|
- try_sleep=0,
|
|
|
- logoutput=True,
|
|
|
- principal="principal")
|
|
|
- self.assertEqual(execute_mock.call_count, 2)
|
|
|
- self.assertEqual(execute_mock.call_args_list[0][0][0].command,
|
|
|
- 'path -kt keytab principal')
|
|
|
- self.assertEqual(execute_mock.call_args_list[1][0][0].command,
|
|
|
- 'hadoop --config conf_dir command')
|
|
|
+ 'hadoop --config conf_dir command1 command2 command3')
|