コード例 #1
0
  def test_expired(self):
    now = datetime.datetime(2015, 1, 1, 1, 1, 1)
    self.mock_now(now)
    _bot_event('first1', 'first', {'build': 100000}, ['Mac'])
    self.assertEqual(2, named_caches.cron_update_named_caches())
    self.assertEqual([now], [e.ts for e in named_caches.NamedCache.query()])

    self.mock_now(now, 8*24*60*60)
    self.assertEqual(2, named_caches.cron_update_named_caches())
    self.assertEqual(1, named_caches.NamedCache.query().count())
    self.assertEqual([now], [e.ts for e in named_caches.NamedCache.query()])

    self.mock_now(now, 8*24*60*60+1)
    self.assertEqual(2, named_caches.cron_update_named_caches())
    self.assertEqual(0, named_caches.NamedCache.query().count())
コード例 #2
0
    def test_simple(self):
        _bot_event('first1', 'first', {'git': 1}, None)
        _bot_event('first2', 'first', {'build': 100000, 'git': 1000}, None)
        self.assertEqual(2, named_caches.cron_update_named_caches())

        self.assertEqual(2, named_caches.NamedCache.query().count())
        oses = ['Linux']
        hints = named_caches.get_hints('first', oses, ['git', 'build', 'new'])
        self.assertEqual([1000, 100000, -1], hints)
コード例 #3
0
    def test_fuzzy_other_os(self):
        # Use the hint from 'Mac' (the larger one) even if requesting for Linux.
        _bot_event('first1', 'first', {'build': 50000}, ['Android'])
        _bot_event('first2', 'first', {'build': 100000}, ['Mac'])
        self.assertEqual(2, named_caches.cron_update_named_caches())

        self.assertEqual(2, named_caches.NamedCache.query().count())
        oses = ['Linux']
        hints = named_caches.get_hints('first', oses, ['build'])
        self.assertEqual([100000], hints)
コード例 #4
0
    def test_p95(self):
        # Create 45 bots with cache 'foo' size between 1 and 45.
        for i in range(45):
            _bot_event('second%d' % i, 'second', {'foo': i + 1}, None)
        self.assertEqual(2, named_caches.cron_update_named_caches())

        self.assertEqual(1, named_caches.NamedCache.query().count())
        oses = ['Linux']
        hints = named_caches.get_hints('second', oses, ['foo'])
        # Roughly p95.
        self.assertEqual([43], hints)
コード例 #5
0
 def run_cron(self):
     named_caches.cron_update_named_caches()