-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Add support for multiple ADM endpoints #346
Conversation
ADM requires different endpoint data for mobile vs non-mobile tile requests. This patch also changes `AdmSettings` to `AdmFilterSettings` since that's more explicit about what they are. Issue: #345, CONSVC-1562
fcf2fbb
to
8d3015a
Compare
/// Return the information for a mobile connection | ||
pub fn as_mobile(settings: &Settings) -> Self { | ||
let default = Self::as_default(settings); | ||
AdmPse { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of cloning the bits to create new AdmPse
s every time we could construct them once at startup and store them on ServerState
. I don't care much about these extra clones though so this as is is ok.
src/web/user_agent.rs
Outdated
|
||
/// Determine if the device is a mobile phone based on either the form factor or OS. | ||
pub fn is_mobile(&self) -> bool { | ||
self.form_factor == FormFactor::Phone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jrconlin Just confirmed with the mobile team, we do have mobile traffic on "tablets", and they wanted Contile to respond to tile requests from there. So let's include FormFactor::Tablet
here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ncloudioj Should we run this by adM as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we will confirm this with them in our next meeting.
Firefox on iPad returns the default desktop UA (apparently per Apple directive).
* allow for out-of-area tiles to receive empty 200 lists (#290) * removed `position` from response (current PR) * fixed response for iPad (current PR)
Now blocking on mozilla-services/contile-integration-tests#147 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi team! 👋🏻
This is my understanding of the feature request:
- Send requests for tiles for mobile clients to a different partner API endpoint
- Make that URL configurable via
CONTILE_ADM_MOBILE_ENDPOINT_URL
Unrelated to the partner mobile API, we’re also removing the deprecated settings sub1
and partner_id
. We're adding adm_mobile_partner_id
and adm_mobile_sub1
for the mobile API.
Does that sound correct to you?
This is correct.
|
I merged |
…ntile into feat/mobile-endpoint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM just needs signoff from @hackebrot
I'd also appreciate a drive by from @ncloudioj to make sure that the ADM calls are correct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
integration-tests/docker-compose.yml
Outdated
CONTILE_ADM_QUERY_TILE_COUNT: 5 | ||
CONTILE_ADM_SETTINGS: /tmp/contile/adm_settings.json | ||
CONTILE_ADM_SUB1: test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONTILE_ADM_SUB1: test | |
CONTILE_ADM_SUB1: sub1_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose. Although, we aren't really checking the parameters in the mock parent script.
integration-tests/docker-compose.yml
Outdated
CONTILE_ADM_QUERY_TILE_COUNT: 5 | ||
CONTILE_ADM_SETTINGS: /tmp/contile/adm_settings.json | ||
CONTILE_ADM_SUB1: test | ||
CONTILE_ADM_PARTNER_ID: test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONTILE_ADM_PARTNER_ID: test | |
CONTILE_ADM_PARTNER_ID: partner_id_test |
@@ -3,6 +3,8 @@ version: "3" | |||
services: | |||
contile: | |||
environment: | |||
CONTILE_ADM_SUB1: test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONTILE_ADM_SUB1: test | |
CONTILE_ADM_SUB1: sub1_test |
@@ -3,6 +3,8 @@ version: "3" | |||
services: | |||
contile: | |||
environment: | |||
CONTILE_ADM_SUB1: test | |||
CONTILE_ADM_PARTNER_ID: test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONTILE_ADM_PARTNER_ID: test | |
CONTILE_ADM_PARTNER_ID: partner_id_test |
@@ -141,7 +133,7 @@ scenarios: | |||
errno: 520 | |||
error: 'An error occurred while trying to request data' | |||
|
|||
- name: error_tablet_ios_reqwest_error | |||
- name: error_tablet_ios_reqwest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm wondering if we should revert that name change.
The error in the web application is a reqwest error
. 🤔
@@ -1,6 +1,9 @@ | |||
scenarios: | |||
- name: success_204_No_Content_exluded_region | |||
description: Test that Contile returns a 204 No Content for excluded regions | |||
# This test uses the Environment Flag "CONTILE_EXCLUDED_COUNTRIES_200" (specified | |||
# in the `docker-compose.204.yml` file) and checks that Contile returns a 204 with | |||
# no content if a request is made to an excluded country location. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding this comment! 📝
# no content if a request is made to an excluded country location. | |
# no content if a request is made from an excluded country location. |
src/web/user_agent.rs
Outdated
|
||
let mut wresult = Parser::new().parse(ua).unwrap_or_default(); | ||
|
||
// NOTE: Firefox on iPads report back the "desktop" UA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's Safari on Desktop isn't it?
// NOTE: Firefox on iPads report back the "desktop" UA | |
// NOTE: Firefox on iPads report back the Safari "desktop" UA |
let tile2 = &tiles[1]; | ||
assert_eq!(tile2["name"], "Los Pollos Hermanos"); | ||
assert_eq!(tile2["position"], 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have any unit test coverage for position
not being included in the response content? We could invert this and the above change to check for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't the strict integration tests handle this? Adding a unit test for this feels like trying to prove a negative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is correct. If Contile returns position
and an expected response content in scenarios.yml
for a 200 OK
scenario doesn't have position
the comparison of Python dicts would fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍🏻
Granted that @ncloudioj approves of these partner related changes, I'm happy for you to merge this pull request. 📱
ADM requires different endpoint data for mobile vs non-mobile tile
requests.
This patch also changes
AdmSettings
toAdmFilterSettings
sincethat's more explicit about what they are.
Issue: CONSVC-1562