Bug 1558764 Log timestamp from page load recordings r=perftest-reviewers,Bebe
authorArnold Iakab <ariakab@mozilla.com>
Wed, 19 Jun 2019 07:51:20 +0000
changeset 479191 405087ccd676e167889bbdac848813071307fab6
parent 479190 ca7d45d235a61397589e68d0dc62a2bc82f9ea8c
child 479192 e2062faea394e3adb601cf6dd5e9737a98e0b5fa
push id36173
push userrgurzau@mozilla.com
push dateWed, 19 Jun 2019 15:50:11 +0000
treeherdermozilla-central@10e3ed789e2b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersperftest-reviewers, Bebe
bugs1558764
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1558764 Log timestamp from page load recordings r=perftest-reviewers,Bebe Differential Revision: https://phabricator.services.mozilla.com/D35008
testing/raptor/raptor/playback/alternate-server-replay-2.0.2.py
testing/raptor/raptor/playback/alternate-server-replay-4.0.4.py
testing/raptor/raptor/raptor.py
--- a/testing/raptor/raptor/playback/alternate-server-replay-2.0.2.py
+++ b/testing/raptor/raptor/playback/alternate-server-replay-2.0.2.py
@@ -85,17 +85,21 @@ Http2Layer._handle_remote_settings_chang
 class ServerPlayback:
     def __init__(self, replayfiles):
         if len(replayfiles) > 0:
             for path in replayfiles:
                 proto = os.path.splitext(path)[0] + ".json"
                 if os.path.exists(proto):
                     ctx.log.info("Loading proto info from %s" % proto)
                     with open(proto) as f:
-                        _PROTO.update(json.loads(f.read()))
+                        p = json.loads(f.read()).get('http_protocol')
+
+                        if p is not None:
+                            _PROTO.update(p)
+
         self.options = None
         self.replayfiles = replayfiles
         self.flowmap = {}
 
     def load(self, flows):
         for i in flows:
             if i.response:
                 l = self.flowmap.setdefault(self._hash(i.request), [])
--- a/testing/raptor/raptor/playback/alternate-server-replay-4.0.4.py
+++ b/testing/raptor/raptor/playback/alternate-server-replay-4.0.4.py
@@ -121,17 +121,23 @@ class AlternateServerPlayback:
                 flows = io.read_flows_from_paths([path])
             except exceptions.FlowReadException as e:
                 raise exceptions.CommandError(str(e))
             self.load_flows(flows)
             proto = os.path.splitext(path)[0] + ".json"
             if os.path.exists(proto):
                 ctx.log.info("Loading proto info from %s" % proto)
                 with open(proto) as f:
-                    _PROTO.update(json.loads(f.read()))
+                    recording_info = json.loads(f.read())
+                ctx.log.info(
+                    "Replaying file {} recorded on {}".format(
+                        os.path.basename(path), recording_info["recording_date"]
+                    )
+                )
+                _PROTO.update(recording_info["http_protocol"])
 
     def _hash(self, flow):
         """
             Calculates a loose hash of the flow request.
         """
         r = flow.request
 
         # unquote url
--- a/testing/raptor/raptor/raptor.py
+++ b/testing/raptor/raptor/raptor.py
@@ -55,17 +55,16 @@ from gen_test_config import gen_test_con
 from outputhandler import OutputHandler
 from manifest import get_raptor_test_list
 from memory import generate_android_memory_profile
 from power import init_android_power_test, finish_android_power_test
 from results import RaptorResultsHandler
 from utils import view_gecko_profile
 from cpu import generate_android_cpu_profile
 
-
 LOG = RaptorLogger(component='raptor-main')
 
 
 class SignalHandler:
 
     def __init__(self):
         signal.signal(signal.SIGINT, self.handle_signal)
         signal.signal(signal.SIGTERM, self.handle_signal)
@@ -316,24 +315,18 @@ class Raptor(object):
         # for chrome the addon is just a list (appended to cmd line)
         chrome_apps = CHROMIUM_DISTROS + ["chrome-android", "chromium-android"]
         if self.config['app'] in chrome_apps:
             self.profile.addons.remove(self.raptor_webext)
 
     def get_proxy_command_for_mitm(self, test, version):
         # Generate Mitmproxy playback args
         script = os.path.join(here, "playback", "alternate-server-replay-{}.py".format(version))
-        recordings = test.get("playback_recordings")
-        if recordings:
-            recording_paths = []
-            proxy_dir = self.playback.mozproxy_dir
-            for recording in recordings.split():
-                if not recording:
-                    continue
-                recording_paths.append(os.path.join(proxy_dir, recording))
+
+        recording_paths = self.get_recording_paths(test)
 
         # this part is platform-specific
         if mozinfo.os == "win":
             script = script.replace("\\", "\\\\\\")
             recording_paths = [recording_path.replace("\\", "\\\\\\")
                                for recording_path in recording_paths]
 
         if version == "2.0.2":
@@ -370,16 +363,47 @@ class Raptor(object):
         self.get_playback_config(test)
         self.playback = get_playback(self.config, self.device)
 
         self.get_proxy_command_for_mitm(test, self.config['playback_version'])
 
         # let's start it!
         self.playback.start()
 
+        self.log_recording_dates(test)
+
+    def get_recording_paths(self, test):
+        recordings = test.get("playback_recordings")
+
+        if recordings:
+            recording_paths = []
+            proxy_dir = self.playback.mozproxy_dir
+
+            for recording in recordings.split():
+                if not recording:
+                    continue
+                recording_paths.append(os.path.join(proxy_dir, recording))
+
+            return recording_paths
+
+    def log_recording_dates(self, test):
+        for r in self.get_recording_paths(test):
+            json_path = '{}.json'.format(r.split('.')[0])
+
+            if os.path.exists(json_path):
+                with open(json_path) as f:
+                    recording_date = json.loads(f.read()).get('recording_date')
+
+                    if recording_date is not None:
+                        LOG.info('Playback recording date: {} '.format(recording_date.split(' ')[0]))
+                    else:
+                        LOG.info('Playback recording date not available')
+            else:
+                LOG.info('Playback recording information not available')
+
     def delete_proxy_settings_from_profile(self):
         # Must delete the proxy settings from the profile if running
         # the test with a host different from localhost.
         userjspath = os.path.join(self.profile.profile, 'user.js')
         with open(userjspath) as userjsfile:
             prefs = userjsfile.readlines()
         prefs = [pref for pref in prefs if 'network.proxy' not in pref]
         with open(userjspath, 'w') as userjsfile: