зеркало из https://github.com/mozilla/treeherder.git
bug 1069389 - remove socket.io usage completely
This commit is contained in:
Родитель
404ec39c40
Коммит
e402df22f4
|
@ -82,91 +82,6 @@ describe('ThResultSetModel', function(){
|
|||
expect(model.getResultSetsArray(rootScope.repoName)[0].id).toBe(1);
|
||||
});
|
||||
|
||||
var newSocketEvent = function(repoName, data) {
|
||||
model.processSocketData(repoName, data);
|
||||
model.processUpdateQueues(repoName);
|
||||
$httpBackend.flush();
|
||||
};
|
||||
|
||||
/**
|
||||
* Test that events for new resultsets gets those job updates on the foreground repo
|
||||
*/
|
||||
it('should add new rs to the foreground repo', function() {
|
||||
var rsValues = {id: 2, push_timestamp: 1396899074+1},
|
||||
data = {
|
||||
branch: foregroundRepo,
|
||||
job_guids: {
|
||||
590604: {
|
||||
result_set_id: 2,
|
||||
result_set_push_timestamp: 1396899074+1
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$httpBackend.whenGET(foregroundPrefix + '/resultset/?count=1&format=json&full=true&id__in=2&offset=0&with_jobs=true').respond(
|
||||
getResultSet(2, rsValues)
|
||||
);
|
||||
|
||||
newSocketEvent(foregroundRepo, data);
|
||||
|
||||
var resultsets = model.getResultSetsArray(foregroundRepo);
|
||||
expect(resultsets.length).toBe(2);
|
||||
expect(_.pluck(resultsets, "id")).toEqual([2, 1]);
|
||||
});
|
||||
|
||||
/**
|
||||
* Test that events for new job in existing resultset gets those job updates on the foreground repo
|
||||
*/
|
||||
it('should add new job to the foreground repo', function() {
|
||||
var data = {
|
||||
branch: foregroundRepo,
|
||||
job_guids: {
|
||||
123: {
|
||||
result_set_id: 1,
|
||||
result_set_push_timestamp: 1396899074
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$httpBackend.whenGET(foregroundPrefix + '/jobs/?count=40&job_guid__in=123').respond(
|
||||
getJob(123, {result_set_id: 1})
|
||||
);
|
||||
|
||||
newSocketEvent(foregroundRepo, data);
|
||||
|
||||
var jobs = model.getResultSetsArray(foregroundRepo)[0].platforms[0].groups[0].jobs;
|
||||
expect(jobs.length).toBe(3);
|
||||
expect(_.pluck(jobs, "id")).toEqual([590604, 590599, 123]);
|
||||
expect(_.pluck(jobs, "state")).toEqual(["pending", "completed", "completed"]);
|
||||
});
|
||||
|
||||
/**
|
||||
* Test that events for new job in existing resultset gets those job updates on the foreground repo
|
||||
*/
|
||||
it('should update an existing job in the foreground repo to its new status', function() {
|
||||
var data = {
|
||||
branch: foregroundRepo,
|
||||
job_guids: {
|
||||
590604: {
|
||||
result_set_id: 1,
|
||||
result_set_push_timestamp: 1396899074
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$httpBackend.whenGET(foregroundPrefix + '/jobs/?count=40&job_guid__in=590604').respond(
|
||||
getJob(590604, {result_set_id: 1})
|
||||
);
|
||||
|
||||
newSocketEvent(foregroundRepo, data);
|
||||
|
||||
var jobs = model.getResultSetsArray(foregroundRepo)[0].platforms[0].groups[0].jobs;
|
||||
expect(jobs.length).toBe(2);
|
||||
expect(_.pluck(jobs, "id")).toEqual([590604, 590599]);
|
||||
expect(_.pluck(jobs, "state")).toEqual(["completed", "completed"]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
/********************************************
|
||||
* Data constructors
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
<script src="vendor/ui-bootstrap-tpls-0.10.0.min.js"></script>
|
||||
<script src="vendor/bootstrap.js"></script>
|
||||
<script src="vendor/angular/angular-sanitize.min.js"></script>
|
||||
<script src="vendor/socket.io.js"></script>
|
||||
<script src="vendor/angular-local-storage.min.js"></script>
|
||||
<script src="vendor/underscore-min.js"></script>
|
||||
<script src="vendor/resizer.js"></script>
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
treeherder.controller('JobsCtrl', [
|
||||
'$scope', '$http', '$rootScope', '$routeParams', 'ThLog', '$cookies',
|
||||
'localStorageService', 'thUrl', 'ThRepositoryModel', 'thSocket',
|
||||
'localStorageService', 'thUrl', 'ThRepositoryModel',
|
||||
'ThResultSetModel', 'thResultStatusList', '$location', 'thEvents',
|
||||
'ThJobModel',
|
||||
function JobsCtrl(
|
||||
$scope, $http, $rootScope, $routeParams, ThLog, $cookies,
|
||||
localStorageService, thUrl, ThRepositoryModel, thSocket,
|
||||
localStorageService, thUrl, ThRepositoryModel,
|
||||
ThResultSetModel, thResultStatusList, $location, thEvents, ThJobModel) {
|
||||
|
||||
var $log = new ThLog(this.constructor.name);
|
||||
|
@ -88,10 +88,6 @@ treeherder.controller('JobsCtrl', [
|
|||
}
|
||||
|
||||
};
|
||||
|
||||
// thSocket.on("job_classification", updateClassification);
|
||||
|
||||
|
||||
}
|
||||
]);
|
||||
|
||||
|
|
|
@ -1022,7 +1022,7 @@ treeherder.directive('thCloneJobs', [
|
|||
);
|
||||
|
||||
/**************
|
||||
Resultset job pollers and socketio updates can
|
||||
Resultset job pollers updates can
|
||||
trigger re-rendering rows at anytime during a
|
||||
session, this can give the appearance of sluggishness
|
||||
in the UI. Use defer to avoid rendering jankiness
|
||||
|
|
|
@ -51,22 +51,9 @@ treeherder.directive('thWatchedRepo', [
|
|||
restrict: "E",
|
||||
link: function(scope, element, attrs) {
|
||||
|
||||
scope.updateCount = function() {
|
||||
if (scope.repoData.groupName !== "try") {
|
||||
scope.adjustedUnclassifiedFailureCount = scope.getTimeWindowUnclassifiedFailureCount(
|
||||
scope.name);
|
||||
}
|
||||
};
|
||||
|
||||
scope.updateTitleText = function() {
|
||||
if (scope.repoData.treeStatus) {
|
||||
scope.titleText = scope.repoData.treeStatus.status;
|
||||
if (scope.adjustedUnclassifiedFailureCount > 0 &&
|
||||
scope.repoData.groupName !== "try") {
|
||||
scope.titleText = scope.titleText + ' - ' +
|
||||
scope.adjustedUnclassifiedFailureCount +
|
||||
" unclassified failures in last 24 hours";
|
||||
}
|
||||
if (scope.repoData.treeStatus.message_of_the_day) {
|
||||
scope.titleText = scope.titleText + ' - ' +
|
||||
scope.repoData.treeStatus.message_of_the_day;
|
||||
|
@ -76,22 +63,16 @@ treeherder.directive('thWatchedRepo', [
|
|||
|
||||
scope.btnClass = "btn-view-nav";
|
||||
|
||||
scope.$watch('repoData', function(newVal) {
|
||||
if (newVal.treeStatus) {
|
||||
$log.debug("updated treeStatus", newVal.treeStatus.status);
|
||||
scope.statusIcon = statusInfo[newVal.treeStatus.status].icon;
|
||||
scope.statusColor = statusInfo[newVal.treeStatus.status].color;
|
||||
scope.btnClass = statusInfo[newVal.treeStatus.status].btnClass;
|
||||
scope.updateCount();
|
||||
scope.$watch('repoData.treeStatus.status', function(newVal) {
|
||||
if (newVal) {
|
||||
$log.debug("updated treeStatus", newVal);
|
||||
var si = statusInfo[newVal];
|
||||
scope.statusIcon = si.icon;
|
||||
scope.statusColor = si.color;
|
||||
scope.btnClass = si.btnClass;
|
||||
scope.updateTitleText();
|
||||
}
|
||||
}, true);
|
||||
|
||||
scope.$watch('isSkippingExclusionProfiles()', function(newVal) {
|
||||
scope.updateCount();
|
||||
scope.updateTitleText();
|
||||
});
|
||||
|
||||
},
|
||||
templateUrl: 'partials/main/thWatchedRepo.html'
|
||||
};
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
treeherder.factory('ThRepositoryModel', [
|
||||
'$http', 'thUrl', '$rootScope', 'ThLog', '$interval',
|
||||
'thSocket', 'treeStatus', 'thRepoGroupOrder',
|
||||
'treeStatus', 'thRepoGroupOrder',
|
||||
function(
|
||||
$http, thUrl, $rootScope, ThLog, $interval,
|
||||
thSocket, treeStatus, thRepoGroupOrder) {
|
||||
treeStatus, thRepoGroupOrder) {
|
||||
|
||||
var $log = new ThLog("ThRepositoryModel");
|
||||
|
||||
|
@ -66,34 +66,6 @@ treeherder.factory('ThRepositoryModel', [
|
|||
updateTreeStatus(repoName);
|
||||
watchedReposUpdated();
|
||||
|
||||
// fetch the
|
||||
// current count of unclassified failures, rather than waiting
|
||||
// for the socket event to be published.
|
||||
$http.get(thUrl.getProjectUrl("/jobs/0/unclassified_failure_count/", repoName)).then(function(response) {
|
||||
repos[repoName].unclassifiedFailureCount = response.data.count;
|
||||
repos[repoName].unclassifiedFailureCountExcluded = response.data.count_excluded;
|
||||
});
|
||||
|
||||
// Add a connect listener
|
||||
// thSocket.on('connect',function() {
|
||||
// // subscribe to all the events for this repo
|
||||
// thSocket.emit('subscribe', repoName);
|
||||
// });
|
||||
|
||||
// setup to listen for the socket events that notify us of the
|
||||
// current count of unclassified failures.
|
||||
// thSocket.on(
|
||||
// "unclassified_failure_count",
|
||||
// function(data) {
|
||||
// if (data.branch === repoName) {
|
||||
//
|
||||
// $log.debug("event unclassified_failure_count", data);
|
||||
// repos[repoName].unclassifiedFailureCount = data.count;
|
||||
// repos[repoName].unclassifiedFailureCountExcluded = data.count_excluded;
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
|
||||
$log.debug("watchedRepo", repoName, repos[repoName]);
|
||||
};
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ treeherder.factory('ThResultSetModel', [
|
|||
*
|
||||
* manages:
|
||||
* resultset array
|
||||
* socket messages
|
||||
* resultset queue
|
||||
* resultset map
|
||||
* job queue
|
||||
|
@ -182,11 +181,6 @@ treeherder.factory('ThResultSetModel', [
|
|||
//and used as the offset in paging
|
||||
rsOffsetId:0,
|
||||
|
||||
// queues of updates that have come over socket.io.
|
||||
// Processed at intervals
|
||||
jobUpdateQueue:[],
|
||||
rsUpdateQueue:[],
|
||||
|
||||
lastJobElSelected:{},
|
||||
lastJobObjSelected:{},
|
||||
|
||||
|
|
|
@ -193,15 +193,13 @@ treeherder.provider('thEvents', function() {
|
|||
// fired when the user middle-clicks on a job to view the log
|
||||
jobContextMenu: "job-context-menu-EVT",
|
||||
|
||||
// fired when jobs are either classified locally, or we are
|
||||
// notified about a classification over socket.io
|
||||
// fired when jobs are classified locally
|
||||
jobsClassified: "jobs-classified-EVT",
|
||||
|
||||
// fired when bugs are associated to jobs locally, or we are
|
||||
// notified about a bug association over socket.io
|
||||
// fired when bugs are associated to jobs locally
|
||||
bugsAssociated: "bugs-associated-EVT",
|
||||
|
||||
// after loading a group of jobs queued during socket.io events
|
||||
// after loading a group of jobs
|
||||
jobsLoaded: "jobs-loaded-EVT",
|
||||
|
||||
// fired when a global filter has changed
|
||||
|
|
|
@ -17,48 +17,12 @@ treeherder.factory('thUrl', [
|
|||
},
|
||||
getLogViewerUrl: function(job_id) {
|
||||
return "logviewer.html#?job_id=" + job_id + "&repo=" + $rootScope.repoName;
|
||||
},
|
||||
getSocketEventUrl: function() {
|
||||
var port = thServiceDomain.indexOf("https:") !== -1 ? 443 :80;
|
||||
return thServiceDomain + ':' + port + '/events';
|
||||
}
|
||||
};
|
||||
return thUrl;
|
||||
|
||||
}]);
|
||||
|
||||
treeherder.factory('thSocket', [
|
||||
'$rootScope', 'ThLog', 'thUrl',
|
||||
function ($rootScope, ThLog, thUrl) {
|
||||
|
||||
var $log = new ThLog("thSocket");
|
||||
|
||||
// var socket = io.connect(thUrl.getSocketEventUrl());
|
||||
// socket.on('connect', function () {
|
||||
// $log.debug('socketio connected');
|
||||
// });
|
||||
return {
|
||||
on: function (eventName, callback) {
|
||||
socket.on(eventName, function () {
|
||||
var args = arguments;
|
||||
$rootScope.$apply(function () {
|
||||
callback.apply(socket, args);
|
||||
});
|
||||
});
|
||||
},
|
||||
emit: function (eventName, data, callback) {
|
||||
socket.emit(eventName, data, function () {
|
||||
var args = arguments;
|
||||
$rootScope.$apply(function () {
|
||||
if (callback) {
|
||||
callback.apply(socket, args);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
treeherder.factory('thCloneHtml', [
|
||||
'$interpolate',
|
||||
function($interpolate) {
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
<script src="vendor/angular/angular-sanitize.min.js"></script>
|
||||
<script src="vendor/ui-bootstrap-tpls-0.10.0.min.js"></script>
|
||||
<script src="vendor/bootstrap.js"></script>
|
||||
<script src="vendor/socket.io.js"></script>
|
||||
<script src="vendor/underscore-min.js"></script>
|
||||
<script src="vendor/resizer.js"></script>
|
||||
|
||||
|
|
|
@ -5,10 +5,6 @@
|
|||
title="{{titleText|stripHtml}}"
|
||||
class="watched-repo-main-btn btn btn-sm {{btnClass}}">
|
||||
<i class="fa {{statusIcon}} {{statusColor}}"></i> {{name}}
|
||||
<span class="watched-repo-spacer"></span>
|
||||
<span ng-show="adjustedUnclassifiedFailureCount > 0">
|
||||
<strong>{{ adjustedUnclassifiedFailureCount }}</strong>
|
||||
</span>
|
||||
</button>
|
||||
<button class="watched-repo-info-btn btn btn-sm {{btnClass}} dropdown-toggle"
|
||||
ng-class="{'active': name===repoName}"
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
treeherder.controller('PluginCtrl', [
|
||||
'$scope', '$rootScope', '$location', 'thUrl', 'ThJobClassificationModel',
|
||||
'thClassificationTypes', 'ThJobModel', 'thEvents', 'dateFilter',
|
||||
'numberFilter', 'ThBugJobMapModel', 'thResultStatus', 'thSocket',
|
||||
'numberFilter', 'ThBugJobMapModel', 'thResultStatus',
|
||||
'ThResultSetModel', 'ThLog', '$q', 'thPinboard', 'ThJobArtifactModel',
|
||||
'thBuildApi', 'thNotify', 'ThJobLogUrlModel', 'thTabs',
|
||||
function PluginCtrl(
|
||||
$scope, $rootScope, $location, thUrl, ThJobClassificationModel,
|
||||
thClassificationTypes, ThJobModel, thEvents, dateFilter,
|
||||
numberFilter, ThBugJobMapModel, thResultStatus, thSocket,
|
||||
numberFilter, ThBugJobMapModel, thResultStatus,
|
||||
ThResultSetModel, ThLog, $q, thPinboard, ThJobArtifactModel,
|
||||
thBuildApi, thNotify, ThJobLogUrlModel, thTabs) {
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
Загрузка…
Ссылка в новой задаче