def test_workerLogging(self): job_uuid = uuid.uuid4() task_uuid = uuid.uuid4() self.disp.jobLoggers[job_uuid] = logManager = mock.MockObject() records = ['log records go here'] self.disp.workerLogging(records, job_uuid, task_uuid) logManager.emitMany._mock.assertCalled(records, task_uuid)
def test_createJob(self): job = self.job mock.mock(dispatcher, 'getHandlerClass') dispatcher.getHandlerClass._mock.setReturn(MockHandler, 'test') saved = [] def db_createJob(newJob, frozen_handler, callback=None): self.assertEqual(job.job_uuid, newJob.job_uuid) ret = newJob.freeze() saved.append(ret) return defer.succeed(ret) self.disp.db._mock.set(createJob=db_createJob) fh_uuid = uuid.uuid4() d = self.disp.createJob(job, firehose=str(fh_uuid)) assert isinstance(d, defer.Deferred) def callback(result): handler = self.disp.jobs.values()[0] self.assertEqual(handler.job.freeze(), saved[0]) self.assertEqual(handler.started, True) self.disp.firehose.subscribe._mock.assertCalled( ('job', str(job.job_uuid)), fh_uuid) self.disp.firehose.publish._mock.assertCalled( ('job', str(job.job_uuid), 'self'), 'created') d.addCallback(callback) return d
def __init__(self, sid=None): if sid is None: sid = uuid.uuid4() self.sid = sid self.subscriptions = set() self.spool = deque() self.response = None self.time_detached = time.time()
def __init__(self, url): if not isinstance(url, rpcproxy.Address): url = rpcproxy.parseAddress(url) assert url.schema == 'http' self.url = url self.sid = uuid.uuid4() self.conn = None self.buffer = ''
def setUp(self): self.cfg = config.DispatcherConfig() self.plugins = pluginlib.PluginManager() mock.mock(dispatcher.Dispatcher, '_start_db') mock.mock(dispatcher.Dispatcher, '_start_filestore') mock.mock(dispatcher.Dispatcher, '_start_bus') mock.mock(dispatcher.Dispatcher, '_start_rpc') self.disp = dispatcher.Dispatcher(self.cfg, self.plugins) self.disp.bus = mock.MockObject() self.disp.db = mock.MockObject() self.disp.firehose = mock.MockObject() self.disp.jobLogger = mock.MockObject() self.job = types.RmakeJob( uuid.uuid4(), 'test', 'spam', data='ham').freeze() self.caps = set([ types.VersionCapability(tuple(dispatcher.PROTOCOL_VERSIONS)), ])
def __init__(self, jobUUID=None, jobId=None, jobName=None, troveList=(), state=JOB_STATE_INIT, status='', owner=None, failure=None, configs=(), timeStarted=None, timeUpdated=None, timeFinished=None): self.jobUUID = jobUUID or uuid.uuid4() self.jobId = jobId self.jobName = jobName self.state = state self.status = status self.owner = owner self.failure = failure self.timeStarted = timeStarted self.timeUpdated = timeUpdated self.timeFinished = timeFinished self.troveContexts = {} self.troves = {} self.configs = dict(configs) for troveTup in troveList: self.addTrove(*troveTup)
def test_main(): from rmake import client from rmake.lib import uuid cli = client.RmakeClient('http://localhost:9999') job = types.RmakeJob(uuid.uuid4(), TEST_JOB, 'nobody') job = cli.createJob(job.freeze(), subscribe=True) for event in cli.firehose.iterAll(): ev = event.event if ev[:2] != ('job', str(job.job_uuid)): continue elif ev[2] == 'self': print event.data if event.data in ('finalized', 'destroyed'): break elif ev[2] == 'status': status = event.data print 'Status: %s %s' % (status.code, status.text) if status.detail: print status.detail else: print ev print event
def setUp(self): self.job = types.RmakeJob( uuid.uuid4(), 'test', 'spam', data='ham').freeze() self.postponedErrors = []