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

Side by Side Diff: appengine/swarming/handlers_endpoints_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: Address nits 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
« no previous file with comments | « appengine/swarming/handlers_endpoints.py ('k') | appengine/swarming/handlers_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding=utf-8 2 # coding=utf-8
3 # Copyright 2015 The LUCI Authors. All rights reserved. 3 # Copyright 2015 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 base64 7 import base64
8 import datetime 8 import datetime
9 import json 9 import json
10 import logging 10 import logging
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 u'quarantined': u'0', 1484 u'quarantined': u'0',
1485 u'dead': u'0', 1485 u'dead': u'0',
1486 u'busy': u'0', 1486 u'busy': u'0',
1487 u'now': unicode(now.strftime(self.DATETIME_FORMAT)), 1487 u'now': unicode(now.strftime(self.DATETIME_FORMAT)),
1488 } 1488 }
1489 self.assertEqual(expected, response.json) 1489 self.assertEqual(expected, response.json)
1490 1490
1491 request = swarming_rpcs.BotsRequest(dimensions=['bad']) 1491 request = swarming_rpcs.BotsRequest(dimensions=['bad'])
1492 self.call_api('count', body=message_to_dict(request), status=400) 1492 self.call_api('count', body=message_to_dict(request), status=400)
1493 1493
1494 def test_dimensions_ok(self):
1495 """Asserts that BotsDimensions is returned with the right data."""
1496 self.set_as_privileged_user()
1497 now = datetime.datetime(2009, 1, 2, 3, 4, 5, 6)
1498 self.mock_now(now)
1499
1500 bot_management.DimensionAggregation(
1501 key=bot_management.DimensionAggregation.KEY,
1502 dimensions=[
1503 bot_management.DimensionValues(
1504 dimension='foo', values=['alpha', 'beta']),
1505 bot_management.DimensionValues(
1506 dimension='bar', values=['gamma', 'delta', 'epsilon']),
1507 ],
1508 ts=now).put()
1509
1510 expected = {
1511 u'bots_dimensions': [
1512 {
1513 u'key': 'foo',
1514 u'value': [u'alpha', u'beta'],
1515 },
1516 {
1517 u'key': 'bar',
1518 u'value': [u'gamma', u'delta', u'epsilon'],
1519 },
1520 ],
1521 u'ts': unicode(now.strftime(self.DATETIME_FORMAT)),
1522 }
1523
1524 self.assertEqual(expected, self.call_api('dimensions', body={}).json)
1525
1526
1494 class BotApiTest(BaseTest): 1527 class BotApiTest(BaseTest):
1495 api_service_cls = handlers_endpoints.SwarmingBotService 1528 api_service_cls = handlers_endpoints.SwarmingBotService
1496 1529
1497 def test_get_ok(self): 1530 def test_get_ok(self):
1498 """Asserts that get shows the tasks a specific bot has executed.""" 1531 """Asserts that get shows the tasks a specific bot has executed."""
1499 self.set_as_privileged_user() 1532 self.set_as_privileged_user()
1500 now = datetime.datetime(2010, 1, 2, 3, 4, 5, 6) 1533 now = datetime.datetime(2010, 1, 2, 3, 4, 5, 6)
1501 self.mock_now(now) 1534 self.mock_now(now)
1502 now_str = unicode(now.strftime(self.DATETIME_FORMAT)) 1535 now_str = unicode(now.strftime(self.DATETIME_FORMAT))
1503 bot_management.bot_event( 1536 bot_management.bot_event(
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1740 self.assertEqual(expected, response.json) 1773 self.assertEqual(expected, response.json)
1741 1774
1742 1775
1743 if __name__ == '__main__': 1776 if __name__ == '__main__':
1744 if '-v' in sys.argv: 1777 if '-v' in sys.argv:
1745 unittest.TestCase.maxDiff = None 1778 unittest.TestCase.maxDiff = None
1746 logging.basicConfig(level=logging.DEBUG) 1779 logging.basicConfig(level=logging.DEBUG)
1747 else: 1780 else:
1748 logging.basicConfig(level=logging.CRITICAL) 1781 logging.basicConfig(level=logging.CRITICAL)
1749 unittest.main() 1782 unittest.main()
OLDNEW
« no previous file with comments | « appengine/swarming/handlers_endpoints.py ('k') | appengine/swarming/handlers_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698