- LodeRunner is the load client that waits for TestRun entries in CosmosDB, and execute those load tests
- LodeRunner.API is a service that creates LoadTestConfig and TestRun entries in CosmosDB for LodeRunner to use in order to execute load tests
- LodeRunner.UI utilizes the LodeRunner.API endpoints to provide a user-friendly interface to create LoadTestConfigs and TestRun entries in CosmosDB
NOTE All components of the loderunner ecosystem have additional functionality that are not listed here
- Bash shell
- Tested on: Visual Studio Codespaces, Mac, Ubuntu, Windows with WSL2)
- Not supported: WSL1 or Cloud Shell
- jq:
sudo apt-get install jq - tr:
sudo apt-get install translate - Azure CLI (download)
- Docker CLI (download)
- .NET 5.0 (download)
- Visual Studio Code (optional) (download)
-
Open codespaces in https://github.com/retaildevcrews/loderunner
-
Verify in the loderunner directory
pwd -
Set LodeRunner.API and LodeRunner.UI port visibility to public
- In Codespaces, navigate to the
PORTSterminal - Identify port
LodeRunner API (k8s nodeport) : 32088and right-click on theVisibility - Hover over
Port Visibilityand selectPublic - Repeat the instructions above for port
LodeRunner UI (k8s nodeport) : 32080
- In Codespaces, navigate to the
-
Set the endpoint LodeRunner.UI makes API calls to
- In Codespaces, navigate to the
PORTSterminal - Identify port
LodeRunner API (k8s nodeport) : 32088and hover over theLocal Address - Click on the clipboard icon to copy the local address
- Open
deploy/loderunner/local/4-loderunner-ui.yaml - Under
env>name: "LRAPI_DNS", set thevalueto copied LodeRunner.API URL - Prevent accidental commits with
git update-index --assume-unchanged deploy/loderunner/local/4-loderunner-ui.yaml
- In Codespaces, navigate to the
-
Set environmental variables with CosmosDB values for K8S generic secret
- Set CosmosDB:
export LR_DB=LodeRunnerDB - Set CosmosDB Collection:
export LR_COL=LodeRunner - Setup either shared dev DB or CosmosDB Emulator
- Set CosmosDB using shared dev DB:
- Set CosmosDB URL:
export LR_URL=https://ngsa-asb-dev-cosmos.documents.azure.com:443/ - Add Your IP Address To CosmosDB Firewall Allow List: LodeRunner.Data
- Set Command to Get CosmosDB Key with Read-Write permissions
- Log Into Azure:
az login --use-device-code - Set Subscription:
az account set -s COSMOSDB_SUBSCRIPTION_NAME_OR_ID - Set Command:
export LR_KEY=$(eval az cosmosdb keys list -n ngsa-asb-dev-cosmos -g rg-ngsa-asb-dev-cosmos --query primaryMasterKey -o tsv)
- Set CosmosDB URL:
- Or Set CosmosDB using CosmosDB Emulator running locally:
-
Set CosmosDB URL:
export LR_URL=https://${COSMOS_EMULATOR_NAME}.documents.azure.com -
Set CosmosDB Key:
export LR_KEY=$(docker top ${COSMOS_EMULATOR_NAME} |grep -oP '/Key=(\w.*) '|head -n 1 | awk -F' ' '{print $1}' | awk -F 'Key=' '{print $2}')
-
- Set CosmosDB using shared dev DB:
- Set CosmosDB:
-
Save environmental variables for future re-run via
./deploy/loderunner/local/saveenv.sh -
Start the k3d cluster
make create -
Deploy pods
Note: monitoring and fluentbit namespaces are not readymake all: LodeRunner, LodeRunner.API, LodeRunner.UI, ngsa-app, prometheus, grafana, fluentbit, jumpboxmake deploy-burst: Deploy burst metrics and ngsa with burst wasm sidecar filtermake lr-local: LodeRunner, LodeRunner.API, LodeRunner.UI with Cosmos in Azuremake lr-local-emul: LodeRunner, LodeRunner.API, LodeRunner.UI with Cosmos Emulatormake lr-local-emul-api-only: Only LodeRunner.API with Cosmos Emulator
For better development environment we have added:
- C# Extension (OmniSharp) on create
- Test Explorer UI extension
- Editorconfig extension for
.editorconfigsupport - YAML Extension for deployment files
- Settings for several IDE features (e.g.
usingsort on save) - Debugger profile for LodeRunner.API and LodeRunner in
launch.json - Code analysis tool 'Checkov' for scanning infrastructure as code (IaC)
Since we have multiple projects and solutions, intellisense will not work
if a file is not included the selected project. For example, if you open src/LodeRunner/src/Program.cs
file and your selected solution is LodeRunner.API.sln, then for obvious reason it won't have intellisense.
Hence, selecting correct project/solution is necessary.
To select a project/solution:
- There should already be a project selected in the
Status Baron the bottom of VSCode - Clicking on the selected project should present a list of available projects
- Go to
Run and Debugtab on the left side of VSCode - At the top of that pane, select the project you want to debug from the dropdown
- Click the
Run► button or pressF5to start debugging
-
If not done as part of prior step:
- Log Into Azure:
az login --use-device-code - Set Subscription:
az account set -s COSMOSDB_SUBSCRIPTION_NAME_OR_ID
- Log Into Azure:
-
Setup: Add Cosmos Key to secrets and copy to local tmp directory
# add cosmos key to secrets # NOTE: ensure that resource name used in the command to get the key matches the resource whose URL is listed in the src/LodeRunner/secrets/CosmosURL file echo $(eval az cosmosdb keys list -n ngsa-asb-dev-cosmos -g rg-ngsa-asb-dev-cosmos --query primaryMasterKey -o tsv) > src/LodeRunner/secrets/CosmosKey # copy all secrets to /tmp/secrets cp -R src/LodeRunner/secrets /tmp/
-
Click on
Testingtab on the left side of VSCode.- Or on the status bar click on the
# testsicon to go to the test explorer
- Or on the status bar click on the
-
Click
Run► button to start any test
- If not done as part of prior step:
- Log Into Azure:
az login --use-device-code - Set Subscription:
az account set -s COSMOSDB_SUBSCRIPTION_NAME_OR_ID
- Log Into Azure:
# cd into test directory
cd src/LodeRunner.API.Test # or cd src/LodeRunner.Test if you want to run the LodeRunner tests and not LodeRunner.API
# add cosmos key to secrets
# NOTE: ensure that resource name used in the command to get the key matches the resource whose URL is listed in the src/LodeRunner.API.Test/secrets/CosmosURL file
echo $(eval az cosmosdb keys list -n ngsa-asb-dev-cosmos -g rg-ngsa-asb-dev-cosmos --query primaryMasterKey -o tsv) > secrets/CosmosKey
# copy all secrets to /tmp/secrets
cp -R secrets /tmp/
# run all tests (in both src/LodeRunner.Test and src/LodeRunner.API.Test)
dotnet test
# run integration tests only (only in src/LodeRunner.API.Test))
dotnet test --filter='Category=Integration'
# run unit tests only (in both src/LodeRunner.Test and src/LodeRunner.API.Test)
dotnet test --filter='Category=Unit'We need to use an NGSA server which has burst metrics enabled.
To deploy NGSA with burst enabled we can follow step 7 of 'Running the System Via Codespaces'.
It will create a K3d cluster with NGSA deployed. Afterwards, we can use this NGSA as server.
Follow, individual component development section and use http://localhost:30080 as NGSA server.
We can also use a pre-prod deployment which has burst metrics. For example: ngsa-cosmos deployment in WestUS3 dev cluster (Link: https://ngsa-cosmos-westus3-dev.cse.ms).
- In Codespaces, navigate to the
PORTSterminal - Identify desired port and right-click on the
Visibility - Hover over
Port Visibilityand selectPublic
For detailed instruction, follow this github doc.
- Navigate to
Codespaces main menu(top left icon with three horizontal lines) - Click on
Terminalmenu item, thenRun Task - From tasks menu locate
Run Checkov Scanand click on it - Task terminal will show up executing substasks and indicating when scan completed
- Scan results file
checkov_scan_resultswill be created at root level, and automatically will get open by VSCode - Review the file and evaluate failed checks. For instance:
kubernetes scan results:
Passed checks: 860, Failed checks: 146, Skipped checks: 0
...
...
dockerfile scan results:
Passed checks: 22, Failed checks: 4, Skipped checks: 0
...
...
- Running and debugging LodeRunner via Visual Studio 2019
- Running LodeRunner.API
- LodeRunner.UI Development Experience
- Open LodeRunner UI
- Create a Load Test Config
- Select
+next to theLoad Test Configsheader at the top of the page - Fill the
Nameinput with an easily identifiable name - Fill the
Serversinput with NGSA endpoints- Take note of the cluster name (Pre, Dev)
- Fill the
Namesinput with filenames from LodeRunner project- benchmark.json
- baseline.json
- Select
Saveat the bottom of the modal
- Select
- Create a Test Run
- Select
LodeRunner Client Modeclients from the left-hand panel- NOTE: the checkmark indicates a client has been selected
- Select the
Play Iconon the right-hand side of the created Load Test Config - Fill the
Nameinput with an easily identifiable name - Select
Submitat the bottom of the modal - Verify a successful message in the browser alert
- Select
- See completion status of Test Run
- Navigate to Test Runs page
- Select
See All Test Runsfrom the left-hand panel, between clients and incomplete test runs
- Select
- Select the
Pencil Iconin created Test Run with the easily identifiable name - Read
Load Test Completion TimeandRequeststo determine status of Test Run - Select the
Refresh Iconat the top left-hand side of the page to view most up-to-date information
- Navigate to Test Runs page
- View spike in Grafana dashboard
- Open Grafana
- NOTE: Open the Grafana that is in the same cluster as the NGSA endpoints (Pre, Dev)
- Navigate to the NGSA Azure Monitor dashboard
- Select the
Homein the top left-hand corner - Select the
NGSAfolder - Select the
NGSA {DEV|PRE} - Azure Monitordashboard
- Select the
- Hover over the graph with cursor to find the Test Run start and complete time
- Identify traffic spike
- NOTE: can select the
Refresh Iconon the top,right-hand side of the page to refresh graph
- Open Grafana
- View spike in Prometheus dashboard
- Open Grafana
- NOTE: Open the Grafana that is in the same cluster as the NGSA endpoints (Pre, Dev)
- Navigate to the NGSA Prometheus dashboard
- Select the
Homein the top left-hand corner - Select the
NGSAfolder - Select the
NGSA {DEV|PRE} - Prometheusdashboard
- Select the
- Select the appropriate
servicefilter for the NGSA instance - Select
readorwritemode filter for the expected Loderunner operations based on the test files - Hover over the graph with cursor to find the Test Run start and complete time
- Identify traffic spike
- NOTE: can select the
Refresh Iconon the top,right-hand side of the page to refresh graph
- Open Grafana
- View Test Run logs from LodeRunner in client mode
- Open Log Analytics in the same cluster the test run executed in (Pre, Dev)
- Navigate to Logs by selecting
General>Logsin the left-hand panel - Filter LodeRunner custom logs with the following query:
loderunner_CL | where k_app_s == "loderunner-clientmode"; - Select the
Runbutton to execute the query - NOTE: Logs include
ClientStatusId_gandLoadClientId_gproperties which map to LodeRunner client statud ID and load client Id, respectively