mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-10 18:09:15 +00:00
better wait reasons update + start working on running multiple projects after build complete
This commit is contained in:
parent
361a5a5436
commit
85844bcb40
@ -1,6 +1,6 @@
|
||||
|
||||
nodes:
|
||||
- type: local
|
||||
maxExecutorsCount: 1
|
||||
maxExecutorsCount: 2
|
||||
|
||||
notify: {}
|
||||
|
@ -59,7 +59,7 @@ Distributor.prototype._runNext = function(callback) {
|
||||
|
||||
self._updateBuild(
|
||||
queueItem.build,
|
||||
{startDate: Date.now(), status: 'in-progress'},
|
||||
{startDate: Date.now(), status: 'in-progress', waitReason: ''},
|
||||
this.slot()
|
||||
);
|
||||
},
|
||||
@ -75,7 +75,13 @@ Distributor.prototype._runNext = function(callback) {
|
||||
error: err ? err.message : null
|
||||
},
|
||||
function(err, build) {
|
||||
self._onBuildComplete(err, build, stepCallback)
|
||||
if (err) {
|
||||
console.error(
|
||||
'Error during build update: ', err.stack || err
|
||||
);
|
||||
return stepCallback(err);
|
||||
}
|
||||
self._onBuildComplete(build, stepCallback);
|
||||
}
|
||||
);
|
||||
});
|
||||
@ -107,13 +113,14 @@ Distributor.prototype._updateWaitReasons = function() {
|
||||
});
|
||||
|
||||
var waitReason = _(waitReasons).compact().join(', ');
|
||||
if (waitReason !== item.build.waitReason) {
|
||||
// set only non-empty reasons
|
||||
if (waitReason && waitReason !== item.build.waitReason) {
|
||||
self._updateBuild(item.build, {waitReason: waitReason});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Distributor.prototype._onBuildComplete = function(err, build, callback) {
|
||||
Distributor.prototype._onBuildComplete = function(build, callback) {
|
||||
var self = this;
|
||||
|
||||
Steppy(
|
||||
|
@ -28,6 +28,10 @@ Node.prototype.hasFreeExecutor = function(project) {
|
||||
return !this.getExecutorWaitReason(project);
|
||||
};
|
||||
|
||||
Node.prototype.getFreeExecutorsCount = function() {
|
||||
return this.maxExecutorsCount - _(this.executors).size();
|
||||
};
|
||||
|
||||
Node.prototype._createExecutor = function(project) {
|
||||
return createExecutor({
|
||||
type: this.type,
|
||||
|
@ -69,20 +69,15 @@ describe('Distributor', function() {
|
||||
expect(changes.completed).equal(false);
|
||||
});
|
||||
|
||||
it('build should have empty wait reason', function() {
|
||||
it('build should be in-progress', function() {
|
||||
var changes = updateBuildSpy.getCall(1).args[1];
|
||||
expect(changes).only.have.keys('waitReason');
|
||||
expect(changes).only.have.keys('startDate', 'status', 'waitReason');
|
||||
expect(changes.status).equal('in-progress');
|
||||
expect(changes.waitReason).equal('');
|
||||
});
|
||||
|
||||
it('build should be in-progress', function() {
|
||||
var changes = updateBuildSpy.getCall(2).args[1];
|
||||
expect(changes).only.have.keys('startDate', 'status');
|
||||
expect(changes.status).equal('in-progress');
|
||||
});
|
||||
|
||||
it('build should be done', function() {
|
||||
var changes = updateBuildSpy.getCall(3).args[1];
|
||||
var changes = updateBuildSpy.getCall(2).args[1];
|
||||
expect(changes).only.have.keys(
|
||||
'endDate', 'status', 'completed', 'error'
|
||||
);
|
||||
@ -91,8 +86,8 @@ describe('Distributor', function() {
|
||||
expect(changes.error).equal(null);
|
||||
});
|
||||
|
||||
it('update build called 4 times in total', function() {
|
||||
expect(updateBuildSpy.callCount).equal(4);
|
||||
it('update build called 3 times in total', function() {
|
||||
expect(updateBuildSpy.callCount).equal(3);
|
||||
});
|
||||
|
||||
after(function() {
|
||||
@ -134,26 +129,20 @@ describe('Distributor', function() {
|
||||
expect(changes.status).equal('queued');
|
||||
});
|
||||
|
||||
it('build should have empty wait reason', function() {
|
||||
var changes = updateBuildSpy.getCall(1).args[1];
|
||||
expect(changes).only.have.keys('waitReason');
|
||||
expect(changes.waitReason).equal('');
|
||||
});
|
||||
|
||||
it('build should be in-progress', function() {
|
||||
var changes = updateBuildSpy.getCall(2).args[1];
|
||||
var changes = updateBuildSpy.getCall(1).args[1];
|
||||
expect(changes.status).equal('in-progress');
|
||||
});
|
||||
|
||||
it('build should be fail', function() {
|
||||
var changes = updateBuildSpy.getCall(3).args[1];
|
||||
var changes = updateBuildSpy.getCall(2).args[1];
|
||||
expect(changes.status).equal('error');
|
||||
expect(changes.completed).equal(true);
|
||||
expect(changes.error).equal('Some error');
|
||||
});
|
||||
|
||||
it('update build called 4 times in total', function() {
|
||||
expect(updateBuildSpy.callCount).equal(4);
|
||||
it('update build called 3 times in total', function() {
|
||||
expect(updateBuildSpy.callCount).equal(3);
|
||||
});
|
||||
|
||||
after(function() {
|
||||
|
Loading…
Reference in New Issue
Block a user