Merge pull request #4711 from pmac/fix-funnelcake-config

Bug 1345467: Allow per experiment configuration of funnelcake platforms and locales
This commit is contained in:
Josh Mize 2017-03-10 10:24:11 -06:00 коммит произвёл GitHub
Родитель 77103cce05 7049ab4b9a
Коммит 4060ee07fc
4 изменённых файлов: 52 добавлений и 9 удалений

Просмотреть файл

@ -4,8 +4,11 @@ from operator import itemgetter
from urllib import urlencode
from django.conf import settings
from bedrock.base.waffle import switch
from decouple import Csv, config
from product_details import ProductDetails
from bedrock.base.waffle import switch
from lib.l10n_utils.dotlang import _lazy as _
@ -208,10 +211,13 @@ class FirefoxDesktop(_ProductDetails):
_version = version
_locale = 'ja-JP-mac' if platform == 'osx' and locale == 'ja' else locale
_platform = 'win' if platform == 'winsha1' else platform
include_funnelcake_param = False
# Bug 1340087 - Only include funnelcake params for Windows 32bit en-US builds by default.
include_funnelcake_param = (funnelcake_id and _platform in settings.FUNNELCAKE_PLATFORMS and
_locale in settings.FUNNELCAKE_LOCALES)
# Bug 1345467 - Only allow specifically configured funnelcake builds
if funnelcake_id:
fc_platforms = config('FUNNELCAKE_%s_PLATFORMS' % funnelcake_id, default='', cast=Csv())
fc_locales = config('FUNNELCAKE_%s_LOCALES' % funnelcake_id, default='', cast=Csv())
include_funnelcake_param = _platform in fc_platforms and _locale in fc_locales
# Nightly and Aurora have a special download link format
# see bug 1324001

Просмотреть файл

@ -399,7 +399,7 @@ class TestFirefoxDesktop(TestCase):
"""latest_major_version should return 0 when no int."""
eq_(firefox_desktop.latest_major_version('release'), 0)
@override_settings(FUNNELCAKE_LOCALES=('en-US',), FUNNELCAKE_PLATFORMS=('win',))
@patch.dict(os.environ, FUNNELCAKE_64_LOCALES='en-US', FUNNELCAKE_64_PLATFORMS='win')
def test_funnelcake_direct_links_en_us_win_only(self):
"""
Ensure funnelcake params are included for Windows en-US builds only.
@ -419,7 +419,7 @@ class TestFirefoxDesktop(TestCase):
url = firefox_desktop.get_download_url('release', '45.0', 'osx', 'en-US', force_direct=True, funnelcake_id='64')
ok_('product=firefox-45.0-f64' not in url)
@override_settings(FUNNELCAKE_LOCALES=('en-US', 'de'), FUNNELCAKE_PLATFORMS=('linux', 'osx'))
@patch.dict(os.environ, FUNNELCAKE_64_LOCALES='en-US,de', FUNNELCAKE_64_PLATFORMS='linux,osx')
def test_funnelcake_direct_links_locales_linux_osx_(self):
"""
Ensure funnelcake params are included for Linux and OSX en-US builds only.
@ -451,6 +451,37 @@ class TestFirefoxDesktop(TestCase):
url = firefox_desktop.get_download_url('release', '45.0', 'linux', 'fr', force_direct=True, funnelcake_id='64')
ok_('product=firefox-45.0-f64' not in url)
def test_no_funnelcake_direct_links_if_not_configured(self):
"""
Ensure funnelcake params are included for Linux and OSX en-US builds only.
"""
url = firefox_desktop.get_download_url('release', '45.0', 'win', 'en-US', force_direct=True, funnelcake_id='64')
ok_('-f64' not in url)
url = firefox_desktop.get_download_url('release', '45.0', 'win', 'en-US', force_direct=True, force_full_installer=True, funnelcake_id='64')
ok_('-f64' not in url)
url = firefox_desktop.get_download_url('release', '45.0', 'win', 'en-US', force_direct=True, force_funnelcake=True, funnelcake_id='64')
ok_('-f64' not in url)
url = firefox_desktop.get_download_url('release', '45.0', 'osx', 'de', force_direct=True, funnelcake_id='64')
ok_('-f64' not in url)
url = firefox_desktop.get_download_url('release', '45.0', 'osx', 'en-US', force_direct=True, funnelcake_id='64')
ok_('-f64' not in url)
url = firefox_desktop.get_download_url('release', '45.0', 'osx', 'fr', force_direct=True, funnelcake_id='64')
ok_('-f64' not in url)
url = firefox_desktop.get_download_url('release', '45.0', 'linux', 'de', force_direct=True, funnelcake_id='64')
ok_('-f64' not in url)
url = firefox_desktop.get_download_url('release', '45.0', 'linux', 'en-US', force_direct=True, funnelcake_id='64')
ok_('-f64' not in url)
url = firefox_desktop.get_download_url('release', '45.0', 'linux', 'fr', force_direct=True, funnelcake_id='64')
ok_('-f64' not in url)
@override_settings(STUB_INSTALLER_LOCALES={'win': ['en-us']})
def test_force_funnelcake_en_us_win_only(self):
"""

Просмотреть файл

@ -2,6 +2,7 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import os
from datetime import date
import json
@ -65,6 +66,7 @@ class TestHome(TestCase):
class TestViews(TestCase):
@patch.dict(os.environ, FUNNELCAKE_5_LOCALES='en-US', FUNNELCAKE_5_PLATFORMS='win')
@override_settings(STUB_INSTALLER_LOCALES={'win': _ALL})
def test_download_button_funnelcake(self):
"""The download button should have the funnelcake ID."""

Просмотреть файл

@ -1290,6 +1290,10 @@ if config('SWITCH_TRACKING_PIXEL', default=DEV, cast=bool):
if any([x.startswith('yahoo') for x in ENABLED_PIXELS]):
CSP_IMG_SRC += ('sp.analytics.yahoo.com',)
# Bug 1340087 - Funnelcake experiments default to Windows 32bit and en-US builds only.
FUNNELCAKE_PLATFORMS = config('FUNNELCAKE_PLATFORMS', default='win', cast=Csv())
FUNNELCAKE_LOCALES = config('FUNNELCAKE_LOCALES', default='en-US', cast=Csv())
# Bug 1345467: Funnelcakes are now explicitly configured in the environment.
# Set experiment specific variables like the following:
#
# FUNNELCAKE_103_PLATFORMS=win,win64
# FUNNELCAKE_103_LOCALES=de,fr,en-US
#
# where "103" in the variable name is the funnelcake ID.