14
14
from packaging .version import parse
15
15
from pathlib import Path
16
16
17
+ from util import add_certificate
18
+
17
19
SERVICE_TEST_PATH = {}
18
20
MAIN_REPO_SWAGGER = 'https://github.com/Azure/azure-rest-api-specs/tree/main'
19
21
PR_URL = 'https://github.com/Azure/azure-rest-api-specs/pull/'
@@ -184,6 +186,7 @@ def bot_analysis(self):
184
186
185
187
def sdk_info_from_pypi (sdk_info , cli_dependency ):
186
188
all_sdk_status = []
189
+ add_certificate (str (Path ('../venv-sdk/lib/python3.8/site-packages/certifi/cacert.pem' )))
187
190
for package in sdk_info :
188
191
if ',' in package :
189
192
package = package .split (',' )
@@ -233,11 +236,13 @@ def get_test_result(txt_path):
233
236
234
237
235
238
def run_playback_test (service_name ):
239
+ if os .getenv ('SKIP_COVERAGE' ) in ('true' , 'yes' ):
240
+ return '-, -, -, -\n '
241
+
236
242
# eg: coverage_path='$(pwd)/sdk-repo/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/'
237
243
coverage_path = '' .join ([os .getenv ('SDK_REPO' ), '/sdk/' , SERVICE_TEST_PATH [service_name ]])
238
244
service_path = coverage_path .split ('/azure/mgmt' )[0 ]
239
245
test_path = service_path + '/tests'
240
- print (f'****{ service_name } *****' )
241
246
if os .path .exists (test_path ):
242
247
print_check ('pip install -r dev_requirements.txt' , path = service_path )
243
248
print_check ('pip install -e .' , path = service_path )
@@ -246,16 +251,17 @@ def run_playback_test(service_name):
246
251
operations_path = coverage_path + '/operations'
247
252
models_path = coverage_path + '/models'
248
253
try :
254
+ start_time = int (time .time ())
249
255
print_check (f'pytest -s tests --cov={ operations_path } --cov={ models_path } >result.txt' , path = service_path )
256
+ cost_time = int (time .time ()) - start_time
257
+ my_print (f'{ service_name } play_back cost { cost_time } seconds({ cost_time // 60 } minutes)' )
250
258
except Exception as e :
251
259
print (f'{ service_name } test ERROR' )
252
260
return '-, 0, 0, 0\n '
253
261
else :
254
262
try :
255
- print (f'hhh { service_name } no coverage' )
256
263
print_check (f'pytest -s tests >result.txt' , path = service_path )
257
264
except Exception as e :
258
- print (f'{ service_name } test ERROR' )
259
265
return '-, 0, 0, 0\n '
260
266
if os .path .exists (service_path + '/result.txt' ):
261
267
return get_test_result (service_path + '/result.txt' )
0 commit comments