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

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

Issue 2661173004: Make deleted bots still show up when searched for by id (Closed)
Patch Set: Address comments Created 3 years, 10 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/message_conversion.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 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 dimensions={'foo': ['bar'], 'id': ['id1']}, state={'ram': 65}, 1582 dimensions={'foo': ['bar'], 'id': ['id1']}, state={'ram': 65},
1583 version='123456789', quarantined=False, task_id=None, task_name=None) 1583 version='123456789', quarantined=False, task_id=None, task_name=None)
1584 bot_management.bot_event( 1584 bot_management.bot_event(
1585 event_type='bot_connected', bot_id='id2', 1585 event_type='bot_connected', bot_id='id2',
1586 external_ip='8.8.4.4', authenticated_as='bot:whitelisted-ip', 1586 external_ip='8.8.4.4', authenticated_as='bot:whitelisted-ip',
1587 dimensions={'foo': ['bar'], 'id': ['id2']}, state={'ram': 65}, 1587 dimensions={'foo': ['bar'], 'id': ['id2']}, state={'ram': 65},
1588 version='123456789', quarantined=True, task_id=None, task_name=None) 1588 version='123456789', quarantined=True, task_id=None, task_name=None)
1589 bot1 = { 1589 bot1 = {
1590 u'authenticated_as': u'bot:whitelisted-ip', 1590 u'authenticated_as': u'bot:whitelisted-ip',
1591 u'bot_id': u'id1', 1591 u'bot_id': u'id1',
1592 u'deleted': False,
1592 u'dimensions': [ 1593 u'dimensions': [
1593 {u'key': u'foo', u'value': [u'bar']}, 1594 {u'key': u'foo', u'value': [u'bar']},
1594 {u'key': u'id', u'value': [u'id1']}, 1595 {u'key': u'id', u'value': [u'id1']},
1595 ], 1596 ],
1596 u'external_ip': u'8.8.4.4', 1597 u'external_ip': u'8.8.4.4',
1597 u'first_seen_ts': now_str, 1598 u'first_seen_ts': now_str,
1598 u'is_dead': False, 1599 u'is_dead': False,
1599 u'last_seen_ts': now_str, 1600 u'last_seen_ts': now_str,
1600 u'quarantined': False, 1601 u'quarantined': False,
1601 u'state': u'{"ram":65}', 1602 u'state': u'{"ram":65}',
1602 u'version': u'123456789', 1603 u'version': u'123456789',
1603 } 1604 }
1604 bot2 = { 1605 bot2 = {
1605 u'authenticated_as': u'bot:whitelisted-ip', 1606 u'authenticated_as': u'bot:whitelisted-ip',
1606 u'bot_id': u'id2', 1607 u'bot_id': u'id2',
1608 u'deleted': False,
1607 u'dimensions': [ 1609 u'dimensions': [
1608 {u'key': u'foo', u'value': [u'bar']}, 1610 {u'key': u'foo', u'value': [u'bar']},
1609 {u'key': u'id', u'value': [u'id2']}, 1611 {u'key': u'id', u'value': [u'id2']},
1610 ], 1612 ],
1611 u'external_ip': u'8.8.4.4', 1613 u'external_ip': u'8.8.4.4',
1612 u'first_seen_ts': now_str, 1614 u'first_seen_ts': now_str,
1613 u'is_dead': False, 1615 u'is_dead': False,
1614 u'last_seen_ts': now_str, 1616 u'last_seen_ts': now_str,
1615 u'quarantined': True, 1617 u'quarantined': True,
1616 u'state': u'{"ram":65}', 1618 u'state': u'{"ram":65}',
1617 u'version': u'123456789', 1619 u'version': u'123456789',
1618 } 1620 }
1619 bot3 = { 1621 bot3 = {
1620 u'authenticated_as': u'bot:whitelisted-ip', 1622 u'authenticated_as': u'bot:whitelisted-ip',
1621 u'bot_id': u'id3', 1623 u'bot_id': u'id3',
1624 u'deleted': False,
1622 u'dimensions': [ 1625 u'dimensions': [
1623 {u'key': u'foo', u'value': [u'bar']}, 1626 {u'key': u'foo', u'value': [u'bar']},
1624 {u'key': u'id', u'value': [u'id3']}, 1627 {u'key': u'id', u'value': [u'id3']},
1625 ], 1628 ],
1626 u'external_ip': u'8.8.4.4', 1629 u'external_ip': u'8.8.4.4',
1627 u'first_seen_ts': then_str, 1630 u'first_seen_ts': then_str,
1628 u'is_dead': True, 1631 u'is_dead': True,
1629 u'last_seen_ts': then_str, 1632 u'last_seen_ts': then_str,
1630 u'quarantined': False, 1633 u'quarantined': False,
1631 u'state': u'{"ram":65}', 1634 u'state': u'{"ram":65}',
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 now_str = unicode(now.strftime(self.DATETIME_FORMAT)) 1847 now_str = unicode(now.strftime(self.DATETIME_FORMAT))
1845 bot_management.bot_event( 1848 bot_management.bot_event(
1846 event_type='bot_connected', bot_id='id1', 1849 event_type='bot_connected', bot_id='id1',
1847 external_ip='8.8.4.4', authenticated_as='bot:whitelisted-ip', 1850 external_ip='8.8.4.4', authenticated_as='bot:whitelisted-ip',
1848 dimensions={'foo': ['bar'], 'id': ['id1']}, state={'ram': 65}, 1851 dimensions={'foo': ['bar'], 'id': ['id1']}, state={'ram': 65},
1849 version='123456789', quarantined=False, task_id=None, task_name=None) 1852 version='123456789', quarantined=False, task_id=None, task_name=None)
1850 1853
1851 expected = { 1854 expected = {
1852 u'authenticated_as': u'bot:whitelisted-ip', 1855 u'authenticated_as': u'bot:whitelisted-ip',
1853 u'bot_id': u'id1', 1856 u'bot_id': u'id1',
1857 u'deleted': False,
1854 u'dimensions': [ 1858 u'dimensions': [
1855 {u'key': u'foo', u'value': [u'bar']}, 1859 {u'key': u'foo', u'value': [u'bar']},
1856 {u'key': u'id', u'value': [u'id1']}, 1860 {u'key': u'id', u'value': [u'id1']},
1857 ], 1861 ],
1858 u'external_ip': u'8.8.4.4', 1862 u'external_ip': u'8.8.4.4',
1859 u'first_seen_ts': now_str, 1863 u'first_seen_ts': now_str,
1860 u'is_dead': False, 1864 u'is_dead': False,
1861 u'last_seen_ts': now_str, 1865 u'last_seen_ts': now_str,
1862 u'quarantined': False, 1866 u'quarantined': False,
1863 u'state': u'{"ram":65}', 1867 u'state': u'{"ram":65}',
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 self.call_api('terminate', body={'bot_id': 'bot1'}, status=403) 2121 self.call_api('terminate', body={'bot_id': 'bot1'}, status=403)
2118 2122
2119 2123
2120 if __name__ == '__main__': 2124 if __name__ == '__main__':
2121 if '-v' in sys.argv: 2125 if '-v' in sys.argv:
2122 unittest.TestCase.maxDiff = None 2126 unittest.TestCase.maxDiff = None
2123 logging.basicConfig(level=logging.DEBUG) 2127 logging.basicConfig(level=logging.DEBUG)
2124 else: 2128 else:
2125 logging.basicConfig(level=logging.CRITICAL) 2129 logging.basicConfig(level=logging.CRITICAL)
2126 unittest.main() 2130 unittest.main()
OLDNEW
« no previous file with comments | « appengine/swarming/handlers_endpoints.py ('k') | appengine/swarming/message_conversion.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698