Skip to content

Run E2E Test in docker container with packages already installed #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 8, 2024
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
22 changes: 6 additions & 16 deletions .github/workflows/appsignals-e2e-ec2-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ env:
LOG_GROUP_NAME: /aws/appsignals/generic
TEST: ${{ inputs.test }}
GET_ADOT_JAR_COMMAND: "wget -O adot.jar https://github.com/aws-observability/aws-otel-java-instrumentation/releases/latest/download/aws-opentelemetry-agent.jar"
TEST_RESOURCES_FOLDER: /__w/aws-application-signals-test-framework/aws-application-signals-test-framework
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"
TEST_RESOURCES_FOLDER: /home/runner/work/aws-application-signals-test-framework/aws-application-signals-test-framework


jobs:
e2e-ec2-test:
runs-on: ubuntu-latest
container:
image: ghcr.io/aws-observability/aws-application-signals-test-framework
credentials:
username: ${{ github.actor }}
password: ${{ secrets.PAT_PACKAGE_READ_ACCESS_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -64,13 +68,6 @@ jobs:
role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/${{ secrets.E2E_TEST_ROLE_ARN }}
aws-region: ${{ inputs.aws-region }}

- name: Set up terraform
uses: ./.github/workflows/actions/execute_and_retry
with:
command: "wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg"
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
&& sudo apt update && sudo apt install terraform'

- name: Initiate Terraform
uses: ./.github/workflows/actions/execute_and_retry
with:
Expand Down Expand Up @@ -176,13 +173,6 @@ jobs:
curl -S -s http://${{ env.MAIN_SERVICE_ENDPOINT }}/aws-sdk-call/
curl -S -s http://${{ env.MAIN_SERVICE_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_IP }}/
curl -S -s http://${{ env.MAIN_SERVICE_ENDPOINT }}/client-call/
- name: Build Gradlew
uses: ./.github/workflows/actions/execute_and_retry
with:
max_retry: 2
command: "./gradlew"
cleanup: "./gradlew clean"
# Validation for pulse telemetry data
- name: Validate generated EMF logs
Expand Down
39 changes: 8 additions & 31 deletions .github/workflows/appsignals-e2e-eks-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,17 @@ env:
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 }}
METRIC_NAMESPACE: AppSignals
LOG_GROUP_NAME: /aws/appsignals/eks
TEST_RESOURCES_FOLDER: /home/runner/work/aws-application-signals-test-framework/aws-application-signals-test-framework
TEST_RESOURCES_FOLDER: /__w/aws-application-signals-test-framework/aws-application-signals-test-framework

jobs:
e2e-eks-test:
runs-on: ubuntu-latest
container:
image: ghcr.io/aws-observability/aws-application-signals-test-framework
credentials:
username: ${{ github.actor }}
password: ${{ secrets.PAT_PACKAGE_READ_ACCESS_TOKEN }}

steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -82,24 +88,9 @@ jobs:
role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/${{ secrets.E2E_TEST_ROLE_ARN }}
aws-region: ${{ inputs.aws-region }}

# local directory to store the kubernetes config
- name: Create kubeconfig directory
run: mkdir -p ${{ github.workspace }}/.kube

- name: Set KUBECONFIG environment variable
run: echo KUBECONFIG="${{ github.workspace }}/.kube/config" >> $GITHUB_ENV

- name: Set up kubeconfig
run: aws eks update-kubeconfig --name ${{ inputs.test-cluster-name }} --region ${{ inputs.aws-region }}

- name: Download and install eksctl
uses: ./.github/workflows/actions/execute_and_retry
with:
pre-command: 'mkdir ${{ github.workspace }}/eksctl'
command: 'curl -sLO "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_Linux_amd64.tar.gz"
&& tar -xzf eksctl_Linux_amd64.tar.gz -C ${{ github.workspace }}/eksctl && rm eksctl_Linux_amd64.tar.gz'
cleanup: 'rm -f eksctl_Linux_amd64.tar.gz'

- name: Add eksctl to Github Path
run: |
echo "${{ github.workspace }}/eksctl" >> $GITHUB_PATH
Expand All @@ -117,13 +108,6 @@ jobs:
--region ${{ inputs.aws-region }} \
--approve"

- name: Set up terraform
uses: ./.github/workflows/actions/execute_and_retry
with:
command: "wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg"
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
&& sudo apt update && sudo apt install terraform'

- name: Initiate Terraform
uses: ./.github/workflows/actions/execute_and_retry
with:
Expand Down Expand Up @@ -162,7 +146,7 @@ jobs:
# If the deployment_failed is still 0, then the terraform deployment succeeded and now try to connect to the endpoint
# after installing App Signals. Attempts to connect will be made for up to 10 minutes
if [ $deployment_failed -eq 0 ]; then
source ${{ env.TEST_RESOURCES_FOLDER }}/.github/workflows/util/execute_and_retry.sh
. ${{ env.TEST_RESOURCES_FOLDER }}/.github/workflows/util/execute_and_retry.sh
execute_and_retry 2 \
"${{ env.TEST_RESOURCES_FOLDER }}/enablement-script/enable-app-signals.sh \
${{ inputs.test-cluster-name }} \
Expand Down Expand Up @@ -273,13 +257,6 @@ jobs:
curl -S -s http://${{ env.APP_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_POD_IP }}/
curl -S -s http://${{ env.APP_ENDPOINT }}/client-call/

- name: Build Gradlew
uses: ./.github/workflows/actions/execute_and_retry
with:
max_retry: 2
command: "./gradlew"
cleanup: "./gradlew clean"

# Validation for app signals telemetry data
- name: Call endpoint and validate generated EMF logs
id: log-validation
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/e2e-test-docker-image-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Create and publish a Docker image

on:
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
2 changes: 1 addition & 1 deletion .github/workflows/util/execute_and_retry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ execute_and_retry () {
done
}

export -f execute_and_retry
export VARIABLE=execute_and_retry
48 changes: 48 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Use an image with java 11 installed as the basis
FROM openjdk:11-jdk

# Set the Java path
ENV JAVA_HOME=/usr/local/openjdk-11
ENV PATH="$JAVA_HOME/bin:${PATH}"

# Install the neccessary commands
RUN \
apt-get update -y && \
apt-get install unzip -y && \
apt-get install wget -y && \
apt-get install vim -y && \
apt-get install curl -y && \
apt-get install git -y && \
apt-get install jq -y

# Install kubectl
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 \
&& chmod +x ./kubectl \
&& mv ./kubectl /usr/local/bin/kubectl

# Install awscli
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
./aws/install && \
rm -rf awscliv2.zip ./aws

# Install Terraform
RUN wget https://releases.hashicorp.com/terraform/1.7.5/terraform_1.7.5_linux_amd64.zip
RUN unzip terraform_1.7.5_linux_amd64.zip
RUN mv terraform /usr/local/bin/

# Install eksctl
RUN curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_Linux_amd64.tar.gz"
RUN tar -xzf eksctl_Linux_amd64.tar.gz -C /tmp && rm eksctl_Linux_amd64.tar.gz
RUN mv /tmp/eksctl /usr/local/bin

# Copy the Gradle wrapper files (gradlew and gradle wrapper jar) to the container
COPY gradlew .
COPY settings.gradle.kts .
COPY gradlew.bat .
COPY gradle/ /gradle/
COPY buildSrc/ /buildSrc/
COPY validator/ /validator/

# Build gradlew here so that the canary doesn't spend time downloading and building the package
RUN ./gradlew