How to use _launch_processes method in Molotov

Best Python code snippet using molotov_python

test_netns_cleanup.py

Source:test_netns_cleanup.py Github

copy

Full Screen

...56 # tests, as otherwise cleanup will kill them all57 self.get_namespaces.return_value = [l3_namespace, dhcp_namespace]58 # launch processes in each namespace to make sure they're59 # killed during cleanup60 procs_launched = self._launch_processes([l3_namespace, dhcp_namespace])61 self.assertIsNot(procs_launched, 0)62 common_utils.wait_until_true(63 lambda: self._get_num_spawned_procs() == procs_launched,64 timeout=15,65 exception=Exception("Didn't spawn expected number of processes"))66 netns_cleanup.cleanup_network_namespaces(self.conf)67 self.get_namespaces_p.stop()68 namespaces_now = ip_lib.IPWrapper.get_namespaces()69 procs_after = self._get_num_spawned_procs()70 self.assertEqual(procs_after, 0)71 self.assertNotIn(l3_namespace, namespaces_now)72 self.assertNotIn(dhcp_namespace, namespaces_now)73 @staticmethod74 def _launch_processes(namespaces):75 """76 Launch processes in the specified namespaces.77 This function will spawn processes inside the given namespaces:78 - 6 processes listening on tcp ports (parent + 5 children)79 - 1 process + 5 subprocesses listening on unix sockets80 - 1 process + 5 subprocesses listening on udp6 sockets81 First two sets of processes will process SIGTERM so when the parent82 gets killed, it will kill all spawned children83 The last set of processes will ignore SIGTERM. This will allow us84 to test the cleanup functionality which will issue a SIGKILL85 to all remaining processes after the SIGTERM attempt86 """87 commands = [['python', process_spawn.__file__,88 '-n', NUM_SUBPROCESSES,...

Full Screen

Full Screen

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 Molotov 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