Exemple #1
0
 def test_shell(self):
     """[Utils] Test shell"""
     # We need to override _register method
     RemoteShell._connections['127.0.0.1'] = FakeSSHClient()
     shell = RemoteShell('127.0.0.1')
     # Test passing cmd execution
     rc, out, err = shell.execute('pass')
     self.assertEqual(rc, 0)
     self.assertEqual(out, 'passed')
     self.assertEqual(err, 'passed')
     # Test failing cmd execution
     rc, out, err = shell.execute('fail', can_fail=False)
     self.assertEqual(rc, 1)
     self.assertEqual(out, 'failed')
     self.assertEqual(err, 'failed')
     self.assertRaises(RuntimeError, shell.execute, 'fail')
     # Test passing script execution
     rc, out, err = shell.run_script(['pass'])
     self.assertEqual(rc, 0)
     self.assertEqual(out, 'passed')
     self.assertEqual(err, 'passed')
     # Test failing script execution
     rc, out, err = shell.run_script(['fail'], can_fail=False)
     self.assertEqual(rc, 1)
     self.assertEqual(out, 'failed')
     self.assertEqual(err, 'failed')
     self.assertRaises(RuntimeError, shell.run_script, ['fail'])
     # Test masking
     mask_list = ['masked']
     try:
         shell.execute('fail masked string', mask_list=mask_list)
     except RuntimeError as ex:
         self.assertEqual(str(ex), 'Failed to run following command '
                                   'on host 127.0.0.1: fail %s string'
                                   % STR_MASK)
     chout = FakeChannelFile()
     chout.output = ['This is masked', 'This should be also masked']
     stdout, solog = shell._process_output('stdout', chout,
                                           mask_list, [])
     self.assertEqual(solog, '%s\nThis is %s\nThis should be also %s'
                             % (OUTFMT % 'stdout', STR_MASK, STR_MASK))
     # Test execute
     rc, out, err = execute('foo bar')
     self.assertEqual(out, 'passed')
     rc, out, err = execute(['ssh', 'bash -x'])
     self.assertEqual(out, 'passed')
Exemple #2
0
 def test_shell(self):
     """[Utils] Test shell"""
     # We need to override _register method
     RemoteShell._connections['127.0.0.1'] = FakeSSHClient()
     shell = RemoteShell('127.0.0.1')
     # Test passing cmd execution
     rc, out, err = shell.execute('pass')
     self.assertEqual(rc, 0)
     self.assertEqual(out, 'passed')
     self.assertEqual(err, 'passed')
     # Test failing cmd execution
     rc, out, err = shell.execute('fail', can_fail=False)
     self.assertEqual(rc, 1)
     self.assertEqual(out, 'failed')
     self.assertEqual(err, 'failed')
     self.assertRaises(RuntimeError, shell.execute, 'fail')
     # Test passing script execution
     rc, out, err = shell.run_script(['pass'])
     self.assertEqual(rc, 0)
     self.assertEqual(out, 'passed')
     self.assertEqual(err, 'passed')
     # Test failing script execution
     rc, out, err = shell.run_script(['fail'], can_fail=False)
     self.assertEqual(rc, 1)
     self.assertEqual(out, 'failed')
     self.assertEqual(err, 'failed')
     self.assertRaises(RuntimeError, shell.run_script, ['fail'])
     # Test masking
     mask_list = ['masked']
     try:
         shell.execute('fail masked string', mask_list=mask_list)
     except RuntimeError as ex:
         self.assertEqual(
             str(ex)[:55],
             '[127.0.0.1] Failed to run command:\nfail %s string' %
             STR_MASK)
     # Test execute
     rc, out, err = execute('foo bar')
     self.assertEqual(out, 'passed')
     rc, out, err = execute(['ssh', 'bash -x'])
     self.assertEqual(out, 'passed')
Exemple #3
0
 def test_shell(self):
     """[Utils] Test shell"""
     # We need to override _register method
     RemoteShell._connections['127.0.0.1'] = FakeSSHClient()
     shell = RemoteShell('127.0.0.1')
     # Test passing cmd execution
     rc, out, err = shell.execute('pass')
     self.assertEqual(rc, 0)
     self.assertEqual(out, 'passed')
     self.assertEqual(err, 'passed')
     # Test failing cmd execution
     rc, out, err = shell.execute('fail', can_fail=False)
     self.assertEqual(rc, 1)
     self.assertEqual(out, 'failed')
     self.assertEqual(err, 'failed')
     self.assertRaises(RuntimeError, shell.execute, 'fail')
     # Test passing script execution
     rc, out, err = shell.run_script(['pass'])
     self.assertEqual(rc, 0)
     self.assertEqual(out, 'passed')
     self.assertEqual(err, 'passed')
     # Test failing script execution
     rc, out, err = shell.run_script(['fail'], can_fail=False)
     self.assertEqual(rc, 1)
     self.assertEqual(out, 'failed')
     self.assertEqual(err, 'failed')
     self.assertRaises(RuntimeError, shell.run_script, ['fail'])
     # Test masking
     mask_list = ['masked']
     try:
         shell.execute('fail masked string', mask_list=mask_list)
     except RuntimeError as ex:
         self.assertEqual(
             str(ex)[:55],
             '[127.0.0.1] Failed to run command:\nfail %s string' % STR_MASK
         )
     # Test execute
     rc, out, err = execute('foo bar')
     self.assertEqual(out, 'passed')
     rc, out, err = execute(['ssh', 'bash -x'])
     self.assertEqual(out, 'passed')
Exemple #4
0
def test_deploy(config, info, messages):
    sh = RemoteShell(config['sql/host'])
    sh.execute('# Running deployment planning here')
Exemple #5
0
def test_deploy(config, info, messages):
    sh = RemoteShell(config['sql/host'])
    sh.execute('# Running deployment planning here')