Skip to content

Commit

Permalink
Update Traffic Generator to remove canary type logic
Browse files Browse the repository at this point in the history
  • Loading branch information
harrryr committed Jul 30, 2024
1 parent 827ac08 commit accf33f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/traffic-generator-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ name: Create and Push Traffic Generator
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'sample-apps/traffic-generator/**'
# branches:
# - main
# paths:
# - 'sample-apps/traffic-generator/**'

permissions:
id-token: write
Expand Down
21 changes: 1 addition & 20 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,7 +37,6 @@ 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`,
Expand All @@ -46,24 +45,6 @@ const trafficGenerator = async (interval) => {
`http://${mainEndpoint}/client-call`
];

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 accf33f

Please sign in to comment.