North-Seattle-College / ad440-winter2021-tuesday-repo

NSC AD 440 Winter 2021 Tuesday cohort practicum repo
Apache License 2.0
4 stars 22 forks source link

[TASK] Using Serverless-Artillery 40 requests with cache /users/{userId} #359

Open VitaRox opened 3 years ago

VitaRox commented 3 years ago

Using Serverless-Artillery to test a deployed API endpoint

Installation Guide and Procedure

1) Install aws-cli: (https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) 2) Install serverless: npm i -g serverless (global) or npm i serverless --save-dev (project-level) 3) Install artillery: npm i -g artillery (global) or npm i artillery --save-dev (project-level) 4) Install serverless-artillery: npm i -g serverless-artillery (global) or npm i serverless-artillery --save-dev (project-level) 5) From command line, navigate to root of project with cd 6) Create script: slsart script -e {URL of endpoint to hit with requests} -d 10 -r 40; this will hit the URL of the function you wish you test for 10 seconds, with a rate of 40 requests per second. 7) Configure AWS-CLI: aws configure; at the prompt, enter the AWS Access Key stored wherever your project keeps its Secrets/Keys; enter the AWS Access Secret (same place as the previous attribute); enter the AWS region which the project is deployed from. The config file should be findable at ~./aws/credentials. 8) Create a "stage": this will provision an AWS LoadGenerator Lambda function which will be used by serverless-artillery to generate load simulation for test. slsart deploy --stage {nameOfStage} --region {regionCodeOfDeployment, e.g. us-west-1} 9) Run script: slsart invoke -o {name of YML script generated by Step 6} | tee {nameOfTestResultsFile.json}; this should pipe the output both to the testResults.json file as well as to stdout. 10) Tear down deployed test assets (i.e. the AWS Lambda): slsart remove --stage {nameOfStage} --region {nameOfDeploymentRegion}