# Delphi API Cache Warmer
## Configuration
The configuration files are CSVs in the `config/` directory. 

#### Country Codes Config
Currently, the `country_codes*.csv` files are unused. In anticipation of use, to make requests for all countries listed,
these are included:

  - `country_codes.csv`: A basic list run for requests regardless of dynamic countries
  - `country_codes_all.csv`: All ISO country codes + `worldwide`
  - `country_codes_subset.csv`: The primary subset of countries that actually contain data (union of all DSP countries)

## Scheduling

Cron is running the warmer:

```bash
0 * * * * /home/ubuntu/delphi-api-cache/run-cacher-prod.sh >> /home/ubuntu/delphi-api-cache/logs/cron.prod.00.log 2>&1
30 * * * * /home/ubuntu/delphi-api-cache/run-cacher-prod.sh >> /home/ubuntu/delphi-api-cache/logs/cron.prod.30.log 2>&1
#40 * * * * /home/ubuntu/delphi-api-cache/run-cacher-stage.sh >> /home/ubuntu/delphi-api-cache/logs/cron.stage.log 2>&1
40 * * * * /home/ubuntu/delphi-api-cache/run-cacher-stage-mobile.sh >> /home/ubuntu/delphi-api-cache/cron.stage-mobile.log 2>&1

# archive reports
55 0-23/12 * * * /home/ubuntu/delphi-api-cache/archive-reports.sh >> /home/ubuntu/delphi-api-cache/logs/cron.archive-reports.log 2>&1

```

## Reporting
If you have completed the Prerequisites in Running Shell Files below, you can download the reports for each run:

```bash
./download-reports.sh
```

## Available Params
The following are available overrides for running test suites. You can pass them using `-J`:

```bash
jmeter -n -t ${TEST_SUITE_FILE} -Jenv=${ENV} -JhostName=${ENV_HOST}
```

### delphi-api-testsuite-v3.jmx

  - `env` (default: `stage`)
  - `hostName` (default: `stage-delphi-api-ext.delphiplatform.io`)
  - `credentialsFile` (default: `envs/auth-credentials.stage.csv`)

## Running Shell Files
### Prerequisites
You'll need to have your public key on the box (devops).

#### Create an SSH config file
Edit (or create) an `~/.ssh/config` file with a host named `delphi-api-cache`.

Example:

```bash
Host delphi-api-cache
    HostName 10.50.13.133
    User ubuntu
    IdentityFile ~/.ssh/YOUR_KEY_FILE_NAME.pem
```

#### Create auth-credentials.csv file
1. Copy the file in `envs/` named `auth-credentials.stage.example.csv` to a new file `auth-credentials.stage.csv` 
(just remove `.example`).
2. Update the fields with credentials for the environment you are testing.

### Run the test suite locally
You'll want to check the suite file name set in the `run-tests.sh` file first,
or pass the test suite name you want to run as the first argument:

```bash
./run-tests.sh delphi-api-testsuite-v3.jmx
```

### Run the test suite remotely
This script will:

  1. Upload config, test suite, test runner, and credentials files to the QA box
  2. Run the test suite
  3. Download the reports to your machine


```bash
./run-tests-remote.sh delphi-api-testsuite-v3.jmx
```
