示例#1
0
 def testDispatcherServerStopFull(self):
     self.startRmakeServer(multinode=True)
     self.startNode()
     trv = self.addComponent('sleep:source', '1.0',
                             [('sleep.recipe', sleepRecipe)])
     name, version, flavor = trv.getNameVersionFlavor()
     flavor = deps.parseFlavor('is:x86')
     buildTrove = self.newBuildTrove(1, name, version, flavor)
     m = mnmessages.BuildCommand('CMD-1', self.buildCfg, 1, buildTrove, [],
                                 [], self.cfg.buildLabel)
     admin = self.getAdminClient(self.rmakeCfg.messageBusPort)
     admin.sendMessage('/command', m)
     count = 0
     while not admin.listNodes() and count < 180:
         time.sleep(.1)
         count += .1
     nodeId = admin.listNodes()[0]
     count = 0
     #print 'Waiting for command to start'
     while not admin.listNodeCommands(nodeId)[1] and count < 180:
         time.sleep(.1)
         count += .1
     m = mnmessages.StopCommand('CMD-2', 1, targetCommandId='CMD-1')
     admin.sendMessage('/command', m)
     #print 'Waiting for command to die'
     while admin.listNodeCommands(nodeId)[1] and count < 180:
         time.sleep(.1)
         count += .1
         # ok, the stop command has finished, now that must be communicated
         # to the dispatcher.
     #print 'Waiting dispatcher to acknowledge'
     while admin.listAssignedCommands() and count < 180:
         time.sleep(.1)
         count += .1
示例#2
0
 def makeStopMessage(self, num, cmd):
     commandId = 'CMD-%s' % num
     messageId = 'MSG-%s' % commandId
     targetId = cmd.getCommandId()
     m = mnmessages.StopCommand(commandId, jobId=cmd.getJobId(),
                              targetCommandId=targetId)
     m.stamp(messageId, 'SND-' + messageId, time.time())
     return m
示例#3
0
    def testStopCommandFull(self):
        from rmake.messagebus import messages
        from rmake.multinode import messages as mnmessages
        # do one build from start -> finish to check out polling, etc.
        port = self.startMessageBus()
        node = self.startNode(messageBusPort=port)
        admin = self.getAdminClient(port)
        clients = admin.listMessageBusClients()
        nodeId = [ x[0] for x in clients.items() if x[1] == 'WORKER' ][0]

        # send a build command - we'll listen for a commandStatus
        # command.
        trv = self.addComponent('sleep:source', '1',
                                [('sleep.recipe', rmakehelp.sleepRecipe)])
        buildTrove = self.newBuildTrove(1, *trv.getNameVersionFlavor())

        m = mnmessages.BuildCommand('CMD-1', self.buildCfg, 1, buildTrove, [],
                                    [], self.cfg.buildLabel,
                                    targetNode=nodeId)
        subscriber = self.createEventSubscriber(port)
        admin.sendMessage('/command', m)
        count = 0
        while not admin.listNodeCommands(nodeId) and count < 30:
            subscriber.poll()
            time.sleep(.1)
            count += .1
        assert(count != 30)
        count = 0
        while not subscriber._troveBuilding and count < 30:
            subscriber.poll()
            time.sleep(.1)
            count += .1
        assert(count != 30)
        m = mnmessages.StopCommand('CMD-2', 1,
                                   targetCommandId='CMD-1',
                                   targetNode=nodeId)
        admin.sendMessage('/command', m)
        count = 0
        while count < 30 and admin.listNodeCommands(nodeId)[1]:
            subscriber.poll()
            time.sleep(.1)
            count += .1
        assert(count != 30)
        troveTup = buildTrove.getNameVersionFlavor()
        subscriber.assertTroveBuilding(1, *troveTup)
        subscriber.poll()
        count = 0
        while count < 30 and not subscriber._troveFailed:
            subscriber.poll()
            time.sleep(.1)
            count += .1
        subscriber.assertTroveFailed(1, *troveTup)
        reason = subscriber.getFailureReason(1, *troveTup)
        assert(str(reason) == 'Failed while building: Stop requested')
示例#4
0
 def stopCommand(self, commandId):
     newCommandId = self.idgen.getStopCommandId(commandId)
     m = messages.StopCommand(newCommandId, self.jobId,
                              targetCommandId=commandId)
     self.bus.sendMessage('/command', m)