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

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: 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 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 self.mock_now(datetime.datetime(2009, 1, 2, 3, 4, 5, 6))
1498
1499 aggregate = bot_management.DimensionAggregation(
1500 id='current',
1501 dimensions=[
1502 bot_management.DimensionValues(dimension='foo',
1503 values=['alpha', 'beta']),
1504 bot_management.DimensionValues(dimension='bar',
1505 values=['gamma', 'delta', 'epsilon']),
1506 ])
1507 aggregate.put()
1508
1509 expected = {
1510 u'fleet_dimensions': [
1511 {
1512 u'key': 'foo',
1513 u'value': [u'alpha', u'beta'],
1514 },
1515 {
1516 u'key': 'bar',
1517 u'value': [u'gamma', u'delta', u'epsilon'],
1518 },
1519 ]
1520 }
1521
1522 response = self.call_api('dimensions', body={})
1523 self.assertEqual(expected, response.json)
1524
1525
1494 class BotApiTest(BaseTest): 1526 class BotApiTest(BaseTest):
1495 api_service_cls = handlers_endpoints.SwarmingBotService 1527 api_service_cls = handlers_endpoints.SwarmingBotService
1496 1528
1497 def test_get_ok(self): 1529 def test_get_ok(self):
1498 """Asserts that get shows the tasks a specific bot has executed.""" 1530 """Asserts that get shows the tasks a specific bot has executed."""
1499 self.set_as_privileged_user() 1531 self.set_as_privileged_user()
1500 now = datetime.datetime(2010, 1, 2, 3, 4, 5, 6) 1532 now = datetime.datetime(2010, 1, 2, 3, 4, 5, 6)
1501 self.mock_now(now) 1533 self.mock_now(now)
1502 now_str = unicode(now.strftime(self.DATETIME_FORMAT)) 1534 now_str = unicode(now.strftime(self.DATETIME_FORMAT))
1503 bot_management.bot_event( 1535 bot_management.bot_event(
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1740 self.assertEqual(expected, response.json) 1772 self.assertEqual(expected, response.json)
1741 1773
1742 1774
1743 if __name__ == '__main__': 1775 if __name__ == '__main__':
1744 if '-v' in sys.argv: 1776 if '-v' in sys.argv:
1745 unittest.TestCase.maxDiff = None 1777 unittest.TestCase.maxDiff = None
1746 logging.basicConfig(level=logging.DEBUG) 1778 logging.basicConfig(level=logging.DEBUG)
1747 else: 1779 else:
1748 logging.basicConfig(level=logging.CRITICAL) 1780 logging.basicConfig(level=logging.CRITICAL)
1749 unittest.main() 1781 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698