@@ -127,14 +127,25 @@ def _trigger_batch_tests(self):
127
127
"DD-API-KEY" : self .api_key ,
128
128
"DD-APPLICATION-KEY" : self .app_key
129
129
}
130
- test_public_ids = self .tests_by_public_id .keys ()
131
- json_request_body = {"tests" : [{"public_id" : public_id } for public_id in test_public_ids ]}
130
+ x = "(\w+)\.edx.org|1.stage.edx.org"
131
+ json_request_body = {"tests" : [{"public_id" : test .public_id ,
132
+ "startUrl" : test .url ,
133
+ "resourceUrlSubstitutionRegexes" : self ._map_environment_resources (test .env )}
134
+ for test in self .tests_by_public_id .values ()]}
132
135
logging .info (f'Trigger request body: { json_request_body } ' )
133
136
response = requests .post (url , headers = headers , json = json_request_body )
134
137
if response .status_code != 200 :
135
138
raise Exception (f"Datadog API error. Status = { response .status_code } " )
136
139
return response
137
140
141
+ def _map_environment_resources (self , env ):
142
+ if not env or env == 'prod' :
143
+ return r"(\.*)|\1" # No change
144
+ elif env == 'stage' :
145
+ return r'"(\.+)\.edx.org|\1.stage.edx.org"'
146
+ else :
147
+ raise Exception (f'Unknown { env } environment' )
148
+
138
149
def _record_batch_id (self , response_body ):
139
150
'''
140
151
Datadog generates a single batch ID associated with the request for all the requested tests. This is distinct
@@ -253,7 +264,7 @@ def run_synthetic_tests(enable_automated_rollbacks, timeout, tests):
253
264
dd_client .timeout_secs = timeout
254
265
255
266
tests_as_dicts = json .loads (tests )
256
- tests_to_report_on = [SyntheticTest (d ["name" ], d ["public_id" ]) for d in tests_as_dicts ]
267
+ tests_to_report_on = [SyntheticTest (d ["name" ], d ["public_id" ], d [ "env" ], d [ "startUrl" ] ) for d in tests_as_dicts ]
257
268
dd_client .trigger_synthetic_tests (tests_to_report_on )
258
269
dd_client .gate_on_deployment_testing_enable_switch () # Exits summarily if test results are to be ignored
259
270
for test in tests_to_report_on :
0 commit comments