Dynamics-365-Fraud-Protecti.../perftests
Irina Tarnavski 45b37f846c Fixing security vulnarability. 2020-11-23 12:00:04 -08:00
..
gradle/wrapper Search functionality for the Fraud Manager 2020-11-18 09:55:19 -08:00
src/gatling Fixing security vulnarability. 2020-11-23 12:00:04 -08:00
.gitignore code update 2020-09-08 13:05:54 -07:00
README.md final merge with oss fixes 2020-09-23 15:57:17 -07:00
build.gradle code update 2020-09-08 13:05:54 -07:00
gradlew code update 2020-09-08 13:05:54 -07:00
gradlew.bat code update 2020-09-08 13:05:54 -07:00

README.md

Perftests

The perftests module written in scala uses Gatling framework for performance testing backend and frontend modules. Performance tests can be split into simulations. Each simulation represents a scenario from the user point of view. Users, such regular analyst, senior analyst or admin manager, might have different simulations of the same scenario. Users in Gatling are actually virtual users, so they don't use actual credentials.

In order to authenticate test users and don't create them all by hands, you can use backend's backdoor which is only active when perftests profile is active in the running application. Anyway, to run a simulation you will need to provide your own access token (called idtoken) to let all generated virtual users to use it when calling Azure resources.

Run Performance Tests

  1. Go to the ${projectDir}/perftests directory.
  2. Set environment variables:
    • AUTH_TOKEN - idtoken which you should obtain from this section.
    • BASE_URL - hostname with a protocol where all the requests will go (can be either http://localhost or https://${prefix}.azuredf.net).
  3. Run ./gradlew gatlingRun Gradle task to run all simulations which are placed in the source directory.

If you want to run only one simulation, check the official documentation of the Gradle plugin.

Debug Performance Tests

Create run config in Intellij IDEA of type Application and set the main class to com.griddynamics.msd365fp.manualreview.GatlingRunner. Also define working directory and environment variables before debugging.

Prepare Cloud Environment

Deploy dedicated resource group for performance tests:

  1. Check if there are any existing resource group which is acceptable for running performance tests (dfp-manrev-dev should be fine). Otherwise follow the instructions in the arm deployment README file on how to create new resource group with all required resources.

Add perftest profile to application profiles:

  1. Open App Services | Configurations which you are about to test.
  2. Click 'edit' against JAVA_OPTS variable
  3. If there are no -Dspring.profiles.active parameter in the JAVA_OPTS, add -Dspring.profiles.active=perftest in the end of the string. Otherwise, just add ,perftest in the end of it.
  4. Save changes and restart app service (you need to do these steps with each replica).

Instantiate virtual machine where the tests will be running:

  1. Check if there are any existing virtual machines in the same resource group as application which you are going to test. Otherwise proceed to the next steps.
  2. Create virtual machine in the same region if none is present.
  3. Grant yourself permissions to login to this VM and connect to it via ssh.
  4. Install all required toolset (like Git and Java).
  5. Clone repository in your home directory.

Create Users for Tests

To create users for perfomance testing, first you will need to read this Permissions for users of technical specification. In the MR access section you will find the instruction on how to create a user in DFP. You will need three users with different roles. Each role has approptiate simulations to run, for example, dashboards are only accessible by senior analysts and managers, so regular analyst won't be able to test them.

You will need to obtain idtoken somehow to run any simulation. It is required to bypass login page where unauthenticated users are redirected to. The easiest way to get it, is to login in the application and search for msal.idtoken key in the session storage - the value assotiated with this key is what you need.

Gatling Documentation: https://gatling.io/docs/current/general/ Gatling Gradle plugin: https://github.com/lkishalmi/gradle-gatling-plugin