Best Python code snippet using yandex-tank
instance_plan.py
Source:instance_plan.py  
...151        else:152            raise NotImplementedError(153                'No such load type implemented for instances_schedule: "%s"' %154                step_type)155    def add_all_steps(self, steps):156        for step in steps:157            self.add_step(step)158        return self159    def create(self):160        self.generators.append(cycle([0]))161        return chain(*self.generators)162def create(instances_schedule):163    '''164    Creates load plan timestamps generator165    >>> from util import take166    >>> take(7, LoadPlanBuilder().ramp(5, 4000).create())167    [0, 1000, 2000, 3000, 4000, 0, 0]168    >>> take(7, create(['ramp(5, 4s)']))169    [0, 1000, 2000, 3000, 4000, 0, 0]170    >>> take(12, create(['ramp(5, 4s)', 'wait(5s)', 'ramp(5,4s)']))171    [0, 1000, 2000, 3000, 4000, 9000, 10000, 11000, 12000, 13000, 0, 0]172    >>> take(7, create(['wait(5s)', 'ramp(5, 0)']))173    [5000, 5000, 5000, 5000, 5000, 0, 0]174    >>> take(7, create([]))175    [0, 0, 0, 0, 0, 0, 0]176    >>> take(12, create(['line(1, 9, 4s)']))177    [0, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 0, 0, 0]178    >>> take(12, create(['const(3, 5s)', 'line(7, 11, 2s)']))179    [0, 0, 0, 5000, 5000, 5000, 5000, 5500, 6000, 6500, 7000, 0]180    >>> take(12, create(['step(2, 10, 2, 3s)']))181    [0, 0, 3000, 3000, 6000, 6000, 9000, 9000, 12000, 12000, 0, 0]182    >>> take(12, LoadPlanBuilder().const(3, 1000).line(5, 10, 5000).steps)183    [(3, 1), (5, 1), (6, 1), (7, 1), (8, 1), (9, 1), (10, 1)]184    >>> take(12, LoadPlanBuilder().stairway(100, 950, 100, 30000).steps)185    [(100, 30), (200, 30), (300, 30), (400, 30), (500, 30), (600, 30), (700, 30), (800, 30), (900, 30), (950, 30)]186    >>> LoadPlanBuilder().stairway(100, 950, 100, 30000).instances187    950188    >>> LoadPlanBuilder().const(3, 1000).line(5, 10, 5000).instances189    10190    >>> LoadPlanBuilder().line(1, 100, 60000).instances191    100192    '''193    lpb = LoadPlanBuilder().add_all_steps(instances_schedule)194    lp = lpb.create()195    info.status.publish('duration', 0)196    # info.status.publish('steps', lpb.steps)197    info.status.publish('steps', [])198    info.status.publish('instances', lpb.instances)...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!!
