Skip to content

Commit 094ac86

Browse files
authored
Merge pull request #69 from cloudfoundry/simplify_s3_integration_tests
Simplify S3 integration tests
2 parents 16c44e2 + 785bc1a commit 094ac86

17 files changed

Lines changed: 108 additions & 186 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Set up Go test environment
2+
description: Sets up Go from go.mod and installs Ginkgo.
3+
4+
runs:
5+
using: 'composite'
6+
steps:
7+
- name: Set up Go
8+
uses: actions/setup-go@v6
9+
with:
10+
go-version-file: go.mod
11+
12+
- name: Install Ginkgo
13+
shell: bash
14+
run: go install github.com/onsi/ginkgo/v2/ginkgo@latest

.github/actions/s3-integration-run/action.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ inputs:
1212
description: 'AWS Region Name'
1313
required: true
1414
stack_name:
15-
description: 'CloudFormation Stack Name (required for IAM tests)'
16-
required: true
15+
description: 'CloudFormation Stack Name'
16+
required: false
17+
default: ''
1718
test_type:
1819
description: 'Type of test to run (e.g.,aws, aws-iam, aws-assume)'
1920
required: true
20-
focus_regex:
21-
description: 'Ginkgo Focus Regex for tests to run'
22-
required: false
21+
label_filter:
22+
description: 'Ginkgo Label Filter for tests to run'
23+
required: true
2324
s3_endpoint_host:
2425
description: 'Custom S3 Endpoint Host'
2526
required: false
@@ -43,15 +44,16 @@ runs:
4344
if [[ "${{inputs.test_type}}" == "aws" ]]; then
4445
export role_arn="${{inputs.role_arn}}"
4546
export s3_endpoint_host="${{inputs.s3_endpoint_host}}"
46-
export focus_regex="${{inputs.focus_regex}}"
47+
export label_filter="${{inputs.label_filter}}"
4748
echo "Running standard AWS integration tests..."
4849
./.github/scripts/s3/run-integration-aws.sh
4950
elif [[ "${{inputs.test_type}}" == "aws-iam" ]]; then
51+
export label_filter="${{inputs.label_filter}}"
5052
echo "Running AWS IAM role tests..."
5153
./.github/scripts/s3/run-integration-aws-iam.sh
5254
elif [[ "${{inputs.test_type}}" == "aws-assume" ]]; then
5355
export assume_role_arn="${{inputs.role_arn}}"
54-
export focus_regex="${{inputs.focus_regex}}"
56+
export label_filter="${{inputs.label_filter}}"
5557
echo "Running AWS assume role tests..."
5658
./.github/scripts/s3/run-integration-aws-assume.sh
5759
else

.github/scripts/s3/assets/lambda_function.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import logging
33
import subprocess
44

5+
56
def test_runner_handler(event, context):
67
os.environ['S3_CLI_PATH'] = './s3cli'
78
os.environ['BUCKET_NAME'] = event['bucket_name']
@@ -11,9 +12,14 @@ def test_runner_handler(event, context):
1112
logger = logging.getLogger()
1213
logger.setLevel(logging.DEBUG)
1314

15+
label_filter = event.get('label_filter', 'aws && iam-role')
16+
1417
try:
15-
output = subprocess.check_output(['./integration.test', '-ginkgo.focus', 'AWS STANDARD IAM ROLE'],
16-
env=os.environ, stderr=subprocess.STDOUT)
18+
output = subprocess.check_output(
19+
['./integration.test', '-ginkgo.label-filter', label_filter],
20+
env=os.environ,
21+
stderr=subprocess.STDOUT,
22+
)
1723
logger.debug("INTEGRATION TEST OUTPUT:")
1824
logger.debug(output)
1925
except subprocess.CalledProcessError as e:

.github/scripts/s3/run-integration-aws-assume.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ source "${script_dir}/utils.sh"
1212
: "${access_key_id:?}"
1313
: "${secret_access_key:?}"
1414
: "${region_name:=unset}"
15-
: "${focus_regex:?}"
15+
: "${label_filter:?}"
1616
: "${assume_role_arn:=unset}"
1717
: "${s3_endpoint_host:=unset}"
1818

19-
2019
# Just need these to get the stack info
2120
export AWS_ACCESS_KEY_ID=${access_key_id}
2221
export AWS_SECRET_ACCESS_KEY=${secret_access_key}
@@ -32,5 +31,6 @@ export S3_HOST=${s3_endpoint_host}
3231

3332
pushd "${repo_root}" > /dev/null
3433
echo -e "\n running tests with $(go version)..."
35-
ginkgo -r --focus="${focus_regex}" s3/integration/
34+
echo "Selecting specs via label filter: ${label_filter}"
35+
ginkgo -r --label-filter="${label_filter}" s3/integration/
3636
popd > /dev/null

.github/scripts/s3/run-integration-aws-iam.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ source "${script_dir}/utils.sh"
1313
: "${secret_access_key:?}"
1414
: "${region_name:?}"
1515
: "${stack_name:?}"
16+
: "${label_filter:?}"
1617

1718
# Just need these to get the stack info and to create/invoke the Lambda function
1819
export AWS_ACCESS_KEY_ID=${access_key_id}
@@ -24,11 +25,11 @@ bucket_name=$(get_stack_info_of "${stack_info}" "BucketName")
2425
iam_role_arn=$(get_stack_info_of "${stack_info}" "IamRoleArn")
2526

2627
# Create JSON payload and base64 encode it
27-
lambda_payload_json="{\"region\": \"${region_name}\", \"bucket_name\": \"${bucket_name}\", \"s3_host\": \"s3.amazonaws.com\"}"
28+
lambda_payload_json="{\"region\": \"${region_name}\", \"bucket_name\": \"${bucket_name}\", \"s3_host\": \"s3.amazonaws.com\", \"label_filter\": \"${label_filter}\"}"
2829
lambda_payload_base64=$(echo -n "${lambda_payload_json}" | base64)
2930

3031
lambda_log=$(mktemp -t "XXXXXX-lambda.log")
31-
trap "cat ${lambda_log}" EXIT
32+
trap 'cat "${lambda_log}"' EXIT
3233

3334
# Go to the repository root (3 levels up from script directory)
3435

@@ -95,7 +96,7 @@ pushd "${repo_root}" > /dev/null
9596
echo "Lambda execution log output for ${log_stream_name}"
9697

9798
tries=0
98-
> lambda_output.log
99+
: > lambda_output.log
99100
while [[ ( "$(du lambda_output.log | cut -f 1)" -eq "0" ) && ( $tries -ne 20 ) ]] ; do
100101
sleep 2
101102
tries=$((tries + 1))

.github/scripts/s3/run-integration-aws.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ source "${script_dir}/utils.sh"
1414
: "${secret_access_key:?}"
1515
: "${region_name:?}"
1616
: "${stack_name:?}"
17-
: "${focus_regex:?}"
17+
: "${role_arn:=}"
18+
: "${label_filter:?}"
1819
: "${s3_endpoint_host:=unset}"
1920

20-
2121
# Just need these to get the stack info
2222
export AWS_ACCESS_KEY_ID=${access_key_id}
2323
export AWS_SECRET_ACCESS_KEY=${secret_access_key}
2424
export AWS_DEFAULT_REGION=${region_name}
25-
export AWS_ROLE_ARN=${role_arn}
25+
export AWS_ROLE_ARN=${role_arn-}
2626
stack_info=$(get_stack_info "${stack_name}")
2727

2828
if [ -n "${AWS_ROLE_ARN}" ]; then
@@ -48,5 +48,6 @@ export S3_HOST=${s3_endpoint_host}
4848

4949
pushd "${repo_root}" > /dev/null
5050
echo -e "\n running tests with $(go version)..."
51-
ginkgo -r --focus="${focus_regex}" s3/integration/
51+
echo "Selecting specs via label filter: ${label_filter}"
52+
ginkgo -r --label-filter="${label_filter}" s3/integration/
5253
popd > /dev/null

.github/scripts/s3/run-integration-s3-compat.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ source "${script_dir}/utils.sh"
1515
: "${bucket_name:?}"
1616
: "${s3_endpoint_host:?}"
1717
: "${s3_endpoint_port:?}"
18+
: "${label_filter:=s3-compatible}"
1819

1920
export ACCESS_KEY_ID=${access_key_id}
2021
export SECRET_ACCESS_KEY=${secret_access_key}
@@ -24,5 +25,6 @@ export S3_PORT=${s3_endpoint_port}
2425

2526
pushd "${repo_root}" > /dev/null
2627
echo -e "\n running tests with $(go version)..."
27-
ginkgo -r --focus="S3 COMPATIBLE" s3/integration/
28+
echo "Selecting specs via label filter: ${label_filter}"
29+
ginkgo -r --label-filter="${label_filter}" s3/integration/
2830
popd > /dev/null

0 commit comments

Comments
 (0)