Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/all-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ jobs:
python-version: ${{ inputs.python-version || '3.11' }}
secrets: inherit

python-perf:
permissions:
id-token: write
contents: read
name: Python Performance Tests
uses: ./.github/workflows/python-perf.yml
with:
python-version: ${{ inputs.python-version || '3.11' }}
secrets: inherit

run-duvet:
permissions:
id-token: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-integ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:

- name: Run unit tests
run: |
uv run pytest test/ --ignore=test/integration/ --verbose \
uv run pytest test/ --ignore=test/integration/ --ignore=test/performance/ --verbose \
--cov=src/s3_encryption --cov-report=term-missing --cov-report=html:coverage-unit \
--cov-fail-under=89

Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/python-perf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Python Performance Tests

on:
workflow_call:
inputs:
python-version:
description: "Python version to use"
default: "3.11"
required: false
type: string

jobs:
python-perf:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v6
with:
submodules: false

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ inputs.python-version || '3.11' }}

- name: Cache uv dependencies
uses: actions/cache@v5
with:
path: ~/.cache/uv
key: ${{ runner.os }}-uv-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-uv-

- name: Install Uv
run: pip install uv

- name: Install dependencies
run: make install

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: arn:aws:iam::370957321024:role/S3EC-Python-Github-test-role
aws-region: us-west-2

- name: Run performance tests
run: make test-perf
env:
CI_S3_BUCKET: ${{ vars.CI_S3_BUCKET }}
CI_KMS_KEY_ALIAS: ${{ vars.CI_KMS_KEY_ALIAS }}
PERF_NUM_ROUNDS: "30"

- name: Generate performance HTML report
if: always()
run: uv run python test/performance/generate_report.py

- name: Upload performance report
if: always()
uses: actions/upload-artifact@v7
with:
name: performance-report
path: perf-results/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ smithy-java-core/out
*.pid
.coverage
coverage-report/
perf-results/
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: lint format test test-unit test-integration install
.PHONY: lint format test test-unit test-integration test-perf install

# Default target
all: lint test duvet
Expand All @@ -25,12 +25,16 @@ test: test-unit test-integration test-examples

# Run unit tests with coverage
test-unit:
uv run pytest test/ --ignore=test/integration/ --verbose --cov=src/s3_encryption --cov-report=term-missing --cov-fail-under=89
uv run pytest test/ --ignore=test/integration/ --ignore=test/performance/ --verbose --cov=src/s3_encryption --cov-report=term-missing --cov-fail-under=89

# Run integration tests with separate coverage
test-integration:
uv run pytest test/integration/ --verbose --cov=src/s3_encryption --cov-report=term-missing --cov-fail-under=83

# Run performance tests
test-perf:
uv run pytest test/performance/ --verbose -x

test-examples:
uv run pytest examples/test/ -v

Expand Down
2 changes: 2 additions & 0 deletions test/performance/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
43 changes: 43 additions & 0 deletions test/performance/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
"""Shared fixtures for performance tests."""

import os

import boto3
import pytest

from s3_encryption import S3EncryptionClient, S3EncryptionClientConfig
from s3_encryption.materials.kms_keyring import KmsKeyring

BUCKET = os.environ.get("CI_S3_BUCKET", "s3ec-python-github-test-bucket")
REGION = os.environ.get("CI_AWS_REGION", "us-west-2")
KMS_KEY_ID = os.environ.get(
"CI_KMS_KEY_ALIAS", "arn:aws:kms:us-west-2:370957321024:alias/S3EC-Python-Github-KMS-Key"
)

# Performance test configuration
NUM_ROUNDS = int(os.environ.get("PERF_NUM_ROUNDS", "30"))
OBJECT_SIZES_MB = [10, 25, 50]


def _make_s3ec(algorithm_suite, commitment_policy):
kms_client = boto3.client("kms", region_name=REGION)
keyring = KmsKeyring(kms_client, KMS_KEY_ID)
wrapped_client = boto3.client("s3")
config = S3EncryptionClientConfig(
keyring,
encryption_algorithm=algorithm_suite,
commitment_policy=commitment_policy,
)
return S3EncryptionClient(wrapped_client, config)


@pytest.fixture(scope="module")
def plain_s3():
return boto3.client("s3", region_name=REGION)


@pytest.fixture(scope="module")
def kms_client():
return boto3.client("kms", region_name=REGION)
Loading
Loading