Best Python code snippet using locust
test_runners.py
Source:test_runners.py  
...702            # Add 2 more workers (should be 6 now)703            add_worker()704            add_worker()705            @retry(AssertionError, tries=10, delay=0.5)706            def check_rebalanced_equals():707                for worker in workers:708                    self.assertEqual(1, worker.user_count)709            # Check that all workers have a user count = 1 now710            check_rebalanced_equals()711            # Simulate that some workers are missing by "killing" them abrutly712            for i in range(3):713                workers[i].greenlet.kill(block=True)714            @retry(AssertionError, tries=10, delay=1)715            def check_master_worker_missing_count():716                self.assertEqual(3, len(master.clients.missing))717            # Check that master detected the missing workers718            check_master_worker_missing_count()719            @retry(AssertionError, tries=10, delay=1)720            def check_remaing_worker_new_user_count():721                for i in range(3, 6):722                    self.assertEqual(2, workers[i].user_count)723            # Check that remaining workers have a new count of user due to rebalancing.724            check_remaing_worker_new_user_count()...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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
