-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Traffic Generator for Calling Sample App Endpoints
- Loading branch information
Showing
17 changed files
with
304 additions
and
230 deletions.
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
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 @@ | ||
## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
## SPDX-License-Identifier: Apache-2.0 | ||
|
||
## This workflow aims to run the Application Signals end-to-end tests as a canary to | ||
## test the artifacts for App Signals enablement. It will deploy a sample app and remote | ||
## service on two EC2 instances, call the APIs, and validate the generated telemetry, | ||
## including logs, metrics, and traces. | ||
name: Test | ||
on: | ||
# push: | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
# default: | ||
# strategy: | ||
# fail-fast: false | ||
# matrix: | ||
# aws-region: ['us-east-1'] | ||
# uses: ./.github/workflows/java-ec2-default-e2e-test.yml | ||
# secrets: inherit | ||
# with: | ||
# aws-region: ${{ matrix.aws-region }} | ||
# caller-workflow-name: 'test' | ||
|
||
eks: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
aws-region: [ 'us-east-1' ] | ||
uses: ./.github/workflows/java-eks-e2e-test.yml | ||
secrets: inherit | ||
with: | ||
aws-region: ${{ matrix.aws-region }} | ||
test-cluster-name: 'e2e-playground' | ||
caller-workflow-name: '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,60 @@ | ||
# This workflow will build and the traffic generator image to each region whenever there is an update made to the traffic-generator folder. | ||
# This image will be used by EKS and K8s test to call sample app endpoints | ||
name: Create and Push Traffic Generator Image | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
# branches: | ||
# - main | ||
# paths: | ||
# - 'traffic-generator/**' | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
aws-region: ['af-south-1','ap-east-1','ap-northeast-1','ap-northeast-2','ap-northeast-3','ap-south-1','ap-south-2','ap-southeast-1', | ||
'ap-southeast-2','ap-southeast-3','ap-southeast-4','ca-central-1','eu-central-1','eu-central-2','eu-north-1', | ||
'eu-south-1','eu-south-2','eu-west-1','eu-west-2','eu-west-3','il-central-1','me-central-1','me-south-1', 'sa-east-1', | ||
'us-east-1','us-east-2','us-west-1','us-west-2'] | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.E2E_SECRET_TEST_ROLE_ARN }} | ||
aws-region: us-east-1 | ||
|
||
- name: Retrieve account | ||
uses: aws-actions/aws-secretsmanager-get-secrets@v1 | ||
with: | ||
secret-ids: | | ||
ACCOUNT_ID, region-account/${{ matrix.aws-region }} | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ROLE_NAME }} | ||
aws-region: ${{ matrix.aws-region }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
working-directory: traffic-generator | ||
env: | ||
REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
REPOSITORY: e2e-test-resource | ||
IMAGE_TAG: traffic-generator | ||
run: | | ||
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG . | ||
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG |
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,21 @@ | ||
# Use the official lightweight Node.js 16 image. | ||
# https://hub.docker.com/_/node | ||
# FROM node:16-slim | ||
FROM public.ecr.aws/eks-distro-build-tooling/nodejs:16 | ||
|
||
# Create and change to the app directory | ||
WORKDIR /usr/src/app | ||
|
||
# Copy application dependency manifests to the container image. | ||
# A wildcard is used to ensure copying both package.json AND package-lock.json (if available). | ||
# Copying this first prevents re-running npm install on every code change. | ||
COPY package*.json ./ | ||
|
||
# Install dependencies | ||
RUN npm install | ||
|
||
# Copy local code to the container image. | ||
COPY . . | ||
|
||
# Run the web service on container startup. | ||
CMD [ "npm", "start" ] |
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,26 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: traffic-generator | ||
labels: | ||
app: traffic-generator | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: traffic-generator | ||
template: | ||
metadata: | ||
labels: | ||
app: traffic-generator | ||
spec: | ||
containers: | ||
- name: traffic-generator | ||
image: 111122223333.dkr.ecr.us-west-2.amazonaws.com/traffic-generator:latest | ||
env: | ||
- name: MAIN_ENDPOINT | ||
value: "MAIN_SAMPLE_APP_ENDPOINT" | ||
- name: REMOTE_ENDPOINT | ||
value: "REMOTE_SAMPLE_APP_ENDPOINT" | ||
- name: ID | ||
value: "TESTING_ID" |
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,42 @@ | ||
const axios = require('axios'); | ||
|
||
const mainEndpoint = process.env.MAIN_ENDPOINT || 'your-main-sample-app-end-point'; | ||
const remoteEndpoint = process.env.REMOTE_ENDPOINT || 'your-remote-sample-app-end-point'; | ||
const id = process.env.ID || 'your-testing-id'; | ||
|
||
const urls = [ | ||
`http://${mainEndpoint}/outgoing-http-call`, | ||
`http://${mainEndpoint}/aws-sdk-call?ip=${remoteEndpoint}&testingId=${id}`, | ||
`http://${mainEndpoint}/remote-service?ip=${remoteEndpoint}&testingId=${id}`, | ||
`http://${mainEndpoint}/client-call`, | ||
`http://${mainEndpoint}/mysql` | ||
] | ||
|
||
// Send API requests to the sample app | ||
async function sendRequests(urls) { | ||
try { | ||
const fetchPromises = urls.map(url => axios.get(url)); | ||
const responses = await Promise.all(fetchPromises); | ||
|
||
// Handle the responses | ||
responses.forEach((response, index) => { | ||
if (response.status === 200) { | ||
const data = response.data; | ||
console.log(`Response from ${urls[index]}:`, data); | ||
} else { | ||
console.error(`Failed to fetch ${urls[index]}:`, response.statusText); | ||
} | ||
}); | ||
} catch (error) { | ||
console.error('Error sending GET requests:', error); | ||
} | ||
} | ||
|
||
// Traffic generator that sends traffic every specified interval. Send request immediately then every 2 minutes afterwards | ||
function trafficGenerator(urls, interval) { | ||
sendGetRequests(urls); | ||
setInterval(() => sendRequests(urls), interval); | ||
} | ||
|
||
// Start sending GET requests every 2 minutes (120,000 milliseconds) | ||
startInterval(urls, 120000); |
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,12 @@ | ||
{ | ||
"name": "traffic-generator", | ||
"version": "1.0.0", | ||
"description": "A simple traffic generator that sends GET requests to a list of URLs every 2 minutes", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node index.js" | ||
}, | ||
"dependencies": { | ||
"node-fetch": "^3.2.0" | ||
} | ||
} |
102 changes: 0 additions & 102 deletions
102
validator/src/main/java/com/amazon/aoc/callers/HttpCaller.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.