mirror of
https://github.com/certbot/certbot.git
synced 2026-06-04 14:26:10 -04:00
make integration tests crossplatform (#10217)
i wanted this for testing https://github.com/certbot/certbot/issues/10190 alex started working on this in https://github.com/certbot/certbot/pull/9207 years ago, but pebble didn't end up doing a release containing his work while he was still regularly contributing to certbot. this has now changed though before this PR, our integration tests only worked on amd64 linux systems. with this PR, i've successfully run our integration tests on all combinations of the architectures amd64 and arm64 and the OSes linux and macos --------- Co-authored-by: ohemorange <erica@eff.org>
This commit is contained in:
parent
48ffe02ce3
commit
2a92e22332
2 changed files with 21 additions and 8 deletions
|
|
@ -4,6 +4,7 @@ import importlib.resources
|
|||
import io
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
import stat
|
||||
import zipfile
|
||||
from contextlib import ExitStack
|
||||
|
|
@ -14,7 +15,7 @@ import requests
|
|||
from certbot_integration_tests.utils.constants import DEFAULT_HTTP_01_PORT
|
||||
from certbot_integration_tests.utils.constants import MOCK_OCSP_SERVER_PORT
|
||||
|
||||
PEBBLE_VERSION = 'v2.5.1'
|
||||
PEBBLE_VERSION = 'v2.7.0'
|
||||
|
||||
|
||||
def fetch(workspace: str, http_01_port: int = DEFAULT_HTTP_01_PORT) -> Tuple[str, str, str]:
|
||||
|
|
@ -32,11 +33,11 @@ def fetch(workspace: str, http_01_port: int = DEFAULT_HTTP_01_PORT) -> Tuple[str
|
|||
|
||||
|
||||
def _fetch_asset(asset: str, assets_path: str) -> str:
|
||||
platform = 'linux-amd64'
|
||||
base_url = 'https://github.com/letsencrypt/pebble/releases/download'
|
||||
asset_path = os.path.join(assets_path, f'{asset}_{PEBBLE_VERSION}_{platform}')
|
||||
os_type, architecture = _get_validated_os_and_architecture()
|
||||
asset_path = os.path.join(assets_path, f'{asset}_{PEBBLE_VERSION}_{os_type}_{architecture}')
|
||||
if not os.path.exists(asset_path):
|
||||
asset_url = f'{base_url}/{PEBBLE_VERSION}/{asset}-{platform}.zip'
|
||||
asset_url = f'{base_url}/{PEBBLE_VERSION}/{asset}-{os_type}-{architecture}.zip'
|
||||
response = requests.get(asset_url, timeout=30)
|
||||
response.raise_for_status()
|
||||
asset_data = _unzip_asset(response.content, asset)
|
||||
|
|
@ -49,6 +50,22 @@ def _fetch_asset(asset: str, assets_path: str) -> str:
|
|||
return asset_path
|
||||
|
||||
|
||||
def _get_validated_os_and_architecture() -> tuple[str, str]:
|
||||
os_type = platform.system().lower()
|
||||
if os_type not in ('darwin', 'linux'):
|
||||
raise ValueError(f'this code has not been tested on {os_type} systems')
|
||||
|
||||
architecture = platform.machine()
|
||||
if architecture in ('amd64', 'x86_64'):
|
||||
architecture = 'amd64'
|
||||
elif architecture in ('aarch64' 'arm64'):
|
||||
architecture = 'arm64'
|
||||
else:
|
||||
raise ValueError(f'this code has not been tested on {architecture} systems')
|
||||
|
||||
return os_type, architecture
|
||||
|
||||
|
||||
def _unzip_asset(zipped_data: bytes, asset_name: str) -> Optional[bytes]:
|
||||
with zipfile.ZipFile(io.BytesIO(zipped_data)) as zip_file:
|
||||
for entry in zip_file.filelist:
|
||||
|
|
|
|||
|
|
@ -125,10 +125,6 @@ You can test your code in several ways:
|
|||
- running the `automated integration`_ tests
|
||||
- running an *ad hoc* `manual integration`_ test
|
||||
|
||||
.. note:: Running integration tests does not currently work on macOS. See
|
||||
https://github.com/certbot/certbot/issues/6959. In the meantime, we
|
||||
recommend developers on macOS open a PR to run integration tests.
|
||||
|
||||
.. _automated unit:
|
||||
|
||||
Running automated unit tests
|
||||
|
|
|
|||
Loading…
Reference in a new issue