Commit ea3b8943 authored by Renato Figueiro Maia's avatar Renato Figueiro Maia
Browse files

Correção para evitar informar endpoints inacessíveis no registro.

[SOMA-6979][SOMA-6957]
parent 91c0c92e
......@@ -132,7 +132,8 @@ function application.new(config)
return self
end
function application.run(self)
local function startapp(self)
copas.sleep(0) -- yields so Xavante starts accepting HTTP requests.
local nodes, n_err = self.driver:get_nodes()
......@@ -179,8 +180,11 @@ function application.run(self)
return self.client:status(self.driver:get_nodes_status())
end)
self.server:start()
end
function application.run(self)
copas.addthread(startapp, self)
self.server:start()
return true
end
......
......@@ -7,7 +7,7 @@ const utils = require('./utils');
describe("Started SGA", function() {
afterEach(utils.clearAllResources);
it('should terminate on shutdown', async () => {
it('should terminate on shutdown after registration', async () => {
const config = utils.fillSgaConfig();
const mock = new utils.RegistryService(config);
const sga = new utils.SgaDaemon(config);
......@@ -22,4 +22,23 @@ describe("Started SGA", function() {
const [exitVal] = await sga.terminated();
expect(exitVal).toEqual(0);
});
it('should retry to register when server is down', async () => {
const mockPort = 55555
const mockBaseUri = `http://localhost:${mockPort}`;
const config = utils.fillSgaConfig({csbase_server: mockBaseUri});
const mock = new utils.RegistryService(config, undefined, mockPort);
const sga = new utils.SgaDaemon(config);
await sga.start();
await utils.waitMsec(200);
await mock.start();
const [req] = await events.once(mock.events, "register");
frisby.get(req.body.actions.shutdown).expect("status", 200);
const [exitVal] = await sga.terminated();
expect(exitVal).toEqual(0);
});
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment