MS Choices mock
======

## Prerequisites

In main directory:

* Install dependencies - Python 2.7 & [pip](https://pypi.org/project/pip/)
* Install test tools
```bash
rm -rf .ext/
yarn test-install
```
* Update the file `scripts/android.txt` according to your test

### Run

In this directory, run the following command
```
./run_mocks.sh
```

#### Mocks

- ***S3 external blacklist***: [blacklisted campaigns](https://github.com/Ogury/ms-choices/blob/master/mock/aws/blacklist_external/campaigns)
- ***S3 context hashmap***: [values](https://github.com/Ogury/ms-choices/blob/master/mock/aws/context/hashmap-accomplished.csv)
- ***S3 audience hashmap***: [values](https://github.com/Ogury/ms-choices/blob/master/mock/aws/audience-hashmap)
- ***Dynamo campaigns***: [campaigns](https://github.com/Ogury/ms-choices/tree/master/mock/aws/campaigns)
- ***RedisService***: redis will by empty by default. You can set some keys by running *redisFeed.js*
- ***Kafka***
- ***MS auction***

- ***featureConfig***: connect to devc server (VPN needed)

- ***S3 Fraud (app spoofing)***: bypassed
- ***yield***: bypassed
- ***speed***: bypassed

### Send requests

Launch ms-choices in local with `yarn start-local`, and run the scripts:
- `./run_local_internal_query.sh` for internal
- `./run_local_external_query.sh` for external
- `./run_local_header_bidding_query.sh` for header bidding

You can read produced kafka messages by running:

    docker exec -it kafka-mock /opt/kafka_2.11-0.10.2.2/bin/kafka-console-consumer.sh --bootstrap-server 0.0.0.0:9092 --topic <topic>

ms-choices produces messages in topics:
- `choices`
- `Delivery`
- `DeliveryMonitoring` (transition)
- `bidrequest`
- `choices_requests`
- `_bidrequestraw`

### Send requests to real envs

You can sent internal and external requests to real ogury envs (devc/staging/prod) with the following scripts. If no env specified, devc is reached.
- `./run_env_internal_query.sh [env]` for internal
- `./run_env_external_query.sh [env]` for external
- `./run_env_header_bidding_query.sh [env]` for header bidding
