asimov-deploy-ui
Advanced tools
Comparing version 0.9.5 to 0.9.6
@@ -68,3 +68,5 @@ /******************************************************************************* | ||
name: req.body.name, | ||
groups: req.body.groups || [ req.body.group ] | ||
groups: req.body.groups || [ req.body.group ], | ||
supportsFiltering: req.body.group ? false : true, | ||
isLegacyNodeAgent: req.body.version === '1.0.0' && req.body.configVersion === '0.0.1' ? true : false | ||
}; | ||
@@ -84,3 +86,3 @@ | ||
if (!existing) { | ||
if (!existing && agent.supportsFiltering) { | ||
agentApiClient.getAgentUnitGroups(agent.name, function (unitGroups) { | ||
@@ -87,0 +89,0 @@ config.addUnitGroups(unitGroups); |
@@ -75,2 +75,8 @@ /******************************************************************************* | ||
if (filters.unitGroups || filters.unitTypes || filters.tags || filters.units || filters.unitStatus) { | ||
agents = _.filter(agents, function (agent) { | ||
return agent.supportsFiltering; | ||
}); | ||
} | ||
var url = _getUnitListUrl(filters, skipStatusRefresh); | ||
@@ -83,7 +89,16 @@ | ||
} | ||
this.get(agent.name, url, function(units) { | ||
result.push({agent: agent, units: units}); | ||
done(); | ||
}); | ||
if (agent.isLegacyNodeAgent) { | ||
this.get(agent.name, '/units/list', function(units) { | ||
result.push({agent: agent, units: units}); | ||
done(); | ||
}); | ||
} | ||
else { | ||
this.get(agent.name, url, function(units) { | ||
result.push({agent: agent, units: units}); | ||
done(); | ||
}); | ||
} | ||
}.bind(this), function() { | ||
@@ -90,0 +105,0 @@ dataCallback(result); |
@@ -5,3 +5,3 @@ { | ||
"author": "Ebay Inc", | ||
"version": "0.9.5", | ||
"version": "0.9.6", | ||
"homepage": "https://github.com/asimov-deploy/asimov-deploy", | ||
@@ -8,0 +8,0 @@ "license": "Apache-2.0", |
@@ -92,2 +92,152 @@ require('should'); | ||
describe('when agent is not a legacy node agent', function() { | ||
var unitList = []; | ||
var fakeAgent = { group: "groupName", isLegacyNodeAgent: false }; | ||
var jsonClientOptions; | ||
var jsonClientGetSpy; | ||
before(function() { | ||
var fakeConfig = { | ||
agents: [ | ||
fakeAgent | ||
], | ||
getAgent: function() { | ||
return { url: 'agentUrl', apiKey: '12321313213' }; | ||
} | ||
}; | ||
var restify = { | ||
createJsonClient: function(options) { | ||
jsonClientOptions = options; | ||
jsonClientGetSpy = sinon.spy(); | ||
return { get: jsonClientGetSpy }; | ||
} | ||
}; | ||
var apiClient = require("../../app/services/agent-api-client").create(fakeConfig, restify); | ||
apiClient.getUnits({agentGroups: ['groupName']}, false, function (results) { | ||
unitList = results; | ||
}); | ||
}); | ||
it('should use url with agent group filter to fetch units', function() { | ||
jsonClientGetSpy.getCall(0).args[0].should.equal('/units/list?agentGroups=groupName'); | ||
jsonClientGetSpy.called.should.equal(true); | ||
}); | ||
}); | ||
describe('when agent is a legacy node agent', function() { | ||
var unitList = []; | ||
var fakeAgent = { group: "groupName", isLegacyNodeAgent: true }; | ||
var jsonClientOptions; | ||
var jsonClientGetSpy; | ||
before(function() { | ||
var fakeConfig = { | ||
agents: [ | ||
fakeAgent | ||
], | ||
getAgent: function() { | ||
return { url: 'agentUrl', apiKey: '12321313213' }; | ||
} | ||
}; | ||
var restify = { | ||
createJsonClient: function(options) { | ||
jsonClientOptions = options; | ||
jsonClientGetSpy = sinon.spy(); | ||
return { get: jsonClientGetSpy }; | ||
} | ||
}; | ||
var apiClient = require("../../app/services/agent-api-client").create(fakeConfig, restify); | ||
apiClient.getUnits({agentGroups: ['groupName']}, false, function (results) { | ||
unitList = results; | ||
}); | ||
}); | ||
it('should use legacy url to fetch units', function() { | ||
jsonClientGetSpy.getCall(0).args[0].should.equal('/units/list'); | ||
jsonClientGetSpy.called.should.equal(true); | ||
}); | ||
}); | ||
describe('when agent supports extended filtering and filtering units on agent groups and unit groups', function() { | ||
var unitList = []; | ||
var fakeAgent = { group: "groupName", supportsFiltering: true }; | ||
var jsonClientOptions; | ||
var jsonClientGetSpy; | ||
before(function() { | ||
var fakeConfig = { | ||
agents: [ | ||
fakeAgent | ||
], | ||
getAgent: function() { | ||
return { url: 'agentUrl', apiKey: '12321313213' }; | ||
} | ||
}; | ||
var restify = { | ||
createJsonClient: function(options) { | ||
jsonClientOptions = options; | ||
jsonClientGetSpy = sinon.spy(); | ||
return { get: jsonClientGetSpy }; | ||
} | ||
}; | ||
var apiClient = require("../../app/services/agent-api-client").create(fakeConfig, restify); | ||
apiClient.getUnits({agentGroups: ['groupName'], unitGroups:['test']}, false, function (results) { | ||
unitList = results; | ||
}); | ||
}); | ||
it('should use url with agent group and unit group filters to fetch units', function() { | ||
jsonClientGetSpy.getCall(0).args[0].should.equal('/units/list?agentGroups=groupName&unitGroups=test'); | ||
jsonClientGetSpy.called.should.equal(true); | ||
}); | ||
}); | ||
describe('when agent not supports extended filtering and filtering units on agent groups and unit groups', function() { | ||
var unitList = []; | ||
var fakeAgent = { group: "groupName", supportsFiltering: false }; | ||
var jsonClientOptions; | ||
var jsonClientGetSpy; | ||
before(function() { | ||
var fakeConfig = { | ||
agents: [ | ||
fakeAgent | ||
], | ||
getAgent: function() { | ||
return { url: 'agentUrl', apiKey: '12321313213' }; | ||
} | ||
}; | ||
var restify = { | ||
createJsonClient: function(options) { | ||
jsonClientOptions = options; | ||
jsonClientGetSpy = sinon.spy(); | ||
return { get: jsonClientGetSpy }; | ||
} | ||
}; | ||
var apiClient = require("../../app/services/agent-api-client").create(fakeConfig, restify); | ||
apiClient.getUnits({agentGroups: ['groupName'], unitGroups:['test']}, false, function (results) { | ||
unitList = results; | ||
}); | ||
}); | ||
it('should not call agent', function() { | ||
//assert(jsonClientGetSpy === undefined); | ||
}); | ||
it('should return empty array', function() { | ||
unitList.should.deepEqual([]); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3406517
71343