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

feat: Add support for multiple ADM endpoints #346

Merged
merged 27 commits into from
Feb 8, 2022
Merged

Conversation

jrconlin
Copy link
Member

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: CONSVC-1562

@jrconlin jrconlin requested review from pjenvey and ncloudioj January 19, 2022 00:30
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
@jrconlin jrconlin force-pushed the feat/mobile-endpoint branch from fcf2fbb to 8d3015a Compare January 19, 2022 00:34
src/settings.rs Outdated Show resolved Hide resolved
/// Return the information for a mobile connection
pub fn as_mobile(settings: &Settings) -> Self {
let default = Self::as_default(settings);
AdmPse {
Copy link
Member

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 AdmPses 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/adm/settings.rs Outdated Show resolved Hide resolved
src/adm/tiles.rs Show resolved Hide resolved
pjenvey
pjenvey previously approved these changes Jan 25, 2022

/// 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
Copy link
Collaborator

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.

Copy link
Member

@pjenvey pjenvey Jan 25, 2022

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?

Copy link
Collaborator

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.

src/web/user_agent.rs Outdated Show resolved Hide resolved
Firefox on iPad returns the default desktop UA (apparently per Apple
directive).
src/web/user_agent.rs Outdated Show resolved Hide resolved
* allow for out-of-area tiles to receive empty 200 lists (#290)
* removed `position` from response (current PR)
* fixed response for iPad (current PR)
@jrconlin jrconlin requested a review from hackebrot January 27, 2022 00:06
@jrconlin
Copy link
Member Author

Now blocking on mozilla-services/contile-integration-tests#147

Copy link
Member

@hackebrot hackebrot left a 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?

src/adm/settings.rs Outdated Show resolved Hide resolved
@jrconlin
Copy link
Member Author

This is correct.
This patch contains a number of fixes and changes which are products of the recent mobile endpoint changes. These normally get rolled up into the final commit message, but I will list them here for clarity.

  • Add handling to send "mobile" devices to the new ADM mobile endpoint, with appropriate partner_id, and sub1
  • Add settings arguments for the new mobile specific arguments.
  • Remove the obsolete sub1 and partner_id values (since we can no longer warn on their use.)
  • "Correctly" identify firefox on iPad UserAgent string (which uses the default macos desktop UA per guidance from the mobile team and Apple)
  • Remove the "position" field from outbound data since it is not used by User Agents and is complicating deployment. (Issue The "postion" field is not always populated in the response of Contile  #347)
  • Adjust integration testing to account for above.

@jrconlin jrconlin requested review from hackebrot and pjenvey February 2, 2022 00:20
pjenvey
pjenvey previously approved these changes Feb 2, 2022
@jrconlin jrconlin dismissed hackebrot’s stale review February 2, 2022 23:58

Changes made. Please re-review.

@jrconlin jrconlin requested a review from pjenvey February 2, 2022 23:58
pjenvey
pjenvey previously approved these changes Feb 3, 2022
@hackebrot
Copy link
Member

I merged main and resolved the merge conflicts.

pjenvey
pjenvey previously approved these changes Feb 4, 2022
Copy link
Member

@pjenvey pjenvey left a 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

@jrconlin
Copy link
Member Author

jrconlin commented Feb 4, 2022

I'd also appreciate a drive by from @ncloudioj to make sure that the ADM calls are correct

Copy link
Member

@hackebrot hackebrot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jrconlin @pjenvey! 👋🏻

I've added my comments inline. I recommend using distinct values for partner parameters to make it easier to debug issues. Otherwise the changes look reasonable to me.

I appreciate you adding the comments to the integration test files. That's helpful! 👍🏻

CONTILE_ADM_QUERY_TILE_COUNT: 5
CONTILE_ADM_SETTINGS: /tmp/contile/adm_settings.json
CONTILE_ADM_SUB1: test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CONTILE_ADM_SUB1: test
CONTILE_ADM_SUB1: sub1_test

Copy link
Member Author

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.

CONTILE_ADM_QUERY_TILE_COUNT: 5
CONTILE_ADM_SETTINGS: /tmp/contile/adm_settings.json
CONTILE_ADM_SUB1: test
CONTILE_ADM_PARTNER_ID: test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

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.
Copy link
Member

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! 📝

Suggested change
# no content if a request is made to an excluded country location.
# no content if a request is made from an excluded country location.


let mut wresult = Parser::new().parse(ua).unwrap_or_default();

// NOTE: Firefox on iPads report back the "desktop" UA
Copy link
Member

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?

Suggested change
// 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);
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member

@hackebrot hackebrot left a 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. 📱

@jrconlin jrconlin merged commit 80d7dca into main Feb 8, 2022
@jrconlin jrconlin deleted the feat/mobile-endpoint branch February 8, 2022 18:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants