Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: appengine/swarming/handlers_test.py

Issue 2212073002: Add endpoint and cron job to aggregate all dimensions and values (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: trying things Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 # Copyright 2013 The LUCI Authors. All rights reserved. 3 # Copyright 2013 The LUCI Authors. All rights reserved.
4 # Use of this source code is governed under the Apache License, Version 2.0 4 # Use of this source code is governed under the Apache License, Version 2.0
5 # that can be found in the LICENSE file. 5 # that can be found in the LICENSE file.
6 6
7 import datetime
7 import itertools 8 import itertools
8 import json 9 import json
9 import logging 10 import logging
10 import os 11 import os
11 import re 12 import re
12 import sys 13 import sys
13 import unittest 14 import unittest
14 import urllib 15 import urllib
15 16
16 # Setups environment. 17 # Setups environment.
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 473
473 # Only cron job requests can be gets for this handler. 474 # Only cron job requests can be gets for this handler.
474 response = self.app.get(cron_job_url, status=403) 475 response = self.app.get(cron_job_url, status=403)
475 self.assertEqual( 476 self.assertEqual(
476 '403 Forbidden\n\nAccess was denied to this resource.\n\n ' 477 '403 Forbidden\n\nAccess was denied to this resource.\n\n '
477 'Only internal cron jobs can do this ', 478 'Only internal cron jobs can do this ',
478 response.body) 479 response.body)
479 # The actual number doesn't matter, just make sure they are unqueued. 480 # The actual number doesn't matter, just make sure they are unqueued.
480 self.execute_tasks() 481 self.execute_tasks()
481 482
483
484 def testCronBotsAggregateTask(self):
485 #self.set_as_admin()
486 #self.mock_now(datetime.datetime(2009, 1, 2, 3, 4, 5, 6))
487
488 bot_management.bot_event(
489 event_type='bot_connected', bot_id='id1',
490 external_ip='8.8.4.4', authenticated_as='bot:whitelisted-ip',
491 dimensions={'foo': ['alpha'], 'id': ['id1']}, state={'ram': 65},
492 version='123456789', quarantined=False, task_id=None, task_name=None)
493 bot_management.bot_event(
494 event_type='bot_connected', bot_id='id2',
495 external_ip='8.8.4.4', authenticated_as='bot:whitelisted-ip',
496 dimensions={'foo': ['beta'], 'id': ['id2']}, state={'ram': 65},
497 version='123456789', quarantined=True, task_id='987', task_name=None)
498
499 response = self.app.get('/internal/cron/aggregate_bots_dimensions', headers= {'X-AppEngine-Cron': 'true'}, status=200)
500 print response
501
502
482 def testCronTriggerTask(self): 503 def testCronTriggerTask(self):
483 triggers = ( 504 triggers = (
484 '/internal/cron/trigger_cleanup_data', 505 '/internal/cron/trigger_cleanup_data',
485 ) 506 )
486 507
487 for url in triggers: 508 for url in triggers:
488 response = self.app.get( 509 response = self.app.get(
489 url, headers={'X-AppEngine-Cron': 'true'}, status=200) 510 url, headers={'X-AppEngine-Cron': 'true'}, status=200)
490 self.assertEqual('Success.', response.body) 511 self.assertEqual('Success.', response.body)
491 self.assertEqual(1, self.execute_tasks()) 512 self.assertEqual(1, self.execute_tasks())
(...skipping 19 matching lines...) Expand all
511 url, headers={'X-AppEngine-QueueName': 'bogus name'}, status=403) 532 url, headers={'X-AppEngine-QueueName': 'bogus name'}, status=403)
512 533
513 534
514 if __name__ == '__main__': 535 if __name__ == '__main__':
515 if '-v' in sys.argv: 536 if '-v' in sys.argv:
516 unittest.TestCase.maxDiff = None 537 unittest.TestCase.maxDiff = None
517 logging.basicConfig( 538 logging.basicConfig(
518 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL, 539 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL,
519 format='%(levelname)-7s %(filename)s:%(lineno)3d %(message)s') 540 format='%(levelname)-7s %(filename)s:%(lineno)3d %(message)s')
520 unittest.main() 541 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698