-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28ef544
commit c5ae346
Showing
23 changed files
with
1,417 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
name: Acceptenace Test Run | ||
on: | ||
workflow_call: | ||
inputs: | ||
tests: | ||
required: true | ||
type: string | ||
deletion-policy: | ||
required: true | ||
type: string # delete/retain | ||
permissions: | ||
id-token: write | ||
contents: read | ||
defaults: | ||
run: | ||
shell: bash | ||
jobs: | ||
run: | ||
runs-on: ['hyperenv', 'medium'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: aws-actions/configure-aws-credentials@v4.0.1 | ||
with: | ||
role-to-assume: arn:aws:iam::859548834666:role/github-openid-connect | ||
role-session-name: github-actions-aws-in-action-code3 | ||
role-duration-seconds: 21600 | ||
aws-region: us-east-1 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: corretto | ||
java-version: '8' | ||
cache: maven | ||
- working-directory: test | ||
env: | ||
DELETION_POLICY: ${{ inputs.deletion-policy }} | ||
TEMPLATE_DIR: ../ | ||
run: mvn -B clean test site -Dtest=${{ inputs.tests }} -Dsurefire.reportNameSuffix=us-east-1 | ||
- uses: actions/upload-artifact@v3 | ||
if: failure() | ||
with: | ||
name: surefire-reports-us-east-1 | ||
path: | | ||
test/target/surefire-reports/ | ||
test/target/site/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
name: Acceptenace Test | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tests: | ||
required: true | ||
type: choice | ||
default: '*' | ||
options: # compile list with cd test/src && find . -name '*Test*' -execdir basename {} .java ';' | sort | ||
- '*' | ||
- Chapter02Test | ||
- Chapter04Test | ||
- Chapter05Test | ||
- Chapter08Test | ||
- Chapter09Test | ||
- Chapter10Test | ||
- Chapter11Test | ||
- Chapter13Test | ||
- Chapter14Test | ||
- Chapter15Test | ||
- Chapter17Test | ||
- Chapter18Test | ||
deletion-policy: | ||
required: true | ||
type: choice | ||
default: delete | ||
options: | ||
- delete | ||
- retain | ||
defaults: | ||
run: | ||
shell: bash | ||
jobs: | ||
acceptance-test: | ||
uses: ./.github/workflows/acceptance-test-run.yml | ||
with: | ||
tests: ${{ inputs.tests }} | ||
deletion-policy: ${{ inputs.deletion-policy }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
name: Acceptenace Tests | ||
on: | ||
workflow_dispatch: {} | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- '.github/workflows/acceptance-tests.yml' | ||
- '*.yaml' | ||
- 'test/**' | ||
concurrency: acceptenace-tests-${{ github.ref }} | ||
defaults: | ||
run: | ||
shell: bash | ||
jobs: | ||
acceptance-test: | ||
uses: ./.github/workflows/acceptance-test-run.yml | ||
with: | ||
tests: '*' | ||
deletion-policy: delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# AWS in Action (3rd edition) Code tests | ||
|
||
Tests for https://github.com/AWSinAction/code3 | ||
|
||
The goal of this tests is to ensure that our templates are always working. The test are implemented in Java 8 and run in JUnit 4. | ||
|
||
If you run this tests, many AWS CloudFormation tests are created and **charges will apply**! | ||
|
||
## Supported env variables | ||
|
||
* `IAM_ROLE_ARN` if the tests should assume an IAM role before they run supply the ARN of the IAM role | ||
* `TEMPLATE_DIR` Load templates from local disk (instead of S3 bucket `widdix-aws-cf-templates`). Must end with an `/`. See `BUCKET_NAME` as well. | ||
* `BUCKET_NAME` Some templates are to big to be passed as a string from local disk, therefore you need to supply the name of the bucket that is used to upload templates. | ||
* `BUCKET_REGION` **required if BUCKET_NAME is set** Region of the bucket | ||
* `DELETION_POLICY` (default `delete`, allowed values [`delete`, `retain`]) should resources be deleted? | ||
|
||
## Usage | ||
|
||
### AWS credentials | ||
|
||
The AWS credentials are passed in as defined by the AWS SDK for Java: http://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html | ||
|
||
One addition is, that you can supply the env variable `IAM_ROLE_ARN` which let's the tests assume a role before they start with the default credentials. | ||
|
||
### Region selection | ||
|
||
The region selection works like defined by the AWS SDK for Java: http://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/java-dg-region-selection.html | ||
|
||
### Run all tests | ||
|
||
``` | ||
AWS_REGION="us-east-1" mvn test | ||
``` | ||
|
||
### Run a single test suite | ||
|
||
to run the `TestJenkins` tests: | ||
|
||
``` | ||
AWS_REGION="us-east-1" mvn -Dtest=TestJenkins test | ||
``` | ||
|
||
### Run a single test | ||
|
||
to run the `TestJenkins.testHA` test: | ||
|
||
``` | ||
AWS_REGION="us-east-1" mvn -Dtest=TestJenkins#testHA test | ||
``` | ||
|
||
### Load templates from local file system | ||
|
||
``` | ||
AWS_REGION="us-east-1" BUCKET_REGION="..." BUCKET_NAME="..." TEMPLATE_DIR="/path/to/widdix-aws-cf-templates/" mvn test | ||
``` | ||
|
||
### Assume role | ||
|
||
This is useful if you run on a integration server like Jenkins and want to assume a different IAM role for this tests. | ||
|
||
``` | ||
IAM_ROLE_ARN="arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME" mvn test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>de.widdix</groupId> | ||
<artifactId>aws-in-action-code3-tests</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.amazonaws</groupId> | ||
<artifactId>aws-java-sdk-cloudformation</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.amazonaws</groupId> | ||
<artifactId>aws-java-sdk-ec2</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.amazonaws</groupId> | ||
<artifactId>aws-java-sdk-s3</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.amazonaws</groupId> | ||
<artifactId>aws-java-sdk-ecs</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.amazonaws</groupId> | ||
<artifactId>aws-java-sdk-sts</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>de.taimos</groupId> | ||
<artifactId>httputils</artifactId> | ||
<version>1.10</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.evanlennick</groupId> | ||
<artifactId>retry4j</artifactId> | ||
<version>0.6.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.jcraft</groupId> | ||
<artifactId>jsch</artifactId> | ||
<version>0.1.54</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.amazonaws</groupId> | ||
<artifactId>aws-java-sdk-bom</artifactId> | ||
<version>1.11.883</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.6.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.20</version> | ||
<configuration> | ||
<parallel>classes</parallel> | ||
<threadCount>2</threadCount> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
Oops, something went wrong.