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

Unified Diff: appengine/swarming/handlers_endpoints_test.py

Issue 1942143002: swarming: isolate defaults (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@swarming-ns-re
Patch Set: rebased Created 4 years, 7 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
« no previous file with comments | « appengine/swarming/handlers_endpoints.py ('k') | appengine/swarming/proto/config.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/swarming/handlers_endpoints_test.py
diff --git a/appengine/swarming/handlers_endpoints_test.py b/appengine/swarming/handlers_endpoints_test.py
index 9484189448d83cf70eb5b3b29e47b8f76da23ba5..3ad9d3887b5f66a0f364de817688ded0a6121add 100755
--- a/appengine/swarming/handlers_endpoints_test.py
+++ b/appengine/swarming/handlers_endpoints_test.py
@@ -136,6 +136,10 @@ class ServerApiTest(BaseTest):
class TasksApiTest(BaseTest):
api_service_cls = handlers_endpoints.SwarmingTasksService
+ def setUp(self):
+ super(TasksApiTest, self).setUp()
+ utils.clear_cache(config.settings)
+
def test_new_ok_raw(self):
"""Asserts that new generates appropriate metadata."""
self.mock(random, 'getrandbits', lambda _: 0x88)
@@ -505,6 +509,72 @@ class TasksApiTest(BaseTest):
response = self.call_api('new', body=message_to_dict(request))
self.assertEqual(expected, response.json)
+ def test_new_ok_isolated_with_defaults(self):
+ self.mock(random, 'getrandbits', lambda _: 0x88)
+ now = datetime.datetime(2010, 1, 2, 3, 4, 5)
+ self.mock_now(now)
+ str_now = unicode(now.strftime(self.DATETIME_NO_MICRO))
+
+ cfg = config.settings()
+ cfg.isolate.default_server = 'https://isolateserver.appspot.com'
+ cfg.isolate.default_namespace = 'default-gzip'
+ self.mock(config, 'settings', lambda: cfg)
+
+ request = swarming_rpcs.NewTaskRequest(
+ expiration_secs=30,
+ name='job1',
+ priority=200,
+ properties=swarming_rpcs.TaskProperties(
+ dimensions=[
+ swarming_rpcs.StringPair(key='pool', value='default'),
+ swarming_rpcs.StringPair(key='foo', value='bar'),
+ ],
+ env=[
+ swarming_rpcs.StringPair(key='PATH', value='/'),
+ ],
+ execution_timeout_secs=30,
+ inputs_ref=swarming_rpcs.FilesRef(isolated='1'*40),
+ io_timeout_secs=30),
+ tags=['foo:bar'],
+ user='joe@localhost')
+ expected = {
+ u'request': {
+ u'authenticated': u'user:user@example.com',
+ u'created_ts': str_now,
+ u'expiration_secs': u'30',
+ u'name': u'job1',
+ u'priority': u'200',
+ u'properties': {
+ u'dimensions': [
+ {u'key': u'foo', u'value': u'bar'},
+ {u'key': u'pool', u'value': u'default'},
+ ],
+ u'env': [
+ {u'key': u'PATH', u'value': u'/'},
+ ],
+ u'execution_timeout_secs': u'30',
+ u'grace_period_secs': u'30',
+ u'idempotent': False,
+ u'inputs_ref': {
+ 'isolated': '1'*40,
+ 'isolatedserver': 'https://isolateserver.appspot.com',
+ 'namespace': 'default-gzip',
+ },
+ u'io_timeout_secs': u'30',
+ },
+ u'tags': [
+ u'foo:bar',
+ u'pool:default',
+ u'priority:200',
+ u'user:joe@localhost',
+ ],
+ u'user': u'joe@localhost',
+ },
+ u'task_id': u'5cee488008810',
+ }
+ response = self.call_api('new', body=message_to_dict(request))
+ self.assertEqual(expected, response.json)
+
def test_list_ok(self):
"""Asserts that list requests all TaskResultSummaries."""
first, second, str_now_120, start, end = self._gen_two_tasks()
« no previous file with comments | « appengine/swarming/handlers_endpoints.py ('k') | appengine/swarming/proto/config.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698