It's currently broken and will be unneeded once we deploy a version
of telemetry-streaming which captures the display version
(see: mozilla/telemetry-streaming#83).
This commit is contained in:
William Lachance 2017-11-08 11:36:49 -05:00 коммит произвёл GitHub
Родитель 663885bc6e
Коммит f12db049bb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 4 добавлений и 114 удалений

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

@ -14,9 +14,8 @@ from .schema import (CHANNELS,
TELEMETRY_PLATFORM_MAPPING, TELEMETRY_PLATFORM_MAPPING,
get_measure_cache_key, get_measure_cache_key,
get_measure_summary_cache_key) get_measure_summary_cache_key)
from .versions import (VersionNotFoundError, from .versions import get_current_firefox_version
get_current_firefox_version,
get_version_string_from_buildid)
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -101,17 +100,6 @@ def update_measure(platform_name, channel_name, measure_name):
if buildstamp < window_start - channel['update_interval']: if buildstamp < window_start - channel['update_interval']:
continue continue
if not data.get(build_id): if not data.get(build_id):
# if we are on beta, try to get a more precise version (the version
# submitted to telemetry does not incorporate the beta number)
if channel_name == 'beta':
try:
version = get_version_string_from_buildid(channel_name, build_id)
except VersionNotFoundError:
# for now let's just warn if we can't find a version (most
# likely cause is invalid telemetry data being
# submitted on the beta channel)
logger.warning("Unable to get version info for %s/%s",
channel_name, build_id)
data[build_id] = {'version': version, 'data': []} data[build_id] = {'version': version, 'data': []}
data[build_id]['data'].append((window_start, measure_count, usage_hours)) data[build_id]['data'].append((window_start, measure_count, usage_hours))

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

@ -1,15 +1,10 @@
import requests import requests
from django.core.cache import cache from django.core.cache import cache
from missioncontrol.settings import (BUILD_HUB_URL, from missioncontrol.settings import (FIREFOX_VERSION_CACHE_TIMEOUT,
FIREFOX_VERSION_CACHE_TIMEOUT,
FIREFOX_VERSION_URL) FIREFOX_VERSION_URL)
class VersionNotFoundError(Exception):
pass
def get_firefox_versions(): def get_firefox_versions():
firefox_versions = cache.get('firefox_versions') firefox_versions = cache.get('firefox_versions')
if firefox_versions: if firefox_versions:
@ -31,33 +26,3 @@ def get_firefox_versions():
def get_current_firefox_version(channel_name): def get_current_firefox_version(channel_name):
return get_firefox_versions()[channel_name] return get_firefox_versions()[channel_name]
def _get_buildhub_url(channel, buildid):
return '{base_url}?_limit=1&build.id=%22{buildid}%22&' \
'target.channel={channel}&source.product=firefox'.format(
base_url=BUILD_HUB_URL, buildid=buildid, channel=channel)
def _get_version_string_cache_key(channel, buildid):
return '-'.join([channel, buildid])
def get_version_string_from_buildid(channel, buildid):
'''
Utility function for getting a human-readable version string based
on a buildid and channel. Generally only needed for beta (where
the version doesn't specify the beta number)
'''
cache_key = _get_version_string_cache_key(channel, buildid)
version = cache.get(cache_key)
if version is None:
r = requests.get(_get_buildhub_url(channel, buildid))
data = r.json()
if not data.get('data'):
raise VersionNotFoundError(
'No version for channel {channel} / buildid {buildid}'.format(
channel=channel, buildid=buildid))
version = data['data'][0]['target']['version']
cache.set(cache_key, version)
return version

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

@ -311,8 +311,6 @@ LOGGING = {
FIREFOX_VERSION_URL = 'https://product-details.mozilla.org/1.0/firefox_versions.json' FIREFOX_VERSION_URL = 'https://product-details.mozilla.org/1.0/firefox_versions.json'
FIREFOX_VERSION_CACHE_TIMEOUT = 300 FIREFOX_VERSION_CACHE_TIMEOUT = 300
BUILD_HUB_URL = 'https://kinto-ota.dev.mozaws.net/v1/buckets/build-hub/collections/releases/records'
DATA_EXPIRY_INTERVAL = timedelta(days=30) DATA_EXPIRY_INTERVAL = timedelta(days=30)
MIN_CLIENT_COUNT = 100 # minimum number of client submissions for aggregate to be used MIN_CLIENT_COUNT = 100 # minimum number of client submissions for aggregate to be used
MEASURE_SUMMARY_SAMPLING_INTERVAL = timedelta(days=1) MEASURE_SUMMARY_SAMPLING_INTERVAL = timedelta(days=1)

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

@ -4,9 +4,7 @@ import pytest
from freezegun import freeze_time from freezegun import freeze_time
from django.core.cache import cache from django.core.cache import cache
from missioncontrol.etl.schema import (get_measure_cache_key, from missioncontrol.etl.schema import get_measure_cache_key
get_measure_summary_cache_key)
from missioncontrol.etl.versions import _get_buildhub_url
@pytest.fixture @pytest.fixture
@ -66,37 +64,6 @@ def test_update_measure_with_initial_data(prepopulated_version_cache,
} }
@freeze_time('2017-07-01 13:00')
def test_update_measure_on_beta(responses, prepopulated_version_cache,
mock_raw_query, mock_raw_query_data,
base_datapoint_time):
from missioncontrol.etl.measure import update_measure
(channel, buildid, expected_version) = ('beta', '20170629075044', '55.0b6')
responses.add(responses.GET, _get_buildhub_url(channel, buildid),
json={'data': [{'target': {'version': expected_version}}]})
update_measure('windows', 'beta', 'main_crashes')
assert cache.get(get_measure_cache_key('windows', 'beta', 'main_crashes')) == {
'20170629075044': {
'version': expected_version,
'data': sorted([(d[0], d[3], d[4]) for d in mock_raw_query_data], key=lambda d: d[0])
}
}
assert cache.get(get_measure_summary_cache_key('windows', 'beta', 'main_crashes')) == {
'lastUpdated': base_datapoint_time,
'latest': {
'median': 9000.0,
'usageHours': 30,
'version': '55.0b6'
},
'previous': {
'median': None,
'usageHours': 0,
'version': None
}
}
@freeze_time('2017-07-01 13:00') @freeze_time('2017-07-01 13:00')
def test_get_measure_summary(prepopulated_version_cache, base_datapoint_time, fake_measure_data): def test_get_measure_summary(prepopulated_version_cache, base_datapoint_time, fake_measure_data):
from missioncontrol.etl.measuresummary import get_measure_summary from missioncontrol.etl.measuresummary import get_measure_summary

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

@ -1,28 +0,0 @@
import pytest
from django.core.cache import cache
from missioncontrol.etl.versions import (VersionNotFoundError,
_get_buildhub_url,
_get_version_string_cache_key,
get_version_string_from_buildid)
def test_get_buildhub_version_exists(responses):
(channel, buildid, expected_version) = ('beta', '20170629075044', '55.0b6')
responses.add(responses.GET, _get_buildhub_url(channel, buildid),
json={'data': [{'target': {'version': expected_version}}]})
cache_key = _get_version_string_cache_key(channel, buildid)
assert get_version_string_from_buildid(channel, buildid) == expected_version
assert len(responses.calls) == 1
assert cache.get(cache_key) == expected_version
def test_get_buildhub_version_does_not_exist(responses):
(channel, buildid) = ('beta', '20170629075044')
responses.add(responses.GET, _get_buildhub_url(channel, buildid),
json={'data': []})
cache_key = _get_version_string_cache_key(channel, buildid)
with pytest.raises(VersionNotFoundError):
get_version_string_from_buildid(channel, buildid)
assert len(responses.calls) == 1
assert cache.get(cache_key) is None