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

Remove check of last enginediscovery was successful #318

Merged
merged 3 commits into from
Jul 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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