| Index: appengine/swarming/server/task_request_test.py
|
| diff --git a/appengine/swarming/server/task_request_test.py b/appengine/swarming/server/task_request_test.py
|
| index 6e57e873d11da371f82c86ebda0f6ee317e7ef13..e83e461af0efce6c8909f310bbe12ee70a35e357 100755
|
| --- a/appengine/swarming/server/task_request_test.py
|
| +++ b/appengine/swarming/server/task_request_test.py
|
| @@ -75,11 +75,13 @@ def _gen_request(properties=None, **kwargs):
|
| properties = merge(properties, {
|
| 'cipd_input': cipd_input,
|
| 'command': [u'command1', u'arg1'],
|
| - 'dimensions': {
|
| - u'OS': u'Windows-3.1.1',
|
| - u'hostname': u'localhost',
|
| - u'pool': u'default',
|
| - },
|
| + 'dimensions_flat': [
|
| + u'hostname:localhost',
|
| + u'os:Windows-3.1.1',
|
| + # Test repeated keys. In this case, the bot has to be in both pools.
|
| + u'pool:default',
|
| + u'pool:testing',
|
| + ],
|
| 'env': {u'foo': u'bar', u'joe': u'2'},
|
| 'execution_timeout_secs': 30,
|
| 'grace_period_secs': 30,
|
| @@ -88,7 +90,6 @@ def _gen_request(properties=None, **kwargs):
|
| 'io_timeout_secs': None,
|
| 'has_secret_bytes': 'secret_bytes' in kwargs,
|
| })
|
| - properties['dimensions_dict'] = properties.pop('dimensions')
|
| now = utils.utcnow()
|
| args = {
|
| 'created_ts': now,
|
| @@ -242,11 +243,12 @@ class TaskRequestApiTest(TestCase):
|
| 'server': u'https://chrome-infra-packages.appspot.com'
|
| },
|
| 'command': [u'command1', u'arg1'],
|
| - 'dimensions': {
|
| - u'OS': u'Windows-3.1.1',
|
| - u'hostname': u'localhost',
|
| - u'pool': u'default',
|
| - },
|
| + 'dimensions': [
|
| + (u'hostname', u'localhost'),
|
| + (u'os', u'Windows-3.1.1'),
|
| + (u'pool', u'default'),
|
| + (u'pool', u'testing'),
|
| + ],
|
| 'env': {u'foo': u'bar', u'joe': u'2'},
|
| 'extra_args': [],
|
| 'execution_timeout_secs': 30,
|
| @@ -270,14 +272,15 @@ class TaskRequestApiTest(TestCase):
|
| # Intentionally hard code the hash value since it has to be deterministic.
|
| # Other unit tests should use the calculated value.
|
| 'properties_hash':
|
| - '258e0894f2589a7bc2b46bd563d01f64300ae08938fb14b3d750baff94ba714e',
|
| + '40635327d825d2e12ba704b7db72be55dc1dcf195ff881eff558c1be2a9f7ef6',
|
| 'pubsub_topic': None,
|
| 'pubsub_userdata': None,
|
| 'service_account': u'none',
|
| 'tags': [
|
| - u'OS:Windows-3.1.1',
|
| u'hostname:localhost',
|
| + u'os:Windows-3.1.1',
|
| u'pool:default',
|
| + u'pool:testing',
|
| u'priority:49',
|
| u'service_account:none',
|
| u'tag:1',
|
| @@ -321,11 +324,12 @@ class TaskRequestApiTest(TestCase):
|
| 'server': u'https://chrome-infra-packages.appspot.com'
|
| },
|
| 'command': [u'command1', u'arg1'],
|
| - 'dimensions': {
|
| - u'OS': u'Windows-3.1.1',
|
| - u'hostname': u'localhost',
|
| - u'pool': u'default',
|
| - },
|
| + 'dimensions': [
|
| + (u'hostname', u'localhost'),
|
| + (u'os', u'Windows-3.1.1'),
|
| + (u'pool', u'default'),
|
| + (u'pool', u'testing'),
|
| + ],
|
| 'env': {u'foo': u'bar', u'joe': u'2'},
|
| 'extra_args': [],
|
| 'execution_timeout_secs': 30,
|
| @@ -349,14 +353,15 @@ class TaskRequestApiTest(TestCase):
|
| # Intentionally hard code the hash value since it has to be deterministic.
|
| # Other unit tests should use the calculated value.
|
| 'properties_hash':
|
| - '693715e9539552e2ece434e25a665d437cfe4685504a3c7bad6356f9feffee2a',
|
| + 'cbbf1b58e73a27c15bae48019cd6678a47a4bfb637c63b47af7231e11d82109e',
|
| 'pubsub_topic': None,
|
| 'pubsub_userdata': None,
|
| 'service_account': u'none',
|
| 'tags': [
|
| - u'OS:Windows-3.1.1',
|
| u'hostname:localhost',
|
| + u'os:Windows-3.1.1',
|
| u'pool:default',
|
| + u'pool:testing',
|
| u'priority:49',
|
| u'service_account:none',
|
| u'tag:1',
|
| @@ -391,7 +396,7 @@ class TaskRequestApiTest(TestCase):
|
| # Other unit tests should use the calculated value.
|
| # Ensure the algorithm is deterministic.
|
| self.assertEqual(
|
| - 'c7445927612637c589b72dd47c4657b166a53ac6ecdfd08c167539331a7890d3',
|
| + 'b4ee0e7018e5fdb414ede87d0da2bc1479211191c5cd6a7af552916d4aa40d25',
|
| as_dict['properties_hash'])
|
|
|
| def test_init_new_request_bot_service_account(self):
|
| @@ -546,15 +551,20 @@ class TaskRequestApiTest(TestCase):
|
| dict(name='build_chromium', path='out'))
|
|
|
| # Dimensions.
|
| - with self.assertRaises(TypeError):
|
| - mkreq(_gen_request(properties=dict(dimensions=[])))
|
| with self.assertRaises(datastore_errors.BadValueError):
|
| - mkreq(_gen_request(properties=dict(dimensions={})))
|
| + mkreq(_gen_request(properties=dict(dimensions_flat={})))
|
| + with self.assertRaises(datastore_errors.BadValueError):
|
| + mkreq(_gen_request(properties=dict(dimensions_flat=[])))
|
| + with self.assertRaises(datastore_errors.BadValueError):
|
| + mkreq(_gen_request(properties=dict(dimensions_dict={u'id': u'b'})))
|
| + with self.assertRaises(datastore_errors.BadValueError):
|
| + mkreq(_gen_request(
|
| + properties=dict(dimensions_flat=[u'id:b', u'a :b'])))
|
| with self.assertRaises(datastore_errors.BadValueError):
|
| mkreq(_gen_request(
|
| - properties=dict(dimensions={u'id': u'b', u'a:': u'b'})))
|
| + properties=dict(dimensions_flat=[u'id:b', u'a.:b'])))
|
| mkreq(_gen_request(
|
| - properties=dict(dimensions={u'id': u'b', u'a.': u'b'})))
|
| + properties=dict(dimensions_flat=[u'a.:b', u'id:b'])))
|
|
|
| # Environment.
|
| with self.assertRaises(TypeError):
|
| @@ -651,11 +661,12 @@ class TaskRequestApiTest(TestCase):
|
| 'server': u'https://chrome-infra-packages.appspot.com'
|
| },
|
| 'command': [u'command1', u'arg1'],
|
| - 'dimensions': {
|
| - u'OS': u'Windows-3.1.1',
|
| - u'hostname': u'localhost',
|
| - u'pool': u'default',
|
| - },
|
| + 'dimensions': [
|
| + (u'hostname', u'localhost'),
|
| + (u'os', u'Windows-3.1.1'),
|
| + (u'pool', u'default'),
|
| + (u'pool', u'testing'),
|
| + ],
|
| 'env': {u'foo': u'bar', u'joe': u'2'},
|
| 'execution_timeout_secs': 30,
|
| 'extra_args': [],
|
| @@ -685,9 +696,10 @@ class TaskRequestApiTest(TestCase):
|
| 'pubsub_userdata': None,
|
| 'service_account': u'none',
|
| 'tags': [
|
| - u'OS:Windows-3.1.1',
|
| u'hostname:localhost',
|
| + u'os:Windows-3.1.1',
|
| u'pool:default',
|
| + u'pool:testing',
|
| u'priority:49',
|
| u'service_account:none',
|
| u'tag:1',
|
|
|