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

Unified 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: reuse KEY 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 side-by-side diff with in-line comments
Download patch
Index: appengine/swarming/handlers_test.py
diff --git a/appengine/swarming/handlers_test.py b/appengine/swarming/handlers_test.py
index 1b02abf1dfa558a05dad5f24e1df44a87d06ab36..46e6765f80614a9a338cc041e93b74eeb6c05e3d 100755
--- a/appengine/swarming/handlers_test.py
+++ b/appengine/swarming/handlers_test.py
@@ -4,6 +4,7 @@
# Use of this source code is governed under the Apache License, Version 2.0
# that can be found in the LICENSE file.
+import datetime
import itertools
import json
import logging
@@ -479,6 +480,36 @@ class BackendTest(AppTestBase):
# The actual number doesn't matter, just make sure they are unqueued.
self.execute_tasks()
+
+ def testCronBotsAggregateTask(self):
+ # Tests that the aggregation works
+ now = datetime.datetime(2010, 1, 2, 3, 4, 5)
+ self.mock_now(now)
+
+ bot_management.bot_event(
+ event_type='bot_connected', bot_id='id1',
+ external_ip='8.8.4.4', authenticated_as='bot:whitelisted-ip',
+ dimensions={'foo': ['beta'], 'id': ['id1']}, state={'ram': 65},
+ version='123456789', quarantined=False, task_id=None, task_name=None)
+ bot_management.bot_event(
+ event_type='bot_connected', bot_id='id2',
+ external_ip='8.8.4.4', authenticated_as='bot:whitelisted-ip',
+ dimensions={'foo': ['alpha'], 'id': ['id2']}, state={'ram': 65},
+ version='123456789', quarantined=True, task_id='987', task_name=None)
+
+ self.app.get('/internal/cron/aggregate_bots_dimensions',
+ headers={'X-AppEngine-Cron': 'true'}, status=200)
+ aggregate = bot_management.DimensionAggregation.KEY.get()
M-A Ruel 2016/08/05 18:06:01 actual = bot_management.DimensionAggregation.KEY.g
kjlubick 2016/08/05 18:28:42 Done.
+ expected = bot_management.DimensionAggregation(
+ key=bot_management.DimensionAggregation.KEY,
M-A Ruel 2016/08/05 18:06:01 +4
kjlubick 2016/08/05 18:28:42 Done.
+ dimensions = [
M-A Ruel 2016/08/05 18:06:02 no spacing
kjlubick 2016/08/05 18:28:42 Done.
+ bot_management.DimensionValues(
+ dimension=u'foo',
M-A Ruel 2016/08/05 18:06:02 alignment is incorrect.
kjlubick 2016/08/05 18:28:42 Done.
+ values=[u'alpha',u'beta'])
+ ],
+ ts = now)
M-A Ruel 2016/08/05 18:06:02 no spacing
kjlubick 2016/08/05 18:28:42 Done.
+ self.assertEqual(expected, aggregate)
+
def testCronTriggerTask(self):
triggers = (
'/internal/cron/trigger_cleanup_data',

Powered by Google App Engine
This is Rietveld 408576698