def run_prestoadmin(self, command, raise_error=True, cluster=None, **kwargs): if not cluster: cluster = self.cluster command = self.replace_keywords(command, cluster=cluster, **kwargs) return cluster.exec_cmd_on_host( cluster.master, "{path} --user {user} {cmd}".format(path=get_presto_admin_path(), user=cluster.user, cmd=command), raise_error=raise_error, invoke_sudo=False )
def run_prestoadmin_expect(self, command, expect_statements): temp_script = os.path.join(get_install_directory(), 'tmp.expect') script_content = '#!/usr/bin/expect\n' + \ 'spawn %s %s\n%s' % \ (get_presto_admin_path(), command, expect_statements) self.cluster.write_content_to_host(script_content, temp_script, self.cluster.master) self.cluster.exec_cmd_on_host(self.cluster.master, 'chmod +x %s' % temp_script) return self.cluster.exec_cmd_on_host(self.cluster.master, temp_script)
def run_prestoadmin(self, command, raise_error=True, cluster=None, **kwargs): if not cluster: cluster = self.cluster command = self.replace_keywords(command, cluster=cluster, **kwargs) return cluster.exec_cmd_on_host( cluster.master, "{path} --user {user} {cmd}".format(path=get_presto_admin_path(), user=cluster.user, cmd=command), raise_error=raise_error, invoke_sudo=False )
def run_prestoadmin_expect(self, command, expect_statements): temp_script = os.path.join(get_install_directory(), 'tmp.expect') script_content = '#!/usr/bin/expect\n' + \ 'spawn %s %s\n%s' % \ (get_presto_admin_path(), command, expect_statements) self.cluster.write_content_to_host(script_content, temp_script, self.cluster.master) self.cluster.exec_cmd_on_host( self.cluster.master, 'chmod +x %s' % temp_script) return self.cluster.exec_cmd_on_host( self.cluster.master, temp_script)
def test_prestoadmin_no_sudo_popen(self): self.upload_topology() self.setup_for_catalog_add() # We use Popen because docker-py loses the first 8 characters of TTY # output. args = ['docker', 'exec', '-t', self.cluster.master, 'sudo', '-u', 'app-admin', get_presto_admin_path(), 'topology show'] proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) self.assertRegexpMatchesLineByLine( 'Please run presto-admin with sudo.\n' '\\[Errno 13\\] Permission denied: \'.*/.prestoadmin/log' 'presto-admin.log\'', proc.stdout.read())
def test_prestoadmin_no_sudo_popen(self): self.upload_topology() self.setup_for_catalog_add() # We use Popen because docker-py loses the first 8 characters of TTY # output. args = [ 'docker', 'exec', '-t', self.cluster.master, 'sudo', '-u', 'app-admin', get_presto_admin_path(), 'topology show' ] proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) self.assertRegexpMatchesLineByLine( 'Please run presto-admin with sudo.\n' '\\[Errno 13\\] Permission denied: \'.*/.prestoadmin/log' 'presto-admin.log\'', proc.stdout.read())