Exemplo n.º 1
0
    def test_getPlan(self):
        p = Plan(owner='me', bucket='b1', events=['hg.push'],
                job_template=JobTemplate(command='echo hello world', interpreter='bash'),
                )
        _id = self.s.addPlan(p)

        p1 = self.s.getPlan(_id)

        self.assertEquals(p.asDict(), p1.asDict())
Exemplo n.º 2
0
    def test_findPlansByEventType(self):
        p = Plan(owner='me', bucket='b1', events=['hg.push'],
                job_template=JobTemplate(command='echo hello world', interpreter='bash'),
                )
        self.s.addPlan(p)

        plans = self.s.findPlansByEventType('hg.push')

        self.assertEquals(len(plans), 1)
        self.assertEquals(plans[0].asDict(), p.asDict())

        plans = self.s.findPlansByEventType('not-thre')
        self.assertEquals(len(plans), 0)
Exemplo n.º 3
0
    def test_updatePlan(self):
        p = Plan(owner='me', bucket='b1', events=['hg.push'],
                job_template=JobTemplate(command='echo hello world', interpreter='bash'),
                )
        _id = self.s.addPlan(p)

        p1 = self.s.getPlan(_id)
        self.assertEquals(p1.owner, 'me')

        p.owner = 'you'
        self.s.updatePlan(p)

        p1 = self.s.getPlan(_id)
        self.assertEquals(p1.owner, 'you')
Exemplo n.º 4
0
Arquivo: store.py Projeto: catlee/lwr
    def getPlan(self, _id):
        p = self.col.find_one({"_id": ObjectId(_id)})
        if not p:
            raise KeyError("Plan %s not found" % _id)

        p = from_mongo_id(p)
        return Plan.fromDict(p)
Exemplo n.º 5
0
Arquivo: store.py Projeto: catlee/lwr
 def findPlansByEventType(self, event_type):
     retval = []
     plans = self.col.find({"events": event_type})
     for p in plans:
         p = from_mongo_id(p)
         p = Plan.fromDict(p)
         retval.append(p)
     return retval
Exemplo n.º 6
0
Arquivo: store.py Projeto: catlee/lwr
 def findPlansByBucket(self, bucket):
     retval = []
     plans = self.col.find({"bucket": bucket})
     for p in plans:
         p = from_mongo_id(p)
         p = Plan.fromDict(p)
         retval.append(p)
     return retval
Exemplo n.º 7
0
import time
from lwr.plugins.zmq import message
from lwr.planner.plan import Event, Plan, JobTemplate

e = Event(owner='me', bucket='public', name='hg.pushes', data={'rev': '1234567890', 'branch': 'projects/awesomesauce'})
jt = JobTemplate(command="echo hello world", interpreter="bash", data={'extra_args': ['--disable-tests']})
p = Plan(owner='me', bucket='b1', events=["public.hg.pushes"], job_template=jt)
j = p.run(e)

obj = j.asDict()

results = {}

def time_serialize(encoder, compressor, n=1000):
    mh = message.MessageHandler()
    mh.setEncoder(encoder)
    mh.setCompressor(compressor)

    start = time.time()
    for i in xrange(n):
        mh.serialize(obj)
    end = time.time()
    return end-start

def time_unserialize(encoder, compressor, n=1000):
    mh = message.MessageHandler()
    mh.setEncoder(encoder)
    mh.setCompressor(compressor)

    s = mh.serialize(obj)
Exemplo n.º 8
0
 def test_plan_run(self):
     e = Event(owner='me', bucket='public', type='hg.pushes')
     jt = JobTemplate(command="echo hello world", interpreter="bash")
     p = Plan(owner='me', bucket='b1', events=["public.hg.pushes"], job_template=jt)
     j = p.run(e)