def test_command_for_this_node(self): n = node.Node(dict( node_username='******', node_host='IP' )) self.assertEquals( "ssh -q -o BatchMode=yes -o UserKnownHostsFile=/dev/null" " -o StrictHostKeyChecking=no USER@IP".split(), n.command_for_this_node())
def __init__(self, env=None): env = env or dict() self.executor = executor.create_executor(env.get('executor')) config = osci_config.Configuration() self.node = node.Node(dict( node_username=config.NODE_USERNAME, node_host=env['node_host'], node_keyfile=config.NODE_KEY ) )
def __init__(self, env=None): env = env or dict() self.executor = executor.create_executor(env.get('executor')) self.node = node.Node(env) self.node.keyfile = osci_config.Configuration().NODE_KEY self.change_ref = env.get('change_ref') self.project_name = env.get('project_name') self.test_runner_url = env.get( 'test_runner_url', 'https://git.openstack.org/stackforge/xenapi-os-testing' )
def copy_dom0_logs(host, user, keyfile, local_directory): dom0_files = ( '/var/log/messages* /var/log/SMlog* /var/log/xensource* /opt/nodepool-scripts/*.log' ) xecutor = Executor() test_node = node.Node( dict(node_username=user, node_host=host, node_keyfile=keyfile)) this_host = localhost.Localhost() xecutor.pipe_run( test_node.command_to_get_dom0_files_as_tgz_to_stdout(dom0_files), this_host.commands_to_extract_stdout_tgz_to(local_directory) )
def test_get_logs(self): n = node.Node() cmds = n.command_to_get_dom0_files_as_tgz_to_stdout('a b c') expected = textwrap.dedent(""" ssh -q -o BatchMode=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no NODE_USERNAME@NODE_HOST sudo -u domzero ssh -q -o BatchMode=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no [email protected] tar --ignore-failed-read -czf - a b c """).strip().split() self.assertEquals(expected, cmds)
def test_copying(self, executor_cls): xecutor = executor_cls.return_value = executor.FakeExecutor() expected_execution = executor.FakeExecutor() this_host = localhost.Localhost() n = node.Node({ 'node_username': '******', 'node_host': 'ip', 'node_keyfile': 'key' }) expected_execution.pipe_run( n.command_to_get_dom0_files_as_tgz_to_stdout( '/var/log/messages* /var/log/SMlog* /var/log/xensource* /opt/nodepool-scripts/*.log' ), this_host.commands_to_extract_stdout_tgz_to('target')) utils.copy_dom0_logs('ip', 'user', 'key', 'target') self.assertEquals(expected_execution.executed_commands, xecutor.executed_commands)