Bug 1509913 - Add helper function for checking UUID values to telemetry-tests-client; r=Dexter

Differential Revision: https://phabricator.services.mozilla.com/D13415

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Raphael Pierzina 2018-11-29 16:02:21 +00:00
parent 056ca1083b
commit a8b139ad31
2 changed files with 23 additions and 7 deletions

View File

@ -3,6 +3,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import os
import re
import simplejson as json
import time
import zlib
@ -15,6 +16,12 @@ from marionette_harness import MarionetteTestCase
from marionette_harness.runner import httpd
CANARY_CLIENT_ID = "c0ffeec0-ffee-c0ff-eec0-ffeec0ffeec0"
UUID_PATTERN = re.compile(
r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
)
class TelemetryTestCase(PuppeteerMixin, MarionetteTestCase):
def __init__(self, *args, **kwargs):
@ -81,6 +88,21 @@ class TelemetryTestCase(PuppeteerMixin, MarionetteTestCase):
# Wait 5 seconds to ensure that telemetry has reinitialized
time.sleep(5)
def assertIsValidUUID(self, value):
"""Check if the given UUID is valid."""
self.assertIsNotNone(value)
self.assertNotEqual(value, "")
# Check for client ID that is used when Telemetry upload is disabled
self.assertNotEqual(
value, CANARY_CLIENT_ID, msg="UUID is CANARY CLIENT ID"
)
self.assertIsNotNone(
re.match(UUID_PATTERN, value),
msg="UUID does not match regular expression",
)
def wait_for_pings(self, action_func, ping_filter, count):
"""Call the given action and wait for pings to come in and return
the `count` number of pings, that match the given filter.

View File

@ -10,8 +10,6 @@ from telemetry_harness.ping_filters import (
MAIN_SHUTDOWN_PING,
)
CANARY_CLIENT_ID = "c0ffeec0-ffee-c0ff-eec0-ffeec0ffeec0"
class TestSearchCounts(TelemetryTestCase):
"""Test for SEARCH_COUNTS across sessions."""
@ -86,11 +84,7 @@ class TestSearchCounts(TelemetryTestCase):
# - SEARCH_COUNTS values should match performed search action
client_id = ping1["clientId"]
self.assertIsNotNone(client_id)
self.assertNotEqual(client_id, "")
# Check for client ID that used when Telemetry upload is disabled
self.assertNotEqual(client_id, CANARY_CLIENT_ID)
self.assertIsValidUUID(client_id)
ping1_info = ping1["payload"]["info"]
self.assertEqual(ping1_info["reason"], "shutdown")