@@ -35,6 +35,7 @@ def setUp(self):
3535 'clusterfuzz._internal.base.utils.post_url' ,
3636 'clusterfuzz._internal.swarming._get_task_name' ,
3737 'clusterfuzz._internal.google_cloud_utils.credentials.get_default' ,
38+ 'clusterfuzz._internal.google_cloud_utils.credentials.get_scoped_service_account_credentials' ,
3839 'google.auth.transport.requests.Request' ,
3940 'clusterfuzz._internal.swarming.FeatureFlags' ,
4041 ])
@@ -62,7 +63,8 @@ def test_get_spec_from_config_with_docker_image(self):
6263 'luci-auth' , 'context' , '--' , './linux_entry_point.sh'
6364 ],
6465 dimensions = [
65- swarming_pb2 .StringPair (key = 'os' , value = job .platform ),
66+ swarming_pb2 .StringPair (
67+ key = 'os' , value = str (job .platform ).capitalize ()),
6668 swarming_pb2 .StringPair (key = 'pool' , value = 'pool-name' )
6769 ],
6870 cipd_input = swarming_pb2 .CipdInput (), # pylint: disable=no-member
@@ -82,12 +84,13 @@ def test_get_spec_from_config_with_docker_image(self):
8284 swarming_pb2 .StringPair (
8385 key = 'DOCKER_ENV_VARS' ,
8486 value =
85- '{"UWORKER": "True", "SWARMING_BOT": "True", "LOG_TO_GCP": "True", "LOGGING_CLOUD_PROJECT_ID": "project_id"}'
87+ '{"UWORKER": "True", "SWARMING_BOT": "True", "LOG_TO_GCP": "True", "IS_K8S_ENV": "True", " LOGGING_CLOUD_PROJECT_ID": "project_id"}'
8688 ),
8789 swarming_pb2 .StringPair (key = 'UWORKER' , value = 'True' ),
8890 swarming_pb2 .StringPair (
8991 key = 'SWARMING_BOT' , value = 'True' ),
9092 swarming_pb2 .StringPair (key = 'LOG_TO_GCP' , value = 'True' ),
93+ swarming_pb2 .StringPair (key = 'IS_K8S_ENV' , value = 'True' ),
9194 swarming_pb2 .StringPair (
9295 key = 'LOGGING_CLOUD_PROJECT_ID' , value = 'project_id' ),
9396 ],
@@ -126,7 +129,8 @@ def test_get_spec_from_config_without_docker_image(self):
126129 'luci-auth' , 'context' , '--' , './mac_entry_point.sh'
127130 ],
128131 dimensions = [
129- swarming_pb2 .StringPair (key = 'os' , value = job .platform ),
132+ swarming_pb2 .StringPair (
133+ key = 'os' , value = str (job .platform ).capitalize ()),
130134 swarming_pb2 .StringPair (key = 'pool' , value = 'pool-name' ),
131135 swarming_pb2 .StringPair (key = 'key1' , value = 'value1' ),
132136 swarming_pb2 .StringPair (key = 'key2' , value = 'value2' ),
@@ -155,12 +159,13 @@ def test_get_spec_from_config_without_docker_image(self):
155159 swarming_pb2 .StringPair (
156160 key = 'DOCKER_ENV_VARS' ,
157161 value =
158- '{"UWORKER": "True", "SWARMING_BOT": "True", "LOG_TO_GCP": "True", "LOGGING_CLOUD_PROJECT_ID": "project_id"}'
162+ '{"UWORKER": "True", "SWARMING_BOT": "True", "LOG_TO_GCP": "True", "IS_K8S_ENV": "True", " LOGGING_CLOUD_PROJECT_ID": "project_id"}'
159163 ),
160164 swarming_pb2 .StringPair (key = 'UWORKER' , value = 'True' ),
161165 swarming_pb2 .StringPair (
162166 key = 'SWARMING_BOT' , value = 'True' ),
163167 swarming_pb2 .StringPair (key = 'LOG_TO_GCP' , value = 'True' ),
168+ swarming_pb2 .StringPair (key = 'IS_K8S_ENV' , value = 'True' ),
164169 swarming_pb2 .StringPair (
165170 key = 'LOGGING_CLOUD_PROJECT_ID' , value = 'project_id' ),
166171 ],
@@ -196,7 +201,8 @@ def test_get_spec_from_config_for_fuzz_task(self):
196201 'luci-auth' , 'context' , '--' , './linux_entry_point.sh'
197202 ],
198203 dimensions = [
199- swarming_pb2 .StringPair (key = 'os' , value = job .platform ),
204+ swarming_pb2 .StringPair (
205+ key = 'os' , value = str (job .platform ).capitalize ()),
200206 swarming_pb2 .StringPair (key = 'pool' , value = 'pool-name' )
201207 ],
202208 cipd_input = swarming_pb2 .CipdInput (), # pylint: disable=no-member
@@ -216,12 +222,13 @@ def test_get_spec_from_config_for_fuzz_task(self):
216222 swarming_pb2 .StringPair (
217223 key = 'DOCKER_ENV_VARS' ,
218224 value =
219- '{"UWORKER": "True", "SWARMING_BOT": "True", "LOG_TO_GCP": "True", "LOGGING_CLOUD_PROJECT_ID": "project_id"}'
225+ '{"UWORKER": "True", "SWARMING_BOT": "True", "LOG_TO_GCP": "True", "IS_K8S_ENV": "True", " LOGGING_CLOUD_PROJECT_ID": "project_id"}'
220226 ),
221227 swarming_pb2 .StringPair (key = 'UWORKER' , value = 'True' ),
222228 swarming_pb2 .StringPair (
223229 key = 'SWARMING_BOT' , value = 'True' ),
224230 swarming_pb2 .StringPair (key = 'LOG_TO_GCP' , value = 'True' ),
231+ swarming_pb2 .StringPair (key = 'IS_K8S_ENV' , value = 'True' ),
225232 swarming_pb2 .StringPair (
226233 key = 'LOGGING_CLOUD_PROJECT_ID' , value = 'project_id' ),
227234 ],
@@ -234,7 +241,7 @@ def test_push_swarming_task(self):
234241 """Tests that push_swarming_task works as expected."""
235242 mock_creds = mock .MagicMock ()
236243 mock_creds .token = 'fake_token'
237- self .mock .get_default .return_value = ( mock_creds , None )
244+ self .mock .get_scoped_service_account_credentials .return_value = mock_creds
238245
239246 job = data_types .Job (name = 'libfuzzer_chrome_asan' , platform = 'LINUX' )
240247 job .put ()
@@ -253,7 +260,8 @@ def test_push_swarming_task(self):
253260 'luci-auth' , 'context' , '--' , './linux_entry_point.sh'
254261 ],
255262 dimensions = [
256- swarming_pb2 .StringPair (key = 'os' , value = job .platform ),
263+ swarming_pb2 .StringPair (
264+ key = 'os' , value = str (job .platform ).capitalize ()),
257265 swarming_pb2 .StringPair (key = 'pool' , value = 'pool-name' )
258266 ],
259267 cipd_input = swarming_pb2 .CipdInput (), # pylint: disable=no-member
@@ -273,20 +281,22 @@ def test_push_swarming_task(self):
273281 swarming_pb2 .StringPair (
274282 key = 'DOCKER_ENV_VARS' ,
275283 value =
276- '{"UWORKER": "True", "SWARMING_BOT": "True", "LOG_TO_GCP": "True", "LOGGING_CLOUD_PROJECT_ID": "project_id"}'
284+ '{"UWORKER": "True", "SWARMING_BOT": "True", "LOG_TO_GCP": "True", "IS_K8S_ENV": "True", " LOGGING_CLOUD_PROJECT_ID": "project_id"}'
277285 ),
278286 swarming_pb2 .StringPair (key = 'UWORKER' , value = 'True' ),
279287 swarming_pb2 .StringPair (
280288 key = 'SWARMING_BOT' , value = 'True' ),
281289 swarming_pb2 .StringPair (key = 'LOG_TO_GCP' , value = 'True' ),
290+ swarming_pb2 .StringPair (key = 'IS_K8S_ENV' , value = 'True' ),
282291 swarming_pb2 .StringPair (
283292 key = 'LOGGING_CLOUD_PROJECT_ID' , value = 'project_id' ),
284293 ],
285294 secret_bytes = base64 .b64encode (
286295 'https://download_url' .encode ('utf-8' ))))
287296 ])
288297
289- self .mock .get_default .assert_called_with (swarming ._SWARMING_SCOPES ) # pylint: disable=protected-access
298+ self .mock .get_scoped_service_account_credentials .assert_called_with (
299+ swarming ._SWARMING_SCOPES ) # pylint: disable=protected-access
290300 expected_headers = {
291301 'Accept' : 'application/json' ,
292302 'Content-Type' : 'application/json' ,
@@ -302,7 +312,7 @@ def test_push_swarming_task_with_refresh(self):
302312 """Tests that push_swarming_task refreshes credentials if token is missing."""
303313 mock_creds = mock .MagicMock ()
304314 mock_creds .token = None
305- self .mock .get_default .return_value = ( mock_creds , None )
315+ self .mock .get_scoped_service_account_credentials .return_value = mock_creds
306316
307317 def refresh_side_effect (_ ):
308318 mock_creds .token = 'refreshed_token'
@@ -370,7 +380,7 @@ def test_get_task_dimensions_job_precedence(self):
370380 dimensions = spec .task_slices [0 ].properties .dimensions
371381
372382 expected_dimensions = [
373- swarming_pb2 .StringPair (key = 'os' , value = 'MAC ' ),
383+ swarming_pb2 .StringPair (key = 'os' , value = 'Mac ' ),
374384 swarming_pb2 .StringPair (key = 'pool' , value = 'pool-name' ),
375385 swarming_pb2 .StringPair (key = 'key1' , value = 'job_value1' ),
376386 swarming_pb2 .StringPair (key = 'key2' , value = 'value2' ),
0 commit comments