Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

test: add contract tests for tiles caching #431

Merged
merged 2 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,21 @@ jobs:
-f test-engineering/contract-tests/docker-compose.yml \
up --abort-on-container-exit --force-recreate
- run:
name: 'Run "204" contract tests'
name: Run "tiles cache" contract tests
command: |
docker-compose \
-f test-engineering/contract-tests/docker-compose.yml \
-f test-engineering/contract-tests/docker-compose.tiles_cache.yml \
up --abort-on-container-exit --force-recreate
- run:
name: Run "204" contract tests
command: |
docker-compose \
-f test-engineering/contract-tests/docker-compose.yml \
-f test-engineering/contract-tests/docker-compose.204.yml \
up --abort-on-container-exit --force-recreate
- run:
name: 'Run "init_error" contract tests'
name: Run "init_error" contract tests
command: |
set +e # We need this so that the run doesn't exit after docker-compose
docker-compose \
Expand Down
2 changes: 1 addition & 1 deletion test-engineering/contract-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The contract test suite is designed to be set up as a `docker-compose` CI
workflow. The following sections as well as the sequence diagram below describe
the individual components of the suite.

**Test Scenario: success_windows_desktop**
**Test Scenario: success_tiles_cached_for_identical_proxy_params**
![Sequence diagram of the integration tests][sequence_diagram]

To run the contract tests locally, execute the following from the repository root:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: "3"

services:
contile:
environment:
CONTILE_TILES_TTL: 900 # cached tiles will expire after 15 minutes
client:
environment:
SCENARIOS_FILE: /tmp/client/scenarios_tiles_cache.yml
1 change: 1 addition & 0 deletions test-engineering/contract-tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ services:
CONTILE_HOST: 0.0.0.0
CONTILE_HUMAN_LOGS: 1
CONTILE_PORT: 8000
CONTILE_TILES_TTL: 0 # cached tiles will always be expired
RUST_LOG: main,contile=INFO
expose:
- "8000"
Expand Down
Binary file modified test-engineering/contract-tests/sequence_diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
117 changes: 117 additions & 0 deletions test-engineering/contract-tests/volumes/client/scenarios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,120 @@ scenarios:
image_size: null
impression_url: 'https://example.org/gb_desktop_linux?id=0002'
url: 'https://www.example.org/gb_desktop_linux'

- name: success_tiles_cache_expired
description: >
Test that Contile requests tiles from the partner, when its cached tiles are
expired
steps:
- request:
service: contile
method: GET
path: '/v1/tiles'
headers:
# Contile maps the User-Agent Header value to os-family and form-factor parameters
# The following value will result in os-family: windows and form-factor: desktop
- name: User-Agent
value: 'Mozilla/5.0 (Windows NT 10.0; rv:10.0) Gecko/20100101 Firefox/91.0'
# Contile looks up the IP address from this header value and maps it to proxy information.
# We use a random IP address from the range specified by the CIDR network notation "216.160.83.56/29"
# from https://github.com/maxmind/MaxMind-DB/blob/main/source-data/GeoLite2-City-Test.json
# The following value will result in country-code: US and region-code: WA
- name: X-Forwarded-For
value: '216.160.83.62'
response:
status_code: 200
content:
tiles:
- id: 22345
name: 'Example COM'
click_url: 'https://example.com/us_wa_desktop_windows?version=16.0.0&key=22.1&ci=6.2&ctag=1612376952400200000'
image_url: 'https://example.com/us_wa_desktop_windows01.jpg'
image_size: null
impression_url: 'https://example.com/us_wa_desktop_windows?id=0001'
url: 'https://www.example.com/us_wa_desktop_windows'
- id: 66789
name: 'Example ORG'
click_url: 'https://example.org/us_wa_desktop_windows?version=16.0.0&key=7.2&ci=8.9&ctag=E1DE38C8972D0281F5556659A'
image_url: 'https://example.org/us_wa_desktop_windows02.jpg'
image_size: null
impression_url: 'https://example.org/us_wa_desktop_windows?id=0002'
url: 'https://www.example.org/us_wa_desktop_windows'
- request:
service: contile
method: GET
path: '/v1/tiles'
headers:
# Contile maps the User-Agent Header value to os-family and form-factor parameters
# The following value will result in os-family: windows and form-factor: desktop
- name: User-Agent
value: 'Mozilla/5.0 (Windows NT 10.0; rv:10.0) Gecko/20100101 Firefox/91.0'
# Contile looks up the IP address from this header value and maps it to proxy information.
# We use a random IP address from the range specified by the CIDR network notation "216.160.83.56/29"
# from https://github.com/maxmind/MaxMind-DB/blob/main/source-data/GeoLite2-City-Test.json
# The following value will result in country-code: US and region-code: WA
- name: X-Forwarded-For
value: '216.160.83.62'
response:
status_code: 200
content:
tiles:
- id: 22345
name: 'Example COM'
click_url: 'https://example.com/us_wa_desktop_windows?version=16.0.0&key=22.1&ci=6.2&ctag=1612376952400200000'
image_url: 'https://example.com/us_wa_desktop_windows01.jpg'
image_size: null
impression_url: 'https://example.com/us_wa_desktop_windows?id=0001'
url: 'https://www.example.com/us_wa_desktop_windows'
- id: 66789
name: 'Example ORG'
click_url: 'https://example.org/us_wa_desktop_windows?version=16.0.0&key=7.2&ci=8.9&ctag=E1DE38C8972D0281F5556659A'
image_url: 'https://example.org/us_wa_desktop_windows02.jpg'
image_size: null
impression_url: 'https://example.org/us_wa_desktop_windows?id=0002'
url: 'https://www.example.org/us_wa_desktop_windows'
- request:
service: partner
method: GET
path: '/records/'
headers:
- name: 'accept'
value: '*/*'
response:
status_code: 200
content:
records:
- count: 2
hackebrot marked this conversation as resolved.
Show resolved Hide resolved
record:
method: GET
headers:
- name: accept
value: '*/*'
- name: user-agent
value: 'contile/1.8.0'
- name: host
value: 'partner:5000'
path: '/tilesp/desktop'
query_parameters:
- name: partner
value: 'partner_id_test'
- name: sub1
value: 'sub1_test'
- name: sub2
value: 'newtab'
- name: country-code
value: 'US'
- name: region-code
value: 'WA'
- name: dma-code
value: '819'
- name: form-factor
value: 'desktop'
- name: os-family
value: 'windows'
- name: v
value: '1.0'
- name: out
value: 'json'
- name: results
value: '5'
Loading