def testGetSlavesAbortedBySelfDestructedMaster(self):
        """Test GetSlavesAbortedBySelfDestructedMaster with aborted slaves."""
        db = fake_cidb.FakeCIDBConnection()
        buildstore = FakeBuildStore(db)
        cidb.CIDBConnectionFactory.SetupMockCidb(db)
        master_build_id = db.InsertBuild('master',
                                         1,
                                         'master',
                                         'bot_hostname',
                                         buildbucket_id=1234)
        master_build_identifier = BuildIdentifier(cidb_id=master_build_id,
                                                  buildbucket_id=1234)

        self.assertEqual(
            set(),
            builder_status_lib.GetSlavesAbortedBySelfDestructedMaster(
                master_build_identifier, buildstore))

        db.InsertBuild('slave_1',
                       1,
                       'slave_1',
                       'bot_hostname',
                       master_build_id=master_build_id,
                       buildbucket_id=12)
        db.InsertBuild('slave_2',
                       2,
                       'slave_2',
                       'bot_hostname',
                       master_build_id=master_build_id,
                       buildbucket_id=23)
        db.InsertBuild('slave_3',
                       3,
                       'slave_3',
                       'bot_hostname',
                       master_build_id=master_build_id,
                       buildbucket_id=34)
        for slave_build_id in (12, 23):
            db.InsertBuildMessage(
                master_build_id,
                message_type=constants.MESSAGE_TYPE_IGNORED_REASON,
                message_subtype=constants.MESSAGE_SUBTYPE_SELF_DESTRUCTION,
                message_value=str(slave_build_id))
        self.assertEqual(
            {'slave_1', 'slave_2'},
            builder_status_lib.GetSlavesAbortedBySelfDestructedMaster(
                BuildIdentifier(cidb_id=master_build_id, buildbucket_id=1234),
                buildstore))
Beispiel #2
0
 def testWaitForSlavesToComplete(self):
     """Test WaitForSlavesToComplete."""
     self.PatchObject(build_status.SlaveStatus, 'UpdateSlaveStatus')
     self.PatchObject(build_status.SlaveStatus,
                      'ShouldWait',
                      return_value=False)
     self.manager = self.BuildManager()
     self.manager.WaitForSlavesToComplete(
         BuildIdentifier(cidb_id=1, buildbucket_id=1234),
         ['build_1', 'build_2'])
Beispiel #3
0
 def testWaitForSlavesToCompleteWithTimeout(self):
     """Test WaitForSlavesToComplete raises timeout."""
     self.PatchObject(build_status.SlaveStatus, 'UpdateSlaveStatus')
     self.PatchObject(build_status.SlaveStatus,
                      'ShouldWait',
                      return_value=True)
     self.manager = self.BuildManager()
     self.assertRaises(timeout_util.TimeoutError,
                       self.manager.WaitForSlavesToComplete,
                       BuildIdentifier(cidb_id=1, buildbucket_id=1234),
                       ['build_1', 'build_2'],
                       timeout=1,
                       ignore_timeout_exception=False)
    def testGetBuildFailureMessageWithBuildStore(self):
        """Test GetBuildFailureMessage with working BuildStore."""
        db = fake_cidb.FakeCIDBConnection()
        cidb.CIDBConnectionFactory.SetupMockCidb(db)
        stage = self.ConstructStage()
        message = 'foo'
        get_msg_from_cidb = self.PatchObject(
            stage,
            'GetBuildFailureMessageFromBuildStore',
            return_value=message)
        self.PatchObject(FakeBuildStore, 'AreClientsReady', return_value=True)
        get_msg_from_results = self.PatchObject(
            stage, 'GetBuildFailureMessageFromResults', return_value=message)

        build_identifier = BuildIdentifier(cidb_id=constants.MOCK_BUILD_ID,
                                           buildbucket_id=None)
        self.PatchObject(stage._run,
                         'GetCIDBHandle',
                         return_value=[build_identifier, None])
        stage.GetBuildFailureMessage()
        get_msg_from_cidb.assert_called_once_with(self.buildstore,
                                                  build_identifier)
        get_msg_from_results.assert_not_called()