Skip to content

Update Traffic Generator to remove canary type logic #148

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 3 commits into from
Jul 30, 2024
Merged
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
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