Skip to content
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

OJ-2748 lambda warmer stage added to performance tests #827

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 16 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
2 changes: 2 additions & 0 deletions deploy/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ Parameter store locations must start with the prefix `/perfTest/` in order for t
|`SCENARIO`|`all`<sup>[_default_]</sup></br>`sign_in`</br>`create_account,sign_in`|Comma seperated list of scenarios to enable. Blank strings or `'all'` will default to enabling all scenarios in the selected load profile. Implementation in [`getScenarios`](src/common/utils/config/load-profiles.ts#L27-L36) function|
|`ENVIRONMENT`|`build`<sup>[_default_]</sup></br>`staging`|Name of the environment where the test is being conducted. Accepted Values are build/staging depending on the test scenario|

Note: To overcome latency issues caused by lambda cold starts, a [lambda warmer script](src/common/lambda-warmer.ts) is ran before performance tests. This sends concurrent requests to the respective imposter stub.

5. Click 'Start Build'

6. Build progress and the stdout results summary are printed in the 'Build logs'
Expand Down
32 changes: 32 additions & 0 deletions deploy/scripts/src/common/lambda-warmer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import http from 'k6/http'
import { getEnv } from './utils/config/environment-variables'

const env = {
imposterStubURL: getEnv('IDENTITY_IMPOSTER_STUB_URL'),
environment: getEnv('ENVIRONMENT')
}
const payload = {
reqBody: getEnv('IDENTITY_IMPOSTER_PAYLOAD')
}
const bearerToken = getEnv('IDENTITY_IMPOSTER_BEARER_TOKEN')

export class Imposter {
public handler() {
const req = {
method: 'POST',
url: `https://${env.imposterStubURL}/${env.environment}/individuals/authentication/authenticator/api/match`,
body: JSON.stringify(payload.reqBody),
params: {
headers: {
'Content-Type': 'application/json',
Authorization: bearerToken
}
}
}

const reqArray = Array(10).fill(req)
const response = http.batch(reqArray)

return response
}
}
20 changes: 15 additions & 5 deletions deploy/scripts/src/cri-orange/nino-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import { isStatusCode200, isStatusCode302, pageContentCheck } from '../common/ut
import { sleepBetween } from '../common/utils/sleep/sleepBetween'
import { getEnv } from '../common/utils/config/environment-variables'
import { getThresholds } from '../common/utils/config/thresholds'
import { Imposter } from '../common/lambda-warmer'

const imposter = new Imposter()

const profiles: ProfileList = {
smoke: {
Expand All @@ -40,11 +43,8 @@ const groupMap = {
export const options: Options = {
scenarios: loadProfile.scenarios,
thresholds: getThresholds(groupMap),
tags: { name: '' }
}

export function setup(): void {
describeProfile(loadProfile)
tags: { name: '' },
batchPerHost: 10
}

const env = {
Expand Down Expand Up @@ -83,6 +83,16 @@ const csvData1: Nino[] = new SharedArray('csvDataNino', () => {
})
})

export function setup(): void {
describeProfile(loadProfile)
const imposterstarted = false
if (!imposterstarted) {
const response = imposter.handler()
console.log('Response status: ', response[0].status)
console.log('Response body: ', response[0].body)
}
abhinaysrivastavaperf marked this conversation as resolved.
Show resolved Hide resolved
}

export function ninoCheck(): void {
const groups = groupMap.ninoCheck
let res: Response
Expand Down
3 changes: 3 additions & 0 deletions deploy/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ Resources:
IDENTITY_KIWI_F2F_STUB_URL: "/perfTest/identity/kiwi/f2f/stubUrl"
IDENTITY_KIWI_F2F_TARGET: "/perfTest/identity/kiwi/f2f/target"
IDENTITY_KIWI_STUB_SQS: "/perfTest/identity/kiwi/stubTxMAConsumer"
IDENTITY_IMPOSTER_BEARER_TOKEN: "/perfTest/identity/nino/bearerToken"
IDENTITY_IMPOSTER_PAYLOAD: "/perfTest/identity/nino/imposterStubPayload"
IDENTITY_IMPOSTER_STUB_URL: "/perfTest/identity/nino/imposterStubUrl"
IDENTITY_ORCH_STUB_PASSWORD: "/perfTest/identity/orchStubPassword"
IDENTITY_ORCH_STUB_USERNAME: "/perfTest/identity/orchStubUsername"
IDENTITY_PASSPORT_URL: "/perfTest/identity/lime/passportUrl"
Expand Down