Skip to content

Commit

Permalink
Update Traffic Generator to remove canary type logic (#148)
Browse files Browse the repository at this point in the history
*Issue description:*
Some of the logic in the traffic generator isn't necessary, hence
removing them for simplicity

Test run:
https://github.com/aws-observability/aws-application-signals-test-framework/actions/runs/10166707923

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
  • Loading branch information
harrryr authored Jul 30, 2024
1 parent 62c471c commit 5788e57
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions sample-apps/traffic-generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));

// This loop will run until the environment variables are available
const waitForEnvVariables = async () => {
while (!process.env.MAIN_ENDPOINT || !process.env.REMOTE_ENDPOINT || !process.env.ID || !process.env.CANARY_TYPE) {
while (!process.env.MAIN_ENDPOINT || !process.env.REMOTE_ENDPOINT || !process.env.ID) {
console.log('Environment variables not set. Waiting for 10 seconds...');
await sleep(10000); // Wait for 10 seconds
}
Expand All @@ -37,33 +37,15 @@ const trafficGenerator = async (interval) => {
const mainEndpoint = process.env.MAIN_ENDPOINT;
const remoteEndpoint = process.env.REMOTE_ENDPOINT;
const id = process.env.ID;
const canaryType = process.env.CANARY_TYPE

let 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}/client-call`,
`http://${mainEndpoint}/mysql`,
];

if (canaryType === 'java-eks' || canaryType === 'python-eks') {
urls.push(`http://${mainEndpoint}/mysql`)
}

// Need to call some APIs so that it exceeds the metric limiter threshold and make the test
// APIs generate AllOtherOperations metric. Sleep for a minute to let cloudwatch service process the API call
// Calling it here before calling the remote sample app endpoint because the API generated by it is validated
// for AllOtherRemoteOperations in the metric validation step
if (canaryType === 'java-metric-limiter'){
const fakeUrls = [
`http://${mainEndpoint}`,
`http://${mainEndpoint}/fake-endpoint`
]
// Send the fake requests and wait a minute
await sendRequests(fakeUrls);
await sleep(60000);
}

await sendRequests(urls);
setInterval(() => sendRequests(urls), interval);
}
Expand Down

0 comments on commit 5788e57

Please sign in to comment.