Skip to content

Commit 7fda8f5

Browse files
committed
test
1 parent 455cc01 commit 7fda8f5

File tree

3 files changed

+191
-94
lines changed

3 files changed

+191
-94
lines changed

codebuild/py311/examples.yml

Lines changed: 97 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ version: 0.2
22

33
env:
44
variables:
5-
TOXENV: "py311-examples"
5+
VERSION: 4.0.2
6+
REGION: "us-west-2"
67
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
78
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
89
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >-
@@ -16,7 +17,100 @@ phases:
1617
install:
1718
runtime-versions:
1819
python: 3.11
19-
build:
2020
commands:
21+
# Check VERSION is available from either environment or env.variables
22+
- |
23+
if [ -z "$VERSION" ]; then
24+
echo "Using default VERSION=$VERSION"
25+
else
26+
echo "Using provided VERSION=$VERSION"
27+
fi
28+
# Install the released package instead of the source
29+
- echo "Installing aws-encryption-sdk version $VERSION"
30+
- pip install "aws-encryption-sdk==$VERSION"
2131
- pip install "tox < 4.0"
22-
- tox
32+
build:
33+
commands:
34+
# Create a simple tox.ini file for running examples with the installed package
35+
- |
36+
cat > release_validation_tox.ini << 'EOF'
37+
[tox]
38+
envlist = py311
39+
skipsdist = True
40+
41+
[testenv]
42+
passenv =
43+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID
44+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2
45+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1
46+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2
47+
AWS_ACCESS_KEY_ID
48+
AWS_SECRET_ACCESS_KEY
49+
AWS_SESSION_TOKEN
50+
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
51+
AWS_PROFILE
52+
deps =
53+
pytest
54+
pytest-mock
55+
mock
56+
coverage
57+
pyyaml
58+
moto
59+
boto3
60+
cryptography
61+
commands =
62+
# Run non-MPL examples
63+
pytest examples/test/legacy/ -m examples
64+
# Run all other examples
65+
pytest examples/test/ -m examples --ignore examples/test/legacy/
66+
EOF
67+
68+
# Run the examples with NUM_RETRIES to handle transient failures
69+
- NUM_RETRIES=3
70+
- |
71+
while [ $NUM_RETRIES -gt 0 ]
72+
do
73+
tox -c release_validation_tox.ini -e py311
74+
if [ $? -eq 0 ]; then
75+
break
76+
fi
77+
NUM_RETRIES=$((NUM_RETRIES-1))
78+
if [ $NUM_RETRIES -eq 0 ]; then
79+
echo "All validation attempts failed, stopping"
80+
exit 1;
81+
else
82+
echo "Validation failed, retrying in 60 seconds; will retry $NUM_RETRIES more times" && sleep 60
83+
fi
84+
done
85+
86+
# Assume special role for MPL-specific tests
87+
- echo "Running tests with special role for MPL features"
88+
- TMP_ROLE=$(aws sts assume-role --role-arn "arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Python-Role-us-west-2" --role-session-name "CB-ValidateReleased")
89+
- export TMP_ROLE
90+
- export AWS_ACCESS_KEY_ID=$(echo "${TMP_ROLE}" | jq -r '.Credentials.AccessKeyId')
91+
- export AWS_SECRET_ACCESS_KEY=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SecretAccessKey')
92+
- export AWS_SESSION_TOKEN=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SessionToken')
93+
- aws sts get-caller-identity
94+
95+
# Also install MPL requirements
96+
- pip install -r requirements_mpl.txt
97+
98+
# Run MPL-specific examples
99+
- NUM_RETRIES=3
100+
- |
101+
while [ $NUM_RETRIES -gt 0 ]
102+
do
103+
# Only run the MPL-specific tests that require special permissions
104+
# These would normally be run with py311-mplexamples-mpl
105+
python -m pytest examples/test/ -m examples --ignore examples/test/legacy/
106+
if [ $? -eq 0 ]; then
107+
break
108+
fi
109+
NUM_RETRIES=$((NUM_RETRIES-1))
110+
if [ $NUM_RETRIES -eq 0 ]; then
111+
echo "All MPL validation attempts failed, stopping"
112+
exit 1;
113+
else
114+
echo "MPL validation failed, retrying in 60 seconds; will retry $NUM_RETRIES more times" && sleep 60
115+
fi
116+
done

codebuild/py312/examples.yml

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
version: 0.2
21

32
env:
43
variables:
5-
TOXENV: "py312-examples"
4+
VERSION: 4.0.2
5+
REGION: "us-west-2"
66
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
77
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
88
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >-
@@ -14,9 +14,57 @@ env:
1414
1515
phases:
1616
install:
17+
commands:
18+
- pip install "tox < 4.0" poetry
19+
- pip install --upgrade pip
1720
runtime-versions:
18-
python: 3.12
21+
python: latest
22+
dotnet: 6.0
23+
pre_build:
24+
commands:
25+
# Setup environment
26+
- aws configure set region us-west-2
27+
- git clone https://github.com/aws/aws-encryption-sdk.git esdk-dafny
28+
- cd esdk-dafny && git submodule update --init --recursive && cd ..
29+
# Install packages and setup environments
30+
- echo "Installing aws-encryption-sdk version $VERSION"
31+
- pip install "aws-encryption-sdk==$VERSION"
32+
- pyenv install --skip-existing 3.11.0 && pyenv local 3.11.0
33+
- make -C esdk-dafny/mpl/StandardLibrary setup_net
34+
- pip install pytest boto3 attrs cryptography
35+
# Update the aws-encryption-sdk version in TestVectors
36+
- sed -i "s/aws-encryption-sdk = \">=4.0.1\"/aws-encryption-sdk = \"==$VERSION\"/" \
37+
esdk-dafny/TestVectors/runtimes/python/pyproject.toml
1938
build:
2039
commands:
21-
- pip install "tox < 4.0"
22-
- tox
40+
- NUM_RETRIES=3
41+
- |
42+
run_command() {
43+
eval "$1"
44+
return $?
45+
}
46+
47+
# Navigate to TestVectors directory
48+
cd esdk-dafny/TestVectors || exit 1
49+
50+
while [ $NUM_RETRIES -gt 0 ]
51+
do
52+
53+
# Build TestVectors implementation in Python
54+
CORES=$(nproc || echo 4)
55+
if ! run_command "make transpile_python CORES=$CORES"; then
56+
NUM_RETRIES=$((NUM_RETRIES-1))
57+
[ $NUM_RETRIES -gt 0 ] && sleep 60 && continue
58+
exit 1
59+
fi
60+
61+
# Run all the test vector commands together
62+
if ! run_command "make test_generate_vectors_python && make test_encrypt_vectors_python && make test_decrypt_encrypt_vectors_python"; then
63+
NUM_RETRIES=$((NUM_RETRIES-1))
64+
[ $NUM_RETRIES -gt 0 ] && sleep 60 && continue
65+
exit 1
66+
fi
67+
68+
# Success
69+
break
70+
done

codebuild/py312/examples_mpl.yml

Lines changed: 41 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -15,102 +15,57 @@ env:
1515
1616
phases:
1717
install:
18+
commands:
19+
- pip install "tox < 4.0" poetry
20+
- pip install --upgrade pip
1821
runtime-versions:
19-
python: 3.11
22+
python: latest
23+
dotnet: 6.0
24+
pre_build:
2025
commands:
21-
# Check VERSION is available from either environment or env.variables
22-
- |
23-
if [ -z "$VERSION" ]; then
24-
echo "Using default VERSION=$VERSION"
25-
else
26-
echo "Using provided VERSION=$VERSION"
27-
fi
28-
# Install the released package instead of the source
26+
# Setup environment
27+
- aws configure set region us-west-2
28+
- git clone https://github.com/aws/aws-encryption-sdk.git esdk-dafny
29+
- cd esdk-dafny && git submodule update --init --recursive && cd ..
30+
# Install packages and setup environments
2931
- echo "Installing aws-encryption-sdk version $VERSION"
3032
- pip install "aws-encryption-sdk==$VERSION"
31-
- pip install "tox < 4.0"
33+
- pyenv install --skip-existing 3.11.0 && pyenv local 3.11.0
34+
- make -C esdk-dafny/mpl/StandardLibrary setup_net
35+
- pip install pytest boto3 attrs cryptography
36+
# Update the aws-encryption-sdk version in TestVectors
37+
- sed -i "s/aws-encryption-sdk = \">=4.0.1\"/aws-encryption-sdk = \"==$VERSION\"/" \
38+
esdk-dafny/TestVectors/runtimes/python/pyproject.toml
3239
build:
3340
commands:
34-
# Create a simple tox.ini file for running examples with the installed package
35-
- |
36-
cat > release_validation_tox.ini << 'EOF'
37-
[tox]
38-
envlist = py311
39-
skipsdist = True
40-
41-
[testenv]
42-
passenv =
43-
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID
44-
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2
45-
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1
46-
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2
47-
AWS_ACCESS_KEY_ID
48-
AWS_SECRET_ACCESS_KEY
49-
AWS_SESSION_TOKEN
50-
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
51-
AWS_PROFILE
52-
deps =
53-
pytest
54-
pytest-mock
55-
mock
56-
coverage
57-
pyyaml
58-
moto
59-
boto3
60-
cryptography
61-
commands =
62-
# Run non-MPL examples
63-
pytest examples/test/legacy/ -m examples
64-
# Run all other examples
65-
pytest examples/test/ -m examples --ignore examples/test/legacy/
66-
EOF
67-
68-
# Run the examples with NUM_RETRIES to handle transient failures
69-
- NUM_RETRIES=3
70-
- |
71-
while [ $NUM_RETRIES -gt 0 ]
72-
do
73-
tox -c release_validation_tox.ini -e py311
74-
if [ $? -eq 0 ]; then
75-
break
76-
fi
77-
NUM_RETRIES=$((NUM_RETRIES-1))
78-
if [ $NUM_RETRIES -eq 0 ]; then
79-
echo "All validation attempts failed, stopping"
80-
exit 1;
81-
else
82-
echo "Validation failed, retrying in 60 seconds; will retry $NUM_RETRIES more times" && sleep 60
83-
fi
84-
done
85-
86-
# Assume special role for MPL-specific tests
87-
- echo "Running tests with special role for MPL features"
88-
- TMP_ROLE=$(aws sts assume-role --role-arn "arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Python-Role-us-west-2" --role-session-name "CB-ValidateReleased")
89-
- export TMP_ROLE
90-
- export AWS_ACCESS_KEY_ID=$(echo "${TMP_ROLE}" | jq -r '.Credentials.AccessKeyId')
91-
- export AWS_SECRET_ACCESS_KEY=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SecretAccessKey')
92-
- export AWS_SESSION_TOKEN=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SessionToken')
93-
- aws sts get-caller-identity
94-
95-
# Also install MPL requirements
96-
- pip install -r requirements_mpl.txt
97-
98-
# Run MPL-specific examples
9941
- NUM_RETRIES=3
10042
- |
43+
run_command() {
44+
eval "$1"
45+
return $?
46+
}
47+
48+
# Navigate to TestVectors directory
49+
cd esdk-dafny/TestVectors || exit 1
50+
10151
while [ $NUM_RETRIES -gt 0 ]
10252
do
103-
# Only run the MPL-specific tests that require special permissions
104-
# These would normally be run with py311-mplexamples-mpl
105-
python -m pytest examples/test/ -m examples --ignore examples/test/legacy/
106-
if [ $? -eq 0 ]; then
107-
break
53+
54+
# Build TestVectors implementation in Python
55+
CORES=$(nproc || echo 4)
56+
if ! run_command "make transpile_python CORES=$CORES"; then
57+
NUM_RETRIES=$((NUM_RETRIES-1))
58+
[ $NUM_RETRIES -gt 0 ] && sleep 60 && continue
59+
exit 1
10860
fi
109-
NUM_RETRIES=$((NUM_RETRIES-1))
110-
if [ $NUM_RETRIES -eq 0 ]; then
111-
echo "All MPL validation attempts failed, stopping"
112-
exit 1;
113-
else
114-
echo "MPL validation failed, retrying in 60 seconds; will retry $NUM_RETRIES more times" && sleep 60
61+
62+
# Run all the test vector commands together
63+
if ! run_command "make test_generate_vectors_python && make test_encrypt_vectors_python && make test_decrypt_encrypt_vectors_python"; then
64+
NUM_RETRIES=$((NUM_RETRIES-1))
65+
[ $NUM_RETRIES -gt 0 ] && sleep 60 && continue
66+
exit 1
11567
fi
68+
69+
# Success
70+
break
11671
done

0 commit comments

Comments
 (0)