How to use _kill_agent method in yandex-tank

Best Python code snippet using yandex-tank

client.py

Source: client.py Github

copy

Full Screen

...346 self.ssh.rm_r(self.path['AGENT_REMOTE_FOLDER'])347 except Exception:348 logger.error("Unable to get agent artefacts", exc_info=True)349 if not self.successfull_stop:350 self._kill_agent()351 return log_filename, data_filename352 def _wait_for_stop(self):353 done = False354 agent_stop_timeout = 5355 while not done:356 if not self.stop_sent:357 logger.info('Session was broken on %s, switch to kill', self.host)358 break359 if (self.stop_sent + agent_stop_timeout) < time.time():360 logger.info("Agent hasn't finished in %s sec, force quit on %s",361 agent_stop_timeout,362 self.host)363 break364 if self.session.finished():365 logger.debug('Session ended with status %s with %s',366 self.session.exit_status(),367 self.host)368 self.successfull_stop = True369 done = True370 agent_stderr = self.session.read_err_maybe()371 if agent_stderr and 'stopped' in agent_stderr:372 logger.debug('Got stopped message from %s', self.host)373 done = True374 def _kill_agent(self):375 if self.agent_remote_folder:376 tpl = ('main_p=$(pgrep -f "[p]ython.*{folder}");'377 'tlgrf_p=$(pgrep -f "[t]elegraf.*{folder}");'378 'descendent_pids(){{ if [ "x$1" != "x" ]; then '379 'pids=$(pgrep -P $1); echo $pids;'380 'for p in $pids; do descendent_pids $p; done; fi }};'381 'all_p=$(descendent_pids ${{main_p}});'382 'if [ "x${{main_p}}${{tlgrf_p}}${{all_p}}" != "x" ] ; then '383 ' kill -9 ${{main_p}} ${{tlgrf_p}} ${{all_p}}; fi')384 cmd = tpl.format(folder=self.agent_remote_folder)385 out, errors, err_code = self.ssh.execute(cmd)386 if errors:387 logger.error(388 "[%s] error while killing agent: '%s'",...

Full Screen

Full Screen

SSHer.py

Source: SSHer.py Github

copy

Full Screen

...198 cmd = ' '.join(pieces)199 self._info.log( 'execute: %s' % cmd )200 failed, output, error = spawn( cmd )201 if private_key:202 self._kill_agent(pid)203 if failed and not suppressException:204 msg = '%r failed: %s' % (205 cmd, error )206 raise RemoteAccessError, msg207 return failed, output, error208 def _create_agent(self):209 cmd = 'eval `ssh-agent` > /​dev/​null; echo $SSH_AUTH_SOCK; echo $SSH_AGENT_PID'210 failed, output, error = spawn( cmd )211 if failed:212 msg = '%r failed: %s' % (213 cmd, error )214 raise RuntimeError, msg215 lines = output.splitlines()216 socket = lines[0].strip()217 pid = lines[1].strip()218 return socket, pid219 220 def _create_agent_with_key(self, private_key):221 socket, pid = self._create_agent()222 cmd = 'SSH_AUTH_SOCK=%s ssh-add "%s" > /​dev/​null; ' % (223 socket, private_key)224 failed, output, error = spawn( cmd )225 if failed:226 self._kill_agent(pid)227 msg = '%r failed: %s' % (228 cmd, error )229 raise RuntimeError, msg230 return socket, pid231 def _kill_agent(self, pid):232 cmd = 'kill -9 %s' % pid233 failed, output, error = spawn( cmd )234 if failed:235 msg = '%r failed: %s' % (236 cmd, error )237 raise RuntimeError, msg238 return239 def _isdirectory(self, server, path):240 if _localhost(server):241 return os.path.isdir(path)242 cmd = '''python -c "import os; print int(os.path.isdir('%s'))"''' % path243 failed, out, err = self.execute(cmd, server, '')244 return int(out)245 ...

Full Screen

Full Screen

__init__.py

Source: __init__.py Github

copy

Full Screen

2from . import parse_agent_variables3import logging4import os5import atexit6def _kill_agent():7 logging.info('killing previously started ssh-agent')8 subprocess.run(['ssh-agent', '-k'])9 del os.environ['SSH_AUTH_SOCK']10 del os.environ['SSH_AGENT_PID']11def _setup_agent():12 process = subprocess.run(['ssh-agent', '-s'], stdout=subprocess.PIPE, text=True)13 agent_data = parse_agent_variables.parse(process.stdout)14 logging.info('ssh agent data: {}'.format(agent_data))15 logging.info('exporting ssh agent environment variables')16 os.environ['SSH_AUTH_SOCK'] = agent_data['SSH_AUTH_SOCK']17 os.environ['SSH_AGENT_PID'] = agent_data['SSH_AGENT_PID']18 atexit.register(_kill_agent)19def agent_up():20 return os.environ.get('SSH_AUTH_SOCK') is not None...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Webinar: Move Forward With An Effective Test Automation Strategy [Voices of Community]

The key to successful test automation is to focus on tasks that maximize the return on investment (ROI), ensuring that you are automating the right tests and automating them in the right way. This is where test automation strategies come into play.

Dec’22 Updates: The All-New LT Browser 2.0, XCUI App Automation with HyperExecute, And More!

Greetings folks! With the new year finally upon us, we’re excited to announce a collection of brand-new product updates. At LambdaTest, we strive to provide you with a comprehensive test orchestration and execution platform to ensure the ultimate web and mobile experience.

Developers and Bugs &#8211; why are they happening again and again?

Entering the world of testers, one question started to formulate in my mind: “what is the reason that bugs happen?”.

Test Optimization for Continuous Integration

“Test frequently and early.” If you’ve been following my testing agenda, you’re probably sick of hearing me repeat that. However, it is making sense that if your tests detect an issue soon after it occurs, it will be easier to resolve. This is one of the guiding concepts that makes continuous integration such an effective method. I’ve encountered several teams who have a lot of automated tests but don’t use them as part of a continuous integration approach. There are frequently various reasons why the team believes these tests cannot be used with continuous integration. Perhaps the tests take too long to run, or they are not dependable enough to provide correct results on their own, necessitating human interpretation.

13 Best Java Testing Frameworks For 2023

The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run yandex-tank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful