def task_prerun_handler(sender=None, task_id=None, task=None, args=None, kwargs=None, signal=None): if sender == run: workload = args[0] prevWorkload = args[1] if workload.preconditions is not None: # block tasks against bucket until pre-conditions met bucket = str(workload.bucket) bs = BucketStatusCacher().bucketstatus(bucket) bs.block(bucket) BucketStatusCacher().store(bs) stat_checker = StatChecker(cfg.COUCHBASE_IP + ":" + cfg.COUCHBASE_PORT, bucket=bucket, username=cfg.COUCHBASE_USER, password=cfg.COUCHBASE_PWD) while not stat_checker.check(workload.preconditions): time.sleep(1) prevWorkload.active = False WorkloadCacher().store(prevWorkload) bs = BucketStatusCacher().bucketstatus(bucket) bs.unblock(bucket) BucketStatusCacher().store(bs)
def sysTestRunner(workload): bucket = str(workload.bucket) latestWorkloadTask = None prevWorkload = None cache = BucketStatusCacher() bucketStatus = cache.bucketstatus(bucket) if bucketStatus is not None: latestWorkloadTask, prevWorkload = bucketStatus.latestWorkloadTask(bucket) else: bucketStatus = BucketStatus(bucket) # make this the latest taskid against this bucket bucketStatus.addTask(bucket, current_task.request.id, workload) cache.store(bucketStatus) if workload.wait is not None: # wait before processing time.sleep(workload.wait) if bucketStatus.mode(bucket) == "blocking": while Cache().retrieve(prevWorkload.id) is not None: time.sleep(2) elif bucketStatus.mode(bucket) == "nonblocking": if prevWorkload is not None: # disable previously running # workload if bucket in nonblocking mode. # if current workload has no preconditions # it's not allowed to override previous workload if workload.preconditions is None: prevWorkload.active = False WorkloadCacher().store(prevWorkload) runTask = run.apply_async(args=[workload, prevWorkload], expires = workload.expires) return runTask.get()
def sysTestRunner(workload): bucket = str(workload.bucket) latestWorkloadTask = None prevWorkload = None cache = BucketStatusCacher() bucketStatus = cache.bucketstatus(bucket) if bucketStatus is not None: latestWorkloadTask, prevWorkload = bucketStatus.latestWorkloadTask( bucket) else: bucketStatus = BucketStatus(bucket) # make this the latest taskid against this bucket bucketStatus.addTask(bucket, current_task.request.id, workload) cache.store(bucketStatus) if workload.wait is not None: # wait before processing time.sleep(workload.wait) if bucketStatus.mode(bucket) == "blocking": while Cache().retrieve(prevWorkload.id) is not None: time.sleep(2) elif bucketStatus.mode(bucket) == "nonblocking": if prevWorkload is not None: # disable previously running # workload if bucket in nonblocking mode. # if current workload has no preconditions # it's not allowed to override previous workload if workload.preconditions is None: prevWorkload.active = False WorkloadCacher().store(prevWorkload) runTask = run.apply_async(args=[workload, prevWorkload], expires=workload.expires) return runTask.get()
def postcondition_handler(): cache = WorkloadCacher() for workload in cache.workloads: if workload.postconditions and workload.active: bucket = workload.bucket bs = BucketStatusCacher().bucketstatus(bucket) bs.block(bucket) BucketStatusCacher().store(bs) stat_checker = StatChecker(cfg.COUCHBASE_IP + ":" + cfg.COUCHBASE_PORT, bucket=bucket, username=cfg.COUCHBASE_USER, password=cfg.COUCHBASE_PWD) status = stat_checker.check(workload.postconditions) if status == True: # unblock bucket and deactivate workload bs = BucketStatusCacher().bucketstatus(bucket) bs.unblock(bucket) BucketStatusCacher().store(bs) workload.active = False cache.store(workload)
def task_prerun_handler(sender=None, task_id=None, task=None, args=None, kwargs=None, signal = None): if sender == run: workload = args[0] prevWorkload = args[1] if workload.preconditions is not None: # block tasks against bucket until pre-conditions met bucket = str(workload.bucket) bs = BucketStatusCacher().bucketstatus(bucket) bs.block(bucket) BucketStatusCacher().store(bs) stat_checker = StatChecker(cfg.COUCHBASE_IP +":"+cfg.COUCHBASE_PORT, bucket = bucket, username = cfg.COUCHBASE_USER, password = cfg.COUCHBASE_PWD) while not stat_checker.check(workload.preconditions): time.sleep(1) prevWorkload.active = False WorkloadCacher().store(prevWorkload) bs = BucketStatusCacher().bucketstatus(bucket) bs.unblock(bucket) BucketStatusCacher().store(bs)
def postcondition_handler(): cache = WorkloadCacher() for workload in cache.workloads: if workload.postconditions and workload.active: bucket = workload.bucket bs = BucketStatusCacher().bucketstatus(bucket) bs.block(bucket) BucketStatusCacher().store(bs) stat_checker = StatChecker(cfg.COUCHBASE_IP +":"+cfg.COUCHBASE_PORT, bucket = bucket, username = cfg.COUCHBASE_USER, password = cfg.COUCHBASE_PWD) status = stat_checker.check(workload.postconditions) if status == True: # unblock bucket and deactivate workload bs = BucketStatusCacher().bucketstatus(bucket) bs.unblock(bucket) BucketStatusCacher().store(bs) workload.active = False cache.store(workload)