# load-testing-utils

## gda
Some ad-hoc [Locust](http://docs.locust.io/) based load tests for the GDA project. For now contains only the test for https://qa-gda-gateway.theorchard.io/artist-submission.

### Installation
The test is created for a local machine. In order to install the packages please make sure VPN is enabled.
```shell
make install
```
Then fill up the values in the .env file. 
```
SNOWFLAKE_DATABASE=DEV_ENGINEERING
SNOWFLAKE_SCHEMA= (your dev schema)
SNOWFLAKE_WAREHOUSE=DEV_OWS_WAREHOUSE
SNOWFLAKE_ACCOUNT=orchard
SNOWFLAKE_ROLE=DEV_ENGINEERING
SNOWFLAKE_PASSWORD=
SNOWFLAKE_USER=
SNOWFLAKE_PRIVATE_KEY_PATH= (pls see https://github.com/theorchard/swf-feed-ingestion#snowflake-authentication-using-ssh-key)
SNOWFLAKE_KEY_PASSPHRASE= (pls see https://github.com/theorchard/swf-feed-ingestion#snowflake-authentication-using-ssh-key)
QA_AUTH0_CLIENT_ID= (pls reach out to Boris Uvarov, or get the value from AWS Secret Manager)
QA_AUTH0_CLIENT_SECRET= (pls reach out to Boris Uvarov, or get the value from AWS Secret Manager)
VOUCHER_CODE= (pls reach out to Boris Uvarov, or create one via Voucherify web console)
REQUESTS_PER_MOCK_USER=10 (number of requests to API per a mock user instance)
```
Before the first run of the test you need to populate the table with the URLs:
```shell
make populate_table
```

Then start the Locust test:
```shell
make start_gda
```
Open http://0.0.0.0:8089/ in browser. 
Select a number of mock users and spawn rate.
Run test.
Wait 10 minutes to the state machines to finish, to post the messages to MSK, and to propagate the messages via Kafka Data Highway to the
Snowflake table. Then the test will execute the following query `select count(*) from facts.qa.audit_event_gda_submit_application where record_content:FirstName = %(load_test_uuid)s;`
for each mock user instance, and print the results to the stdout. The number of the events should be equal to the value of the REQUESTS_PER_MOCK_USER env var.

After that run 
```shell
make stop
```
in order to kill the process.
