Пример #1
0
    def release_ticket(self, wid, project):
        """
        This unlocks an OBS project by moving along the work queue.
        If the queue is quiet it raises an exception

        # The Q.head.wfid is compared to the current wfid. If they
        # differ an exception is raised. NOT YET.

        The current wi is sent to BOSS to allow this process to
        continue.

        The Q.head wi is deleted and the new head is sent to BOSS to
        allow that process to continue (unblocking it)
        """

        path = os.path.join(self.prjdir, project)
        q = WorkQueue(path)

        head_wi = Workitem(q.head())
        if head_wi.wfid != wid.wfid:
            self.log.info("OUCH ... released the wrong lock")

        try:
            next_wid = Workitem(q.next())
            next_wid.result = True
            # Implementation is a bit convoluted but this just sends
            # the WI from the stack to BOSS
            self.send_to_engine(next_wid)
        except QueueEmpty:
            # That's OK, there's nothing waiting
            pass
Пример #2
0
    def release_ticket(self, wid, project):
        """
        This unlocks an OBS project by moving along the work queue.
        If the queue is quiet it raises an exception

        # The Q.head.wfid is compared to the current wfid. If they
        # differ an exception is raised. NOT YET.

        The current wi is sent to BOSS to allow this process to
        continue.

        The Q.head wi is deleted and the new head is sent to BOSS to
        allow that process to continue (unblocking it)
        """

        path = os.path.join(self.prjdir, project)
        q = WorkQueue(path)

        head_wi = Workitem(q.head())
        if head_wi.wfid != wid.wfid:
            self.log.info("OUCH ... released the wrong lock")

        try:
            next_wid = Workitem(q.next())
            next_wid.result = True
            # Implementation is a bit convoluted but this just sends
            # the WI from the stack to BOSS
            self.send_to_engine(next_wid)
        except QueueEmpty:
            # That's OK, there's nothing waiting
            pass
Пример #3
0
    def test_handle_wi(self):
        """Test ParticipantHandler.handle_wi()"""
        # pylint: disable=E1101
        wid = Workitem('{"fei": { "wfid": "x", "subid": "x", "expid": "x",'
                       '          "engine_id": "x" },'
                       ' "fields": { "params": {}, "debug_dump": true } }')
        self.assertRaises(RuntimeError, self.participant.handle_wi, wid)
        self.assertFalse(wid.result)

        wid.params.lock_project = "test"
        wid.params.action = "get"
        self.participant.handle_wi(wid)
        self.assertTrue(wid.result)
        # First item should go forward
        self.assertFalse(wid.forget)

        # Second one is forgotten in the queue
        self.participant.handle_wi(wid)
        self.assertTrue(wid.forget)

        wid.params.forget = False
        wid.params.action = "release"
        self.participant.handle_wi(wid)
        self.assertTrue(wid.result)

        wid = Workitem('{"fei": { "wfid": "y", "subid": "x", "expid": "x",'
                       '          "engine_id": "x" },'
                       ' "fields": { "params": { "lock_project": "test",'
                       '"action": "release" },'
                       '"debug_dump": true } }')

        self.participant.handle_wi(wid)
        self.assertTrue(wid.result)
    def test_handle_wi(self):
        """Test participant.handle_wi()"""

        # Test bad values
        wid = Workitem(WI_TEMPLATE)
        wid.fields.__error__ = None
        wid.fields.ev.id = None
        wid.fields.packages = None
        wid.fields.new_failures = None
        self.assertRaises(RuntimeError, self.participant.handle_wi, wid)
        self.assertFalse(wid.result)

        # Test failed package
        wid = Workitem(WI_TEMPLATE)
        wid.fields.test_project = "test_project"
        wid.fields.repository = "repo"
        wid.fields.archs = ["i386"]
        wid.fields.new_failures = ["package-a"]
        wid.fields.ev.id = "123"
        wid.fields.msg = None
        self.participant.obs.getPackageResults.return_value = {
            "code": "err",
            "details": "Failed miserably"
        }
        self.participant.obs.isPackageSucceeded.return_value = False
        self.participant.obs.getBuildLog.return_value = "buildlog"
        self.participant.handle_wi(wid)
        self.assertEqual(len(wid.fields.msg), 1)
        self.assertEqual(len(wid.fields.attachments), 1)
        self.assertTrue(wid.result)

        # Test successful package
        wid = Workitem(WI_TEMPLATE)
        wid.fields.test_project = "test_project"
        wid.fields.repository = "repo"
        wid.fields.archs = ["i386"]
        wid.fields.packages = ["package-a"]
        wid.fields.ev = {}
        wid.fields.ev.id = None
        wid.fields.msg = ["existing message"]
        self.participant.obs.isPackageSucceeded.return_value = True
        self.participant.handle_wi(wid)
        self.assertEqual(len(wid.fields.msg), 2)
        self.assertEqual(len(wid.fields.attachments), 0)
        self.assertTrue(wid.result)
    def configure_participant(self):
        ctrl = Mock()
        ctrl.message = "start"
        ctrl.config = ConfigParser()
        ctrl.config.add_section("obs")
        ctrl.config.set("obs", "oscrc", "oscrc_file")
        self.participant.handle_lifecycle_control(ctrl)

        self.mut.subprocess = Mock()
        self.mut.subprocess.Popen.side_effect = self.mock_specify

        self.participant.obs.getFile.return_value = TEST_SPEC
        self.specify_out = TEST_SPEC

        self.wid = Workitem(WI_TEMPLATE)
        self.wid.fields.msg = None
        self.wid.fields.ev.actions = self.fake_actions
        self.wid.fields.ev.namespace = "test"
Пример #6
0
    def test_quality_check(self):
        wid = Workitem(WI_TEMPLATE)
        wid.fields.ev.actions = []
        wid.fields.msg = None
        self.assertRaises(RuntimeError, self.participant.handle_wi, wid)

        wid.fields.ev.actions = self.fake_actions

        self.participant.handle_wi(wid)
        self.assertFalse(wid.result)

        for action in wid.fields.ev.actions:
            if action["type"] == "submit":
                action["relevant_changelog"] = "Something"
        self.participant.handle_wi(wid)
        self.assertTrue(wid.result)

        for action in wid.fields.ev.actions:
            if action["type"] == "submit":
                action["relevant_changelog"] = u"Something\xe1\xe1"
        self.participant.handle_wi(wid)
        self.assertTrue(wid.result)
 def setUp(self):
     super(TestParticipantHandler, self).setUp()
     self.wid = Workitem(WI_TEMPLATE)
     # Use the fake actions but cut off the second submit action
     self.wid.fields.ev.actions = self.fake_actions[:-1]