def test_noshell_bang_command(self): """ Test no shebang in the command script Some commands are shell without bangs! (like in Centreon...) We can detect it in the launch, and it should be managed :return: None """ self.print_header() a = Action() a.command = "libexec/dummy_command_nobang.sh" assert False == a.got_shell_characters() a.execute() # Run the action script a.execute() assert 'launched' == a.status # Wait action execution end self.wait_finished(a) assert 0 == a.exit_status assert 'done' == a.status assert "Hi, I'm for testing only. Please do not use me directly, really" == a.output assert "" == a.long_output assert "Hip=99% Bob=34mm" == a.perf_data
def test_action(self): """ Test simple action execution :return: None """ self.print_header() a = Action() if os.name == 'nt': a.command = r'libexec\\dummy_command.cmd' else: a.command = "libexec/dummy_command.sh" assert a.got_shell_characters() == False # Run the action script a.execute() assert 'launched' == a.status # Wait action execution end self.wait_finished(a) assert 0 == a.exit_status assert 'done' == a.status assert "Hi, I'm for testing only. Please do not use me directly, really" == a.output assert "" == a.long_output assert "Hip=99% Bob=34mm" == a.perf_data
def test_got_pipe_shell_characters(self): a = Action() a.timeout = 10 a.command = "libexec/dummy_command_nobang.sh | grep 'Please do not use me directly'" a.env = {} if os.name == 'nt': return self.assertEqual(True, a.got_shell_characters()) a.execute() self.assertEqual('launched', a.status) self.wait_finished(a) print "F**k", a.status, a.output self.assertEqual(0, a.exit_status) self.assertEqual('done', a.status)
def test_noshell_bang_command(self): a = Action() a.timeout = 10 a.command = "libexec/dummy_command_nobang.sh" a.env = {} if os.name == 'nt': return self.assertEqual(False, a.got_shell_characters()) a.execute() self.assertEqual('launched', a.status) self.wait_finished(a) print "F**k", a.status, a.output self.assertEqual(0, a.exit_status) self.assertEqual('done', a.status)
def test_action(self): a = Action() a.timeout = 10 a.env = {} if os.name == 'nt': a.command = r'libexec\\dummy_command.cmd' else: a.command = "libexec/dummy_command.sh" self.assertEqual(False, a.got_shell_characters()) a.execute() self.assertEqual('launched', a.status) # Give also the max output we want for the command self.wait_finished(a) self.assertEqual(0, a.exit_status) self.assertEqual('done', a.status) print a.output self.assertEqual("Hi, I'm for testing only. Please do not use me directly, really", a.output) self.assertEqual("Hip=99% Bob=34mm", a.perf_data)
def test_got_pipe_shell_characters(self): """ Test pipe shell character in the command :return: None """ a = Action() a.command = "libexec/dummy_command_nobang.sh | grep 'I will not match this search!'" assert True == a.got_shell_characters() # Run the action script a.execute() assert 'launched' == a.status # Wait action execution end self.wait_finished(a) assert 1 == a.exit_status assert 'done' == a.status assert "" == a.output assert "" == a.long_output assert "" == a.perf_data
def test_got_shell_characters(self): """ Test shell characters in the command (&>...) :return: None """ a = Action() a.command = "libexec/dummy_command_nobang.sh && echo finished ok" assert True == a.got_shell_characters() # Run the action script a.execute() assert 'launched' == a.status # Wait action execution end self.wait_finished(a) assert 0 == a.exit_status assert 'done' == a.status assert "Hi, I'm for testing only. Please do not use me directly, really" == a.output assert "finished ok" == a.long_output assert "Hip=99% Bob=34mm" == a.perf_data
def test_action(self): """ Test simple action execution :return: None """ a = Action() a.command = "libexec/dummy_command.sh" assert a.got_shell_characters() == False # Run the action script a.execute() assert 'launched' == a.status # Wait action execution end self.wait_finished(a) assert 3 == a.exit_status assert 'done' == a.status assert "Hi, I'm for testing only. Please do not use me directly, really" == a.output assert "" == a.long_output assert "Hip=99% Hop=34mm" == a.perf_data
def test_noshell_bang_command(self): """ Test no shebang in the command script Some commands are shell without bangs! (like in Centreon...) We can detect it in the launch, and it should be managed :return: None """ a = Action() a.command = "libexec/dummy_command_nobang.sh" assert False == a.got_shell_characters() a.execute() # Run the action script a.execute() assert 'launched' == a.status # Wait action execution end self.wait_finished(a) assert 0 == a.exit_status assert 'done' == a.status assert "Hi, I'm for testing only. Please do not use me directly, really" == a.output assert "" == a.long_output assert "Hip=99% Bob=34mm" == a.perf_data