def run(self, **kwargs): Test = kwargs['test'] func = self.command_ref[Test['name']] Test['state'] = 'running' with cpulse_lock.thread_lock(Test, self.conductor_id): self.update_test(Test['uuid'], Test) result = func() if result[0] == 200: Test['state'] = 'success' Test['result'] = textwrap.fill(str(result[1]), 40) else: Test['state'] = 'failed' Test['result'] = textwrap.fill(str(result[1]), 40) with cpulse_lock.thread_lock(Test, self.conductor_id): self.update_test(Test['uuid'], Test)
def run(self, **kwargs): Test = kwargs['test'] func = self.command_ref[Test['name']] Test['state'] = 'running' try: with cpulse_lock.thread_lock(Test, self.conductor_id): LOG.info(('Updating db entry for the test %s') % Test['name']) self.update_test(Test['uuid'], Test) LOG.debug(('Running Test %s') % Test['name']) try: result = func() except Exception as e: result = [404, str(e)] if result[0] == 200: Test['state'] = 'success' Test['result'] = textwrap.fill(str(result[1]), 40) elif result[0] == 300: Test['state'] = 'skipped' Test['result'] = textwrap.fill(str(result[1]), 40) else: Test['state'] = 'failed' Test['result'] = textwrap.fill(str(result[1]), 40) LOG.debug( ('Test State %s for test %s') % (Test['state'], Test['name'])) LOG.info(('Updating db entry for the test %s') % Test['name']) self.update_test(Test['uuid'], Test) except Exception as e: LOG.debug("Not Running test in this run") return
def run(self, **kwargs): Test = kwargs['test'] func = self.command_ref[Test['name']] Test['state'] = 'running' try: with cpulse_lock.thread_lock(Test, self.conductor_id): LOG.info(('Updating db entry for the test %s') % Test['name']) self.update_test(Test['uuid'], Test) LOG.debug(('Running Test %s') % Test['name']) try: result = func() except Exception as e: result = [404, str(e)] if result[0] == 200: Test['state'] = 'success' Test['result'] = textwrap.fill(str(result[1]), 40) elif result[0] == 300: Test['state'] = 'skipped' Test['result'] = textwrap.fill(str(result[1]), 40) else: Test['state'] = 'failed' Test['result'] = textwrap.fill(str(result[1]), 40) LOG.debug(('Test State %s for test %s') % (Test['state'], Test['name'])) LOG.info(('Updating db entry for the test %s') % Test['name']) self.update_test(Test['uuid'], Test) except Exception as e: LOG.debug("Not Running test in this run") return
def create_task_entry(self, context): test = {} test['state'] = 'created' test['testtype'] = 'periodic' test['name'] = self.task test['uuid'] = utils.generate_uuid() new_test = objects.Cpulse(context, **test) with cpulse_lock.thread_lock(new_test, self.conductor_id): new_test.create() return new_test
def create_task_entry(self, context): test = {} test['state'] = 'scheduled' test['testtype'] = 'periodic' test['name'] = self.task test['uuid'] = utils.generate_uuid() new_test = objects.Cpulse(context, **test) with cpulse_lock.thread_lock(new_test, self.conductor_id): LOG.info(('Creating db entry for the test %s') % test['name']) new_test.create() return new_test