How to use task method in locust

Best Python code snippet using locust

task.js

Source:task.js Github

copy

Full Screen

1/**2 * Support for concurrent task management and synchronization in web3 * applications.4 *5 * @author Dave Longley6 * @author David I. Lehn <dlehn@digitalbazaar.com>7 *8 * Copyright (c) 2009-2013 Digital Bazaar, Inc.9 */10var forge = require('./forge');11require('./debug');12require('./log');13require('./util');14// logging category15var cat = 'forge.task';16// verbose level17// 0: off, 1: a little, 2: a whole lot18// Verbose debug logging is surrounded by a level check to avoid the19// performance issues with even calling the logging code regardless if it20// is actually logged. For performance reasons this should not be set to 221// for production use.22// ex: if(sVL >= 2) forge.log.verbose(....)23var sVL = 0;24// track tasks for debugging25var sTasks = {};26var sNextTaskId = 0;27// debug access28forge.debug.set(cat, 'tasks', sTasks);29// a map of task type to task queue30var sTaskQueues = {};31// debug access32forge.debug.set(cat, 'queues', sTaskQueues);33// name for unnamed tasks34var sNoTaskName = '?';35// maximum number of doNext() recursions before a context swap occurs36// FIXME: might need to tweak this based on the browser37var sMaxRecursions = 30;38// time slice for doing tasks before a context swap occurs39// FIXME: might need to tweak this based on the browser40var sTimeSlice = 20;41/**42 * Task states.43 *44 * READY: ready to start processing45 * RUNNING: task or a subtask is running46 * BLOCKED: task is waiting to acquire N permits to continue47 * SLEEPING: task is sleeping for a period of time48 * DONE: task is done49 * ERROR: task has an error50 */51var READY = 'ready';52var RUNNING = 'running';53var BLOCKED = 'blocked';54var SLEEPING = 'sleeping';55var DONE = 'done';56var ERROR = 'error';57/**58 * Task actions. Used to control state transitions.59 *60 * STOP: stop processing61 * START: start processing tasks62 * BLOCK: block task from continuing until 1 or more permits are released63 * UNBLOCK: release one or more permits64 * SLEEP: sleep for a period of time65 * WAKEUP: wakeup early from SLEEPING state66 * CANCEL: cancel further tasks67 * FAIL: a failure occured68 */69var STOP = 'stop';70var START = 'start';71var BLOCK = 'block';72var UNBLOCK = 'unblock';73var SLEEP = 'sleep';74var WAKEUP = 'wakeup';75var CANCEL = 'cancel';76var FAIL = 'fail';77/**78 * State transition table.79 *80 * nextState = sStateTable[currentState][action]81 */82var sStateTable = {};83sStateTable[READY] = {};84sStateTable[READY][STOP] = READY;85sStateTable[READY][START] = RUNNING;86sStateTable[READY][CANCEL] = DONE;87sStateTable[READY][FAIL] = ERROR;88sStateTable[RUNNING] = {};89sStateTable[RUNNING][STOP] = READY;90sStateTable[RUNNING][START] = RUNNING;91sStateTable[RUNNING][BLOCK] = BLOCKED;92sStateTable[RUNNING][UNBLOCK] = RUNNING;93sStateTable[RUNNING][SLEEP] = SLEEPING;94sStateTable[RUNNING][WAKEUP] = RUNNING;95sStateTable[RUNNING][CANCEL] = DONE;96sStateTable[RUNNING][FAIL] = ERROR;97sStateTable[BLOCKED] = {};98sStateTable[BLOCKED][STOP] = BLOCKED;99sStateTable[BLOCKED][START] = BLOCKED;100sStateTable[BLOCKED][BLOCK] = BLOCKED;101sStateTable[BLOCKED][UNBLOCK] = BLOCKED;102sStateTable[BLOCKED][SLEEP] = BLOCKED;103sStateTable[BLOCKED][WAKEUP] = BLOCKED;104sStateTable[BLOCKED][CANCEL] = DONE;105sStateTable[BLOCKED][FAIL] = ERROR;106sStateTable[SLEEPING] = {};107sStateTable[SLEEPING][STOP] = SLEEPING;108sStateTable[SLEEPING][START] = SLEEPING;109sStateTable[SLEEPING][BLOCK] = SLEEPING;110sStateTable[SLEEPING][UNBLOCK] = SLEEPING;111sStateTable[SLEEPING][SLEEP] = SLEEPING;112sStateTable[SLEEPING][WAKEUP] = SLEEPING;113sStateTable[SLEEPING][CANCEL] = DONE;114sStateTable[SLEEPING][FAIL] = ERROR;115sStateTable[DONE] = {};116sStateTable[DONE][STOP] = DONE;117sStateTable[DONE][START] = DONE;118sStateTable[DONE][BLOCK] = DONE;119sStateTable[DONE][UNBLOCK] = DONE;120sStateTable[DONE][SLEEP] = DONE;121sStateTable[DONE][WAKEUP] = DONE;122sStateTable[DONE][CANCEL] = DONE;123sStateTable[DONE][FAIL] = ERROR;124sStateTable[ERROR] = {};125sStateTable[ERROR][STOP] = ERROR;126sStateTable[ERROR][START] = ERROR;127sStateTable[ERROR][BLOCK] = ERROR;128sStateTable[ERROR][UNBLOCK] = ERROR;129sStateTable[ERROR][SLEEP] = ERROR;130sStateTable[ERROR][WAKEUP] = ERROR;131sStateTable[ERROR][CANCEL] = ERROR;132sStateTable[ERROR][FAIL] = ERROR;133/**134 * Creates a new task.135 *136 * @param options options for this task137 * run: the run function for the task (required)138 * name: the run function for the task (optional)139 * parent: parent of this task (optional)140 *141 * @return the empty task.142 */143var Task = function(options) {144 // task id145 this.id = -1;146 // task name147 this.name = options.name || sNoTaskName;148 // task has no parent149 this.parent = options.parent || null;150 // save run function151 this.run = options.run;152 // create a queue of subtasks to run153 this.subtasks = [];154 // error flag155 this.error = false;156 // state of the task157 this.state = READY;158 // number of times the task has been blocked (also the number159 // of permits needed to be released to continue running)160 this.blocks = 0;161 // timeout id when sleeping162 this.timeoutId = null;163 // no swap time yet164 this.swapTime = null;165 // no user data166 this.userData = null;167 // initialize task168 // FIXME: deal with overflow169 this.id = sNextTaskId++;170 sTasks[this.id] = this;171 if(sVL >= 1) {172 forge.log.verbose(cat, '[%s][%s] init', this.id, this.name, this);173 }174};175/**176 * Logs debug information on this task and the system state.177 */178Task.prototype.debug = function(msg) {179 msg = msg || '';180 forge.log.debug(cat, msg,181 '[%s][%s] task:', this.id, this.name, this,182 'subtasks:', this.subtasks.length,183 'queue:', sTaskQueues);184};185/**186 * Adds a subtask to run after task.doNext() or task.fail() is called.187 *188 * @param name human readable name for this task (optional).189 * @param subrun a function to run that takes the current task as190 * its first parameter.191 *192 * @return the current task (useful for chaining next() calls).193 */194Task.prototype.next = function(name, subrun) {195 // juggle parameters if it looks like no name is given196 if(typeof(name) === 'function') {197 subrun = name;198 // inherit parent's name199 name = this.name;200 }201 // create subtask, set parent to this task, propagate callbacks202 var subtask = new Task({203 run: subrun,204 name: name,205 parent: this206 });207 // start subtasks running208 subtask.state = RUNNING;209 subtask.type = this.type;210 subtask.successCallback = this.successCallback || null;211 subtask.failureCallback = this.failureCallback || null;212 // queue a new subtask213 this.subtasks.push(subtask);214 return this;215};216/**217 * Adds subtasks to run in parallel after task.doNext() or task.fail()218 * is called.219 *220 * @param name human readable name for this task (optional).221 * @param subrun functions to run that take the current task as222 * their first parameter.223 *224 * @return the current task (useful for chaining next() calls).225 */226Task.prototype.parallel = function(name, subrun) {227 // juggle parameters if it looks like no name is given228 if(forge.util.isArray(name)) {229 subrun = name;230 // inherit parent's name231 name = this.name;232 }233 // Wrap parallel tasks in a regular task so they are started at the234 // proper time.235 return this.next(name, function(task) {236 // block waiting for subtasks237 var ptask = task;238 ptask.block(subrun.length);239 // we pass the iterator from the loop below as a parameter240 // to a function because it is otherwise included in the241 // closure and changes as the loop changes -- causing i242 // to always be set to its highest value243 var startParallelTask = function(pname, pi) {244 forge.task.start({245 type: pname,246 run: function(task) {247 subrun[pi](task);248 },249 success: function(task) {250 ptask.unblock();251 },252 failure: function(task) {253 ptask.unblock();254 }255 });256 };257 for(var i = 0; i < subrun.length; i++) {258 // Type must be unique so task starts in parallel:259 // name + private string + task id + sub-task index260 // start tasks in parallel and unblock when the finish261 var pname = name + '__parallel-' + task.id + '-' + i;262 var pi = i;263 startParallelTask(pname, pi);264 }265 });266};267/**268 * Stops a running task.269 */270Task.prototype.stop = function() {271 this.state = sStateTable[this.state][STOP];272};273/**274 * Starts running a task.275 */276Task.prototype.start = function() {277 this.error = false;278 this.state = sStateTable[this.state][START];279 // try to restart280 if(this.state === RUNNING) {281 this.start = new Date();282 this.run(this);283 runNext(this, 0);284 }285};286/**287 * Blocks a task until it one or more permits have been released. The288 * task will not resume until the requested number of permits have289 * been released with call(s) to unblock().290 *291 * @param n number of permits to wait for(default: 1).292 */293Task.prototype.block = function(n) {294 n = typeof(n) === 'undefined' ? 1 : n;295 this.blocks += n;296 if(this.blocks > 0) {297 this.state = sStateTable[this.state][BLOCK];298 }299};300/**301 * Releases a permit to unblock a task. If a task was blocked by302 * requesting N permits via block(), then it will only continue303 * running once enough permits have been released via unblock() calls.304 *305 * If multiple processes need to synchronize with a single task then306 * use a condition variable (see forge.task.createCondition). It is307 * an error to unblock a task more times than it has been blocked.308 *309 * @param n number of permits to release (default: 1).310 *311 * @return the current block count (task is unblocked when count is 0)312 */313Task.prototype.unblock = function(n) {314 n = typeof(n) === 'undefined' ? 1 : n;315 this.blocks -= n;316 if(this.blocks === 0 && this.state !== DONE) {317 this.state = RUNNING;318 runNext(this, 0);319 }320 return this.blocks;321};322/**323 * Sleep for a period of time before resuming tasks.324 *325 * @param n number of milliseconds to sleep (default: 0).326 */327Task.prototype.sleep = function(n) {328 n = typeof(n) === 'undefined' ? 0 : n;329 this.state = sStateTable[this.state][SLEEP];330 var self = this;331 this.timeoutId = setTimeout(function() {332 self.timeoutId = null;333 self.state = RUNNING;334 runNext(self, 0);335 }, n);336};337/**338 * Waits on a condition variable until notified. The next task will339 * not be scheduled until notification. A condition variable can be340 * created with forge.task.createCondition().341 *342 * Once cond.notify() is called, the task will continue.343 *344 * @param cond the condition variable to wait on.345 */346Task.prototype.wait = function(cond) {347 cond.wait(this);348};349/**350 * If sleeping, wakeup and continue running tasks.351 */352Task.prototype.wakeup = function() {353 if(this.state === SLEEPING) {354 cancelTimeout(this.timeoutId);355 this.timeoutId = null;356 this.state = RUNNING;357 runNext(this, 0);358 }359};360/**361 * Cancel all remaining subtasks of this task.362 */363Task.prototype.cancel = function() {364 this.state = sStateTable[this.state][CANCEL];365 // remove permits needed366 this.permitsNeeded = 0;367 // cancel timeouts368 if(this.timeoutId !== null) {369 cancelTimeout(this.timeoutId);370 this.timeoutId = null;371 }372 // remove subtasks373 this.subtasks = [];374};375/**376 * Finishes this task with failure and sets error flag. The entire377 * task will be aborted unless the next task that should execute378 * is passed as a parameter. This allows levels of subtasks to be379 * skipped. For instance, to abort only this tasks's subtasks, then380 * call fail(task.parent). To abort this task's subtasks and its381 * parent's subtasks, call fail(task.parent.parent). To abort382 * all tasks and simply call the task callback, call fail() or383 * fail(null).384 *385 * The task callback (success or failure) will always, eventually, be386 * called.387 *388 * @param next the task to continue at, or null to abort entirely.389 */390Task.prototype.fail = function(next) {391 // set error flag392 this.error = true;393 // finish task394 finish(this, true);395 if(next) {396 // propagate task info397 next.error = this.error;398 next.swapTime = this.swapTime;399 next.userData = this.userData;400 // do next task as specified401 runNext(next, 0);402 } else {403 if(this.parent !== null) {404 // finish root task (ensures it is removed from task queue)405 var parent = this.parent;406 while(parent.parent !== null) {407 // propagate task info408 parent.error = this.error;409 parent.swapTime = this.swapTime;410 parent.userData = this.userData;411 parent = parent.parent;412 }413 finish(parent, true);414 }415 // call failure callback if one exists416 if(this.failureCallback) {417 this.failureCallback(this);418 }419 }420};421/**422 * Asynchronously start a task.423 *424 * @param task the task to start.425 */426var start = function(task) {427 task.error = false;428 task.state = sStateTable[task.state][START];429 setTimeout(function() {430 if(task.state === RUNNING) {431 task.swapTime = +new Date();432 task.run(task);433 runNext(task, 0);434 }435 }, 0);436};437/**438 * Run the next subtask or finish this task.439 *440 * @param task the task to process.441 * @param recurse the recursion count.442 */443var runNext = function(task, recurse) {444 // get time since last context swap (ms), if enough time has passed set445 // swap to true to indicate that doNext was performed asynchronously446 // also, if recurse is too high do asynchronously447 var swap =448 (recurse > sMaxRecursions) ||449 (+new Date() - task.swapTime) > sTimeSlice;450 var doNext = function(recurse) {451 recurse++;452 if(task.state === RUNNING) {453 if(swap) {454 // update swap time455 task.swapTime = +new Date();456 }457 if(task.subtasks.length > 0) {458 // run next subtask459 var subtask = task.subtasks.shift();460 subtask.error = task.error;461 subtask.swapTime = task.swapTime;462 subtask.userData = task.userData;463 subtask.run(subtask);464 if(!subtask.error) {465 runNext(subtask, recurse);466 }467 } else {468 finish(task);469 if(!task.error) {470 // chain back up and run parent471 if(task.parent !== null) {472 // propagate task info473 task.parent.error = task.error;474 task.parent.swapTime = task.swapTime;475 task.parent.userData = task.userData;476 // no subtasks left, call run next subtask on parent477 runNext(task.parent, recurse);478 }479 }480 }481 }482 };483 if(swap) {484 // we're swapping, so run asynchronously485 setTimeout(doNext, 0);486 } else {487 // not swapping, so run synchronously488 doNext(recurse);489 }490};491/**492 * Finishes a task and looks for the next task in the queue to start.493 *494 * @param task the task to finish.495 * @param suppressCallbacks true to suppress callbacks.496 */497var finish = function(task, suppressCallbacks) {498 // subtask is now done499 task.state = DONE;500 delete sTasks[task.id];501 if(sVL >= 1) {502 forge.log.verbose(cat, '[%s][%s] finish',503 task.id, task.name, task);504 }505 // only do queue processing for root tasks506 if(task.parent === null) {507 // report error if queue is missing508 if(!(task.type in sTaskQueues)) {509 forge.log.error(cat,510 '[%s][%s] task queue missing [%s]',511 task.id, task.name, task.type);512 } else if(sTaskQueues[task.type].length === 0) {513 // report error if queue is empty514 forge.log.error(cat,515 '[%s][%s] task queue empty [%s]',516 task.id, task.name, task.type);517 } else if(sTaskQueues[task.type][0] !== task) {518 // report error if this task isn't the first in the queue519 forge.log.error(cat,520 '[%s][%s] task not first in queue [%s]',521 task.id, task.name, task.type);522 } else {523 // remove ourselves from the queue524 sTaskQueues[task.type].shift();525 // clean up queue if it is empty526 if(sTaskQueues[task.type].length === 0) {527 if(sVL >= 1) {528 forge.log.verbose(cat, '[%s][%s] delete queue [%s]',529 task.id, task.name, task.type);530 }531 /* Note: Only a task can delete a queue of its own type. This532 is used as a way to synchronize tasks. If a queue for a certain533 task type exists, then a task of that type is running.534 */535 delete sTaskQueues[task.type];536 } else {537 // dequeue the next task and start it538 if(sVL >= 1) {539 forge.log.verbose(cat,540 '[%s][%s] queue start next [%s] remain:%s',541 task.id, task.name, task.type,542 sTaskQueues[task.type].length);543 }544 sTaskQueues[task.type][0].start();545 }546 }547 if(!suppressCallbacks) {548 // call final callback if one exists549 if(task.error && task.failureCallback) {550 task.failureCallback(task);551 } else if(!task.error && task.successCallback) {552 task.successCallback(task);553 }554 }555 }556};557/* Tasks API */558module.exports = forge.task = forge.task || {};559/**560 * Starts a new task that will run the passed function asynchronously.561 *562 * In order to finish the task, either task.doNext() or task.fail()563 * *must* be called.564 *565 * The task must have a type (a string identifier) that can be used to566 * synchronize it with other tasks of the same type. That type can also567 * be used to cancel tasks that haven't started yet.568 *569 * To start a task, the following object must be provided as a parameter570 * (each function takes a task object as its first parameter):571 *572 * {573 * type: the type of task.574 * run: the function to run to execute the task.575 * success: a callback to call when the task succeeds (optional).576 * failure: a callback to call when the task fails (optional).577 * }578 *579 * @param options the object as described above.580 */581forge.task.start = function(options) {582 // create a new task583 var task = new Task({584 run: options.run,585 name: options.name || sNoTaskName586 });587 task.type = options.type;588 task.successCallback = options.success || null;589 task.failureCallback = options.failure || null;590 // append the task onto the appropriate queue591 if(!(task.type in sTaskQueues)) {592 if(sVL >= 1) {593 forge.log.verbose(cat, '[%s][%s] create queue [%s]',594 task.id, task.name, task.type);595 }596 // create the queue with the new task597 sTaskQueues[task.type] = [task];598 start(task);599 } else {600 // push the task onto the queue, it will be run after a task601 // with the same type completes602 sTaskQueues[options.type].push(task);603 }604};605/**606 * Cancels all tasks of the given type that haven't started yet.607 *608 * @param type the type of task to cancel.609 */610forge.task.cancel = function(type) {611 // find the task queue612 if(type in sTaskQueues) {613 // empty all but the current task from the queue614 sTaskQueues[type] = [sTaskQueues[type][0]];615 }616};617/**618 * Creates a condition variable to synchronize tasks. To make a task wait619 * on the condition variable, call task.wait(condition). To notify all620 * tasks that are waiting, call condition.notify().621 *622 * @return the condition variable.623 */624forge.task.createCondition = function() {625 var cond = {626 // all tasks that are blocked627 tasks: {}628 };629 /**630 * Causes the given task to block until notify is called. If the task631 * is already waiting on this condition then this is a no-op.632 *633 * @param task the task to cause to wait.634 */635 cond.wait = function(task) {636 // only block once637 if(!(task.id in cond.tasks)) {638 task.block();639 cond.tasks[task.id] = task;640 }641 };642 /**643 * Notifies all waiting tasks to wake up.644 */645 cond.notify = function() {646 // since unblock() will run the next task from here, make sure to647 // clear the condition's blocked task list before unblocking648 var tmp = cond.tasks;649 cond.tasks = {};650 for(var id in tmp) {651 tmp[id].unblock();652 }653 };654 return cond;...

Full Screen

Full Screen

test_play_iterator.py

Source:test_play_iterator.py Github

copy

Full Screen

...137 )138 # lookup up an original task139 target_task = p._entries[0].tasks[0].block[0]140 task_copy = target_task.copy(exclude_parent=True)141 found_task = itr.get_original_task(hosts[0], task_copy)142 self.assertEqual(target_task, found_task)143 bad_task = Task()144 found_task = itr.get_original_task(hosts[0], bad_task)145 self.assertIsNone(found_task)146 # pre task147 (host_state, task) = itr.get_next_task_for_host(hosts[0])148 self.assertIsNotNone(task)149 self.assertEqual(task.action, 'debug')150 # implicit meta: flush_handlers151 (host_state, task) = itr.get_next_task_for_host(hosts[0])152 self.assertIsNotNone(task)153 self.assertEqual(task.action, 'meta')154 # role task155 (host_state, task) = itr.get_next_task_for_host(hosts[0])156 self.assertIsNotNone(task)157 self.assertEqual(task.action, 'debug')158 self.assertEqual(task.name, "role task")...

Full Screen

Full Screen

ecs_task.py

Source:ecs_task.py Github

copy

Full Screen

...184 for c in response['taskArns']:185 if c.endswith(service_name):186 return c187 return None188 def run_task(self, cluster, task_definition, overrides, count, startedBy):189 if overrides is None:190 overrides = dict()191 response = self.ecs.run_task(192 cluster=cluster,193 taskDefinition=task_definition,194 overrides=overrides,195 count=count,196 startedBy=startedBy)197 # include tasks and failures198 return response['tasks']199 def start_task(self, cluster, task_definition, overrides, container_instances, startedBy):200 args = dict()201 if cluster:202 args['cluster'] = cluster203 if task_definition:204 args['taskDefinition']=task_definition205 if overrides:206 args['overrides']=overrides207 if container_instances:208 args['containerInstances']=container_instances209 if startedBy:210 args['startedBy']=startedBy211 response = self.ecs.start_task(**args)212 # include tasks and failures213 return response['tasks']214 def stop_task(self, cluster, task):215 response = self.ecs.stop_task(cluster=cluster, task=task)216 return response['task']217def main():218 argument_spec = ec2_argument_spec()219 argument_spec.update(dict(220 operation=dict(required=True, choices=['run', 'start', 'stop'] ),221 cluster=dict(required=False, type='str' ), # R S P222 task_definition=dict(required=False, type='str' ), # R* S*223 overrides=dict(required=False, type='dict'), # R S224 count=dict(required=False, type='int' ), # R225 task=dict(required=False, type='str' ), # P*226 container_instances=dict(required=False, type='list'), # S*227 started_by=dict(required=False, type='str' ) # R S228 ))229 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)230 # Validate Requirements231 if not HAS_BOTO:232 module.fail_json(msg='boto is required.')233 if not HAS_BOTO3:234 module.fail_json(msg='boto3 is required.')235 # Validate Inputs236 if module.params['operation'] == 'run':237 if not 'task_definition' in module.params and module.params['task_definition'] is None:238 module.fail_json(msg="To run a task, a task_definition must be specified")239 task_to_list = module.params['task_definition']240 status_type = "RUNNING"241 if module.params['operation'] == 'start':242 if not 'task_definition' in module.params and module.params['task_definition'] is None:243 module.fail_json(msg="To start a task, a task_definition must be specified")244 if not 'container_instances' in module.params and module.params['container_instances'] is None:245 module.fail_json(msg="To start a task, container instances must be specified")246 task_to_list = module.params['task']247 status_type = "RUNNING"248 if module.params['operation'] == 'stop':249 if not 'task' in module.params and module.params['task'] is None:250 module.fail_json(msg="To stop a task, a task must be specified")251 if not 'task_definition' in module.params and module.params['task_definition'] is None:252 module.fail_json(msg="To stop a task, a task definition must be specified")253 task_to_list = module.params['task_definition']254 status_type = "STOPPED"255 service_mgr = EcsExecManager(module)256 existing = service_mgr.list_tasks(module.params['cluster'], task_to_list, status_type)257 results = dict(changed=False)258 if module.params['operation'] == 'run':259 if existing:260 # TBD - validate the rest of the details261 results['task']=existing262 else:263 if not module.check_mode:264 results['task'] = service_mgr.run_task(265 module.params['cluster'],266 module.params['task_definition'],267 module.params['overrides'],268 module.params['count'],269 module.params['started_by'])270 results['changed'] = True271 elif module.params['operation'] == 'start':272 if existing:273 # TBD - validate the rest of the details274 results['task']=existing275 else:276 if not module.check_mode:277 results['task'] = service_mgr.start_task(278 module.params['cluster'],279 module.params['task_definition'],280 module.params['overrides'],281 module.params['container_instances'],282 module.params['started_by']283 )284 results['changed'] = True285 elif module.params['operation'] == 'stop':286 if existing:287 results['task']=existing288 else:289 if not module.check_mode:290 # it exists, so we should delete it and mark changed.291 # return info about the cluster deleted292 results['task'] = service_mgr.stop_task(293 module.params['cluster'],294 module.params['task']295 )296 results['changed'] = True297 module.exit_json(**results)298if __name__ == '__main__':...

Full Screen

Full Screen

test_tasks.py

Source:test_tasks.py Github

copy

Full Screen

...102 rollout.save()103 rollouts[cls][sigs] = rollout104 rollout_ids[cls][sigs] = rollout.id105 if cls is DelayTask:106 task = create_task(rollout, DelayTask, seconds=15)107 tasks[cls][sigs] = task108 else:109 t1, t2, t3 = [create_task(rollout, DelayTask, seconds=15) for _ in range(3)]110 task = create_task(rollout, cls, [t1, t2, t3])111 tasks[cls][sigs] = t3112 for cls in classes:113 for sigs in signals:114 rollout = rollouts[cls][sigs]115 rollout.rollout_async()116 # Enough time for rollouts to start117 time.sleep(0.5)118 for cls in classes:119 for sigs in signals:120 id = rollout_ids[cls][sigs]121 for sig in sigs:122 self.assertTrue(Rollout._can_signal(id, sig))123 self.assertTrue(Rollout._do_signal(id, sig))124 self.assertTrue(Rollout._is_signalling(id, sig))...

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