Phedenskog has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/252662

Change subject: Catch when WPT misses repeat view
......................................................................

Catch when WPT misses repeat view

When WebPageTest gets some error (like error 99998) that somehow
means the test wasn't ok (even though the API returns ok) it skips
testing repeat view and we missed to catch that on our side.

Lets check that the view exists before we fetch the data and follow
up with an issue for WPT on GitHub.

Bug:T118441
Change-Id: I52bdf106d5809615cc28fa2d767bf2655aa615a6
---
M lib/collectMetrics.js
1 file changed, 28 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/performance/WebPageTest 
refs/changes/62/252662/1

diff --git a/lib/collectMetrics.js b/lib/collectMetrics.js
index 0a603c3..72b9bf2 100644
--- a/lib/collectMetrics.js
+++ b/lib/collectMetrics.js
@@ -34,44 +34,51 @@
         }
 
         views.forEach(function(view) {
-            // if we are missing browser info from WPT (happens when using 
MotoG at least)
-            // use a normalized version of the location
-            // the browser/location can then look like 
Dulles_MotoG_Motorola_G_Chrome
-            // but since there are no standard of naming it should be ok to 
just use what we got
-            var browser = wptJson.data.median[view].browser_name ?
-                wptJson.data.median[view].browser_name.replace(/ /g, '_') :
-                wptJson.data.location.replace(/[^A-Za-z_0-9]/g, 
'_').replace(/__+/g, '_');
+            if (wptJson.data.median[view]) {
+                // if we are missing browser info from WPT (happens when using 
MotoG at least)
+                // use a normalized version of the location
+                // the browser/location can then look like 
Dulles_MotoG_Motorola_G_Chrome
+                // but since there are no standard of naming it should be ok 
to just use what we got
+                var browser = wptJson.data.median[view].browser_name ?
+                    wptJson.data.median[view].browser_name.replace(/ /g, '_') :
+                    wptJson.data.location.replace(/[^A-Za-z_0-9]/g, 
'_').replace(/__+/g, '_');
 
-            if (emulateMobile) {
-                browser += '-emulateMobile';
-            }
+                if (emulateMobile) {
+                    browser += '-emulateMobile';
+                }
 
-            // the actual location is the first part of the location string
-            // separated by either a : or _
-            var location = wptJson.data.location.split(/:|_/)[0];
+                // the actual location is the first part of the location string
+                // separated by either a : or _
+                var location = wptJson.data.location.split(/:|_/)[0];
 
-            var keyStart = namespace + '.' + location + '.' + browser + '.' + 
view + '.';
+                var keyStart = namespace + '.' + location + '.' + browser + 
'.' + view + '.';
 
-            metricsToCollect.forEach(function(metric) {
+                metricsToCollect.forEach(function(metric) {
                 metricsToSend.timings[keyStart + metric] = 
wptJson.data.median[view][metric];
             });
 
-            if (wptJson.data.median[view].userTimes) {
-                
Object.keys(wptJson.data.median[view].userTimes).forEach(function(userTiming) {
+                if (wptJson.data.median[view].userTimes) {
+                    
Object.keys(wptJson.data.median[view].userTimes).forEach(function(userTiming) {
                     metricsToSend.timings[keyStart + userTiming] =
                         wptJson.data.median[view].userTimes[userTiming];
                 });
-            }
+                } else {
+                    console.error('Missing user timing metrics for view ' + 
view);
+                }
 
-            // collect sizes & assets
-            
Object.keys(wptJson.data.median[view].breakdown).forEach(function(assetType) {
+                // collect sizes & assets
+                
Object.keys(wptJson.data.median[view].breakdown).forEach(function(assetType) {
                 metricsToSend.requests[keyStart +
                     assetType + '.requests'] = 
wptJson.data.median[view].breakdown[assetType].
                 requests;
                 metricsToSend.sizes[keyStart +
                     assetType + '.bytes'] = 
wptJson.data.median[view].breakdown[assetType].bytes;
             });
-
+            } else {
+                // When we get a result error 99998 from WebPageTest, the 
repeat view is left out
+                // so then skip the data and log
+                console.error('Missing view ' + view);
+            }
         });
 
         return metricsToSend;

-- 
To view, visit https://gerrit.wikimedia.org/r/252662
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I52bdf106d5809615cc28fa2d767bf2655aa615a6
Gerrit-PatchSet: 1
Gerrit-Project: performance/WebPageTest
Gerrit-Branch: master
Gerrit-Owner: Phedenskog <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to