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

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 comments 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 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(dimension='foo',
1504 values=['alpha', 'beta']),
1505 bot_management.DimensionValues(dimension='bar',
1506 values=['gamma', 'delta', 'epsilon'])
M-A Ruel 2016/08/05 18:41:45 keep trailing comma.
kjlubick 2016/08/05 18:51:54 Done.
1507 ],
1508 ts=now
M-A Ruel 2016/08/05 18:41:46 it's fine to merge 1508 and 1509 on one line.
kjlubick 2016/08/05 18:51:54 Done.
1509 ).put()
1510
1511 expected = {
1512 u'bots_dimensions': [
1513 {
1514 u'key': 'foo',
1515 u'value': [u'alpha', u'beta'],
1516 },
1517 {
1518 u'key': 'bar',
1519 u'value': [u'gamma', u'delta', u'epsilon'],
1520 },
1521 ],
1522 u'ts': unicode(now.strftime(self.DATETIME_FORMAT)),
1523 }
1524
1525 self.assertEqual(expected, self.call_api('dimensions', body={}).json)
1526
1527
1494 class BotApiTest(BaseTest): 1528 class BotApiTest(BaseTest):
1495 api_service_cls = handlers_endpoints.SwarmingBotService 1529 api_service_cls = handlers_endpoints.SwarmingBotService
1496 1530
1497 def test_get_ok(self): 1531 def test_get_ok(self):
1498 """Asserts that get shows the tasks a specific bot has executed.""" 1532 """Asserts that get shows the tasks a specific bot has executed."""
1499 self.set_as_privileged_user() 1533 self.set_as_privileged_user()
1500 now = datetime.datetime(2010, 1, 2, 3, 4, 5, 6) 1534 now = datetime.datetime(2010, 1, 2, 3, 4, 5, 6)
1501 self.mock_now(now) 1535 self.mock_now(now)
1502 now_str = unicode(now.strftime(self.DATETIME_FORMAT)) 1536 now_str = unicode(now.strftime(self.DATETIME_FORMAT))
1503 bot_management.bot_event( 1537 bot_management.bot_event(
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1740 self.assertEqual(expected, response.json) 1774 self.assertEqual(expected, response.json)
1741 1775
1742 1776
1743 if __name__ == '__main__': 1777 if __name__ == '__main__':
1744 if '-v' in sys.argv: 1778 if '-v' in sys.argv:
1745 unittest.TestCase.maxDiff = None 1779 unittest.TestCase.maxDiff = None
1746 logging.basicConfig(level=logging.DEBUG) 1780 logging.basicConfig(level=logging.DEBUG)
1747 else: 1781 else:
1748 logging.basicConfig(level=logging.CRITICAL) 1782 logging.basicConfig(level=logging.CRITICAL)
1749 unittest.main() 1783 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698