[pipeline] optimize the way to set cert for test-proxy (#28596)
* fix * update * update * ssl cert * clean test env * fix * update * pylint
This commit is contained in:
Родитель
980148dd08
Коммит
229d62fb1b
|
@ -483,9 +483,17 @@ class CodegenTestPR:
|
|||
log(f'{test_mode} run done, do not find failure !!!')
|
||||
self.test_result = succeeded_result
|
||||
|
||||
@staticmethod
|
||||
def clean_test_env():
|
||||
for item in ("SSL_CERT_DIR", "REQUESTS_CA_BUNDLE"):
|
||||
if os.getenv(item):
|
||||
os.environ.pop(item)
|
||||
|
||||
def run_test(self):
|
||||
self.prepare_test_env()
|
||||
self.run_test_proc()
|
||||
self.clean_test_env()
|
||||
|
||||
|
||||
def create_pr_proc(self):
|
||||
api = GhApi(owner='Azure', repo='azure-sdk-for-python', token=self.bot_token)
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _find_certificate():
|
||||
devcert_path = Path('eng/common/testproxy/dotnet-devcert.crt')
|
||||
with open(devcert_path, 'r') as fr:
|
||||
return fr.read()
|
||||
from subprocess import getoutput
|
||||
|
||||
|
||||
def add_certificate():
|
||||
certification = _find_certificate()
|
||||
cacert_path = Path('../venv-sdk/lib/python3.8/site-packages/certifi/cacert.pem')
|
||||
with open(cacert_path, 'a+') as f:
|
||||
f.seek(0, 0)
|
||||
f.write(certification)
|
||||
# Set the following certificate paths:
|
||||
# SSL_CERT_DIR=C:\<YOUR DIRECTORY>\azure-sdk-for-python\.certificate
|
||||
# REQUESTS_CA_BUNDLE=C:\<YOUR DIRECTORY>\azure-sdk-for-python\.certificate\dotnet-devcert.pem
|
||||
result = getoutput(f"python {Path('scripts/devops_tasks/trust_proxy_cert.py')}").split("\n")
|
||||
for item in result[1:]:
|
||||
name, value = item.strip().split("=", 1)
|
||||
os.environ[name] = value
|
||||
|
|
|
@ -282,6 +282,12 @@ def run_test(sdk_name, service_name, sdk_folder):
|
|||
return test_result
|
||||
|
||||
|
||||
def clean_test_env():
|
||||
for item in ("SSL_CERT_DIR", "REQUESTS_CA_BUNDLE"):
|
||||
if os.getenv(item):
|
||||
os.environ.pop(item)
|
||||
|
||||
|
||||
def sdk_info_from_pypi(sdk_info: List[Dict[str, str]], cli_dependency):
|
||||
all_sdk_status = []
|
||||
add_certificate()
|
||||
|
@ -310,6 +316,7 @@ def sdk_info_from_pypi(sdk_info: List[Dict[str, str]], cli_dependency):
|
|||
text_to_write += test_result
|
||||
all_sdk_status.append(text_to_write)
|
||||
|
||||
clean_test_env()
|
||||
my_print(f'total pypi package kinds: {len(all_sdk_status)}')
|
||||
return all_sdk_status
|
||||
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _find_certificate():
|
||||
devcert_path = Path(os.getenv('SDK_REPO') + '/eng/common/testproxy/dotnet-devcert.crt')
|
||||
with open(devcert_path, 'r') as fr:
|
||||
return fr.read()
|
||||
from subprocess import getoutput
|
||||
|
||||
|
||||
def add_certificate():
|
||||
certification = _find_certificate()
|
||||
cacert_path = Path('../venv-sdk/lib/python3.8/site-packages/certifi/cacert.pem')
|
||||
with open(cacert_path, 'a+') as f:
|
||||
f.seek(0, 0)
|
||||
f.write(certification)
|
||||
# Set the following certificate paths:
|
||||
# SSL_CERT_DIR=C:\<YOUR DIRECTORY>\azure-sdk-for-python\.certificate
|
||||
# REQUESTS_CA_BUNDLE=C:\<YOUR DIRECTORY>\azure-sdk-for-python\.certificate\dotnet-devcert.pem
|
||||
result = getoutput(f"python {Path('scripts/devops_tasks/trust_proxy_cert.py')}").split("\n")
|
||||
for item in result[1:]:
|
||||
name, value = item.strip().split("=", 1)
|
||||
os.environ[name] = value
|
||||
|
|
Загрузка…
Ссылка в новой задаче