Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
Remove check of last enginediscovery was successful when returning en…
Browse files Browse the repository at this point in the history
…gines(#318)

* remove check if last enginediscovery was successful

* remove tests for throwing errors when discovery fails
  • Loading branch information
Fredrik Folkesson committed Jul 4, 2018
1 parent 07d0ac1 commit 8926b9f
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 53 deletions.
4 changes: 0 additions & 4 deletions src/EngineDiscovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ class EngineDiscovery {
* @returns {Promise<EngineReturnSpec[]>} Promise to an array of engines.
*/
async list(query) {
if (!this.discoverySuccessful) {
throw new Error('Last engine discovery failed');
}

const engines = this.engineMap.all();

if (query.format === 'condensed') {
Expand Down
21 changes: 0 additions & 21 deletions test/component/swarm/component-swarm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,3 @@ describe('Mira in docker swarm mode', () => {

after(() => nock.cleanAll());
});

describe('Mira in docker swarm mode but no access to docker daemon', () => {
let app;

before(async () => {
// Mock docker.sock
nock('http://localhost:8001').filteringPath(() => '/tasks').get('/tasks').times(10)
.reply(503, 'This node is not a swarm manager.');
app = require('../../../src/index'); // eslint-disable-line global-require
await sleep(1000); // Sleep to make room for status checks to succeed
});

describe('GET /engines', () => {
it('should return 503 Service Unavailable', async () => {
const res = await request(app.listen()).get('/v1/engines');
expect(res.status).to.equal(503);
});
});

after(() => nock.cleanAll());
});
28 changes: 0 additions & 28 deletions test/unit/EngineDiscovery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,34 +131,6 @@ describe('EngineDiscovery', () => {
expect(second.engine).to.deep.equal(engine3.engine);
});

it('should throw error if the last discovery was failed', async () => {
listEnginesStub = sinon.stub(FakeDockerClient, 'listEngines')
.onFirstCall()
.returns(engines1)
.throws(new Error('Orchestration not responding'));

engineDiscovery = new EngineDiscovery(FakeDockerClient, 20, 100000);
await engineDiscovery.start();
await sleep(50);

try {
await engineDiscovery.list({});
} catch (err) { return; }
throw new Error('Should have thrown an error');
});

it('should throw error if the first discovery failed', async () => {
listEnginesStub = sinon.stub(FakeDockerClient, 'listEngines').throws(new Error('Orchestration not responding'));
engineDiscovery = new EngineDiscovery(FakeDockerClient, 20, 100000);
await engineDiscovery.start();
await sleep(50);

try {
await engineDiscovery.list({});
} catch (err) { return; }
throw new Error('Should have thrown an error');
});

it('should list all discovered engines if a previous but not last discovery was failed', async () => {
listEnginesStub = sinon.stub(FakeDockerClient, 'listEngines')
.onFirstCall()
Expand Down

0 comments on commit 8926b9f

Please sign in to comment.