Beispiel #1
0
 def waitForNodes(self, pool):
     self.wait_for_config(pool)
     allocation_history = allocation.AllocationHistory()
     while True:
         self.wait_for_threads()
         with pool.getDB().getSession() as session:
             needed = pool.getNeededNodes(session, allocation_history)
             if not needed:
                 nodes = session.getNodes(state=nodedb.BUILDING)
                 if not nodes:
                     break
         time.sleep(1)
     self.wait_for_threads()
Beispiel #2
0
    def setUp(self):
        super(RoundRobinFixedProvider, self).setUp()

        ah = allocation.AllocationHistory()

        def do_it():
            ap1 = allocation.AllocationProvider('provider1', self.provider1)
            ap2 = allocation.AllocationProvider('provider2', self.provider2)

            at1 = allocation.AllocationTarget('target1')

            ars = []
            ars.append(allocation.AllocationRequest('label1', self.label1, ah))
            ars.append(allocation.AllocationRequest('label2', self.label2, ah))
            ars.append(allocation.AllocationRequest('label3', self.label3, ah))
            ars.append(allocation.AllocationRequest('label4', self.label4, ah))
            ars.append(allocation.AllocationRequest('label5', self.label5, ah))
            ars.append(allocation.AllocationRequest('label6', self.label6, ah))
            ars.append(allocation.AllocationRequest('label7', self.label7, ah))
            ars.append(allocation.AllocationRequest('label8', self.label8, ah))

            # first ar can only go to provider1, the last only to
            # provider2
            ars[0].addTarget(at1, 0)
            ars[0].addProvider(ap1, at1, 0)
            ars[-1].addTarget(at1, 0)
            ars[-1].addProvider(ap2, at1, 0)

            # the rest can go anywhere
            for ar in ars[1:-1]:
                ar.addTarget(at1, 0)
                ar.addProvider(ap1, at1, 0)
                ar.addProvider(ap2, at1, 0)

            ap1.makeGrants()
            for g in ap1.grants:
                self.allocations.append(g.request.name)

            ap2.makeGrants()
            for g in ap2.grants:
                self.allocations.append(g.request.name)

            ah.grantsDone()

        # run the test several times to make sure we bounce around
        # enough
        for i in range(0, 11):
            do_it()
Beispiel #3
0
    def setUp(self):
        super(RoundRobinAllocation, self).setUp()

        ah = allocation.AllocationHistory()

        def do_it():
            ap1 = allocation.AllocationProvider('provider1', self.provider1)
            ap2 = allocation.AllocationProvider('provider2', self.provider2)

            at1 = allocation.AllocationTarget('target1')

            ars = []
            ars.append(allocation.AllocationRequest('label1', self.label1, ah))
            ars.append(allocation.AllocationRequest('label2', self.label2, ah))
            ars.append(allocation.AllocationRequest('label3', self.label3, ah))
            ars.append(allocation.AllocationRequest('label4', self.label4, ah))
            ars.append(allocation.AllocationRequest('label5', self.label5, ah))
            ars.append(allocation.AllocationRequest('label6', self.label6, ah))
            ars.append(allocation.AllocationRequest('label7', self.label7, ah))
            ars.append(allocation.AllocationRequest('label8', self.label8, ah))

            # each request to one target, and can be satisfied by both
            # providers
            for ar in ars:
                ar.addTarget(at1, 0)
                ar.addProvider(ap1, at1, 0)
                ar.addProvider(ap2, at1, 0)

            ap1.makeGrants()
            for g in ap1.grants:
                self.allocations.append(g.request.name)
            ap2.makeGrants()
            for g in ap2.grants:
                self.allocations.append(g.request.name)

            ah.grantsDone()

        # run the test several times to make sure we bounce around
        # enough
        for i in range(0, 11):
            do_it()