Skip to content

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdover committed Aug 1, 2018
1 parent bef1ba1 commit 9841b57
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/server/status/lib/get_kibana_info_for_stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ export function getKibanaInfoForStats(server, kbnServer) {
transport_address: `${config.get('server.host')}:${config.get('server.port')}`,
version: kbnServer.version.replace(snapshotRegex, ''),
snapshot: snapshotRegex.test(kbnServer.version),
status: get(status, 'overall.state')
status: get(status, 'overall.id')
};
}
20 changes: 12 additions & 8 deletions src/server/status/server_status.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as states from './states';
import Status from './status';
import ServerStatus from './server_status';


describe('ServerStatus class', function () {
const plugin = { id: 'name', version: '1.2.3' };

Expand Down Expand Up @@ -93,13 +94,13 @@ describe('ServerStatus class', function () {
it('considers each status to produce a summary', function () {
const status = serverStatus.createForPlugin(plugin);

expect(serverStatus.overall().state).toBe('uninitialized');
expect(serverStatus.overall().id).toBe('uninitialized');

const match = function (overall, state) {
expect(overall).toHaveProperty('state', state.id);
expect(overall).toHaveProperty('title', state.title);
expect(overall).toHaveProperty('icon', state.icon);
expect(state.nicknames).toContain(overall.nickname);
expect(overall).toHaveProperty('id', state.id);
expect(overall).toHaveProperty('state.title', state.title);
expect(overall).toHaveProperty('state.uiColor', state.uiColor);
expect(state.nicknames).toContain(overall.state.nickname);
};

status.green();
Expand Down Expand Up @@ -133,9 +134,12 @@ describe('ServerStatus class', function () {
expect(json.statuses).toHaveLength(3);

const out = status => find(json.statuses, { id: status.id });
expect(out(service)).toHaveProperty('state', 'green');
expect(out(p1)).toHaveProperty('state', 'yellow');
expect(out(p2)).toHaveProperty('state', 'red');
expect(out(service)).toHaveProperty('state.message', 'Green');
expect(out(service)).toHaveProperty('state.uiColor', 'secondary');
expect(out(p1)).toHaveProperty('state.message', 'Yellow');
expect(out(p1)).toHaveProperty('state.uiColor', 'warning');
expect(out(p2)).toHaveProperty('state.message', 'Red');
expect(out(p2)).toHaveProperty('state.uiColor', 'danger');
});
});

Expand Down
1 change: 1 addition & 0 deletions src/server/status/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default class Status extends EventEmitter {
return {
id: this.id,
state: {
id: this.state,
message: this.message,
uiColor: states.get(this.state).uiColor,
},
Expand Down
7 changes: 5 additions & 2 deletions test/api_integration/apis/status/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ export default function ({ getService }) {
expect(body.version.build_number).to.be.a('number');

expect(body.status.overall).to.be.an('object');
expect(body.status.overall.state).to.be('green');
expect(body.status.overall.id).to.be('green');
expect(body.status.overall.state).to.be.an('object');
expect(body.status.overall.state.title).to.be('Green');

expect(body.status.statuses).to.be.an('array');
const kibanaPlugin = body.status.statuses.find(s => {
return s.id.indexOf('plugin:kibana') === 0;
});
expect(kibanaPlugin.state).to.be('green');
expect(kibanaPlugin.state).to.be.an('object');
expect(kibanaPlugin.state.id).to.be('green');

expect(body.metrics.collection_interval_in_millis).to.be.a('number');

Expand Down
2 changes: 1 addition & 1 deletion test/common/services/kibana_server/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ export class KibanaServerStatus {

async getOverallState() {
const status = await this.get();
return status.status.overall.state;
return status.status.overall.id;
}
}

0 comments on commit 9841b57

Please sign in to comment.