Skip to content

Commit 23ddb23

Browse files
authored
Merge pull request #33 from aws-observability/build-docker-for-e2e
Run E2E Test in docker container with packages already installed
2 parents 5614e56 + 68aeef3 commit 23ddb23

File tree

5 files changed

+93
-48
lines changed

5 files changed

+93
-48
lines changed

.github/workflows/appsignals-e2e-ec2-test.yml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@ env:
3131
LOG_GROUP_NAME: /aws/appsignals/generic
3232
TEST: ${{ inputs.test }}
3333
GET_ADOT_JAR_COMMAND: "wget -O adot.jar https://github.com/aws-observability/aws-otel-java-instrumentation/releases/latest/download/aws-opentelemetry-agent.jar"
34+
TEST_RESOURCES_FOLDER: /__w/aws-application-signals-test-framework/aws-application-signals-test-framework
3435
GET_CW_AGENT_RPM_COMMAND: "wget -O cw-agent.rpm https://amazoncloudwatch-agent-${{ inputs.aws-region }}.s3.${{ inputs.aws-region }}.amazonaws.com/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm"
35-
TEST_RESOURCES_FOLDER: /home/runner/work/aws-application-signals-test-framework/aws-application-signals-test-framework
36-
3736

3837
jobs:
3938
e2e-ec2-test:
4039
runs-on: ubuntu-latest
40+
container:
41+
image: ghcr.io/aws-observability/aws-application-signals-test-framework
42+
credentials:
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.PAT_PACKAGE_READ_ACCESS_TOKEN }}
4145
steps:
4246
- uses: actions/checkout@v4
4347
with:
@@ -64,13 +68,6 @@ jobs:
6468
role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/${{ secrets.E2E_TEST_ROLE_ARN }}
6569
aws-region: ${{ inputs.aws-region }}
6670

67-
- name: Set up terraform
68-
uses: ./.github/workflows/actions/execute_and_retry
69-
with:
70-
command: "wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg"
71-
post-command: 'echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
72-
&& sudo apt update && sudo apt install terraform'
73-
7471
- name: Initiate Terraform
7572
uses: ./.github/workflows/actions/execute_and_retry
7673
with:
@@ -176,13 +173,6 @@ jobs:
176173
curl -S -s http://${{ env.MAIN_SERVICE_ENDPOINT }}/aws-sdk-call/
177174
curl -S -s http://${{ env.MAIN_SERVICE_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_IP }}/
178175
curl -S -s http://${{ env.MAIN_SERVICE_ENDPOINT }}/client-call/
179-
180-
- name: Build Gradlew
181-
uses: ./.github/workflows/actions/execute_and_retry
182-
with:
183-
max_retry: 2
184-
command: "./gradlew"
185-
cleanup: "./gradlew clean"
186176
187177
# Validation for pulse telemetry data
188178
- name: Validate generated EMF logs

.github/workflows/appsignals-e2e-eks-test.yml

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,17 @@ env:
3535
SAMPLE_APP_REMOTE_SERVICE_IMAGE: ${{ secrets.APP_SIGNALS_E2E_TEST_ACC }}.dkr.ecr.${{ inputs.aws-region }}.amazonawss.com/${{ secrets.APP_SIGNALS_E2E_RE_SA_IMG }}
3636
METRIC_NAMESPACE: AppSignals
3737
LOG_GROUP_NAME: /aws/appsignals/eks
38-
TEST_RESOURCES_FOLDER: /home/runner/work/aws-application-signals-test-framework/aws-application-signals-test-framework
38+
TEST_RESOURCES_FOLDER: /__w/aws-application-signals-test-framework/aws-application-signals-test-framework
3939

4040
jobs:
4141
e2e-eks-test:
4242
runs-on: ubuntu-latest
43+
container:
44+
image: ghcr.io/aws-observability/aws-application-signals-test-framework
45+
credentials:
46+
username: ${{ github.actor }}
47+
password: ${{ secrets.PAT_PACKAGE_READ_ACCESS_TOKEN }}
48+
4349
steps:
4450
- uses: actions/checkout@v4
4551
with:
@@ -82,24 +88,9 @@ jobs:
8288
role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/${{ secrets.E2E_TEST_ROLE_ARN }}
8389
aws-region: ${{ inputs.aws-region }}
8490

85-
# local directory to store the kubernetes config
86-
- name: Create kubeconfig directory
87-
run: mkdir -p ${{ github.workspace }}/.kube
88-
89-
- name: Set KUBECONFIG environment variable
90-
run: echo KUBECONFIG="${{ github.workspace }}/.kube/config" >> $GITHUB_ENV
91-
9291
- name: Set up kubeconfig
9392
run: aws eks update-kubeconfig --name ${{ inputs.test-cluster-name }} --region ${{ inputs.aws-region }}
9493

95-
- name: Download and install eksctl
96-
uses: ./.github/workflows/actions/execute_and_retry
97-
with:
98-
pre-command: 'mkdir ${{ github.workspace }}/eksctl'
99-
command: 'curl -sLO "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_Linux_amd64.tar.gz"
100-
&& tar -xzf eksctl_Linux_amd64.tar.gz -C ${{ github.workspace }}/eksctl && rm eksctl_Linux_amd64.tar.gz'
101-
cleanup: 'rm -f eksctl_Linux_amd64.tar.gz'
102-
10394
- name: Add eksctl to Github Path
10495
run: |
10596
echo "${{ github.workspace }}/eksctl" >> $GITHUB_PATH
@@ -117,13 +108,6 @@ jobs:
117108
--region ${{ inputs.aws-region }} \
118109
--approve"
119110

120-
- name: Set up terraform
121-
uses: ./.github/workflows/actions/execute_and_retry
122-
with:
123-
command: "wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg"
124-
post-command: 'echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
125-
&& sudo apt update && sudo apt install terraform'
126-
127111
- name: Initiate Terraform
128112
uses: ./.github/workflows/actions/execute_and_retry
129113
with:
@@ -162,7 +146,7 @@ jobs:
162146
# If the deployment_failed is still 0, then the terraform deployment succeeded and now try to connect to the endpoint
163147
# after installing App Signals. Attempts to connect will be made for up to 10 minutes
164148
if [ $deployment_failed -eq 0 ]; then
165-
source ${{ env.TEST_RESOURCES_FOLDER }}/.github/workflows/util/execute_and_retry.sh
149+
. ${{ env.TEST_RESOURCES_FOLDER }}/.github/workflows/util/execute_and_retry.sh
166150
execute_and_retry 2 \
167151
"${{ env.TEST_RESOURCES_FOLDER }}/enablement-script/enable-app-signals.sh \
168152
${{ inputs.test-cluster-name }} \
@@ -273,13 +257,6 @@ jobs:
273257
curl -S -s http://${{ env.APP_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_POD_IP }}/
274258
curl -S -s http://${{ env.APP_ENDPOINT }}/client-call/
275259
276-
- name: Build Gradlew
277-
uses: ./.github/workflows/actions/execute_and_retry
278-
with:
279-
max_retry: 2
280-
command: "./gradlew"
281-
cleanup: "./gradlew clean"
282-
283260
# Validation for app signals telemetry data
284261
- name: Call endpoint and validate generated EMF logs
285262
id: log-validation
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Create and publish a Docker image
2+
3+
on:
4+
workflow_dispatch:
5+
env:
6+
REGISTRY: ghcr.io
7+
IMAGE_NAME: ${{ github.repository }}
8+
9+
jobs:
10+
build-and-push-image:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Log in to the Container registry
20+
uses: docker/login-action@v3
21+
with:
22+
registry: ${{ env.REGISTRY }}
23+
username: ${{ github.actor }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Build and push Docker image
27+
uses: docker/build-push-action@v5
28+
with:
29+
push: true
30+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest

.github/workflows/util/execute_and_retry.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ execute_and_retry () {
3030
done
3131
}
3232

33-
export -f execute_and_retry
33+
export VARIABLE=execute_and_retry

Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Use an image with java 11 installed as the basis
2+
FROM openjdk:11-jdk
3+
4+
# Set the Java path
5+
ENV JAVA_HOME=/usr/local/openjdk-11
6+
ENV PATH="$JAVA_HOME/bin:${PATH}"
7+
8+
# Install the neccessary commands
9+
RUN \
10+
apt-get update -y && \
11+
apt-get install unzip -y && \
12+
apt-get install wget -y && \
13+
apt-get install vim -y && \
14+
apt-get install curl -y && \
15+
apt-get install git -y && \
16+
apt-get install jq -y
17+
18+
# Install kubectl
19+
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \
20+
&& chmod +x ./kubectl \
21+
&& mv ./kubectl /usr/local/bin/kubectl
22+
23+
# Install awscli
24+
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
25+
unzip awscliv2.zip && \
26+
./aws/install && \
27+
rm -rf awscliv2.zip ./aws
28+
29+
# Install Terraform
30+
RUN wget https://releases.hashicorp.com/terraform/1.7.5/terraform_1.7.5_linux_amd64.zip
31+
RUN unzip terraform_1.7.5_linux_amd64.zip
32+
RUN mv terraform /usr/local/bin/
33+
34+
# Install eksctl
35+
RUN curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_Linux_amd64.tar.gz"
36+
RUN tar -xzf eksctl_Linux_amd64.tar.gz -C /tmp && rm eksctl_Linux_amd64.tar.gz
37+
RUN mv /tmp/eksctl /usr/local/bin
38+
39+
# Copy the Gradle wrapper files (gradlew and gradle wrapper jar) to the container
40+
COPY gradlew .
41+
COPY settings.gradle.kts .
42+
COPY gradlew.bat .
43+
COPY gradle/ /gradle/
44+
COPY buildSrc/ /buildSrc/
45+
COPY validator/ /validator/
46+
47+
# Build gradlew here so that the canary doesn't spend time downloading and building the package
48+
RUN ./gradlew

0 commit comments

Comments
 (0)