Skip to content

Commit

Permalink
Support api_integration/kibana/stats against remote hosts (#53000)
Browse files Browse the repository at this point in the history
* Support api_integration/kibana/stats against remote hosts

The stats API integration tests run under the assumption of a fixed
kibana.yml.  This is the case when running against a
default FTR configuration, but not when running against remote servers.
This relaxes a few assertions and conditionally runs in cases that can't be
relaxed.

Resolves #37386

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
jbudz and elasticmachine committed May 20, 2020
1 parent 32a7f81 commit 5ab3e19
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions x-pack/test/api_integration/apis/kibana/stats/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,45 @@ import expect from '@kbn/expect';
export default function({ getService }) {
const supertestNoAuth = getService('supertestWithoutAuth');
const supertest = getService('supertest');
const config = getService('config');

describe('/api/stats', () => {
describe('operational stats and usage stats', () => {
// lazy check for uuid for test runs against preexisting services
function isUUID(uuid) {
return typeof uuid === 'string' && uuid.length === 36;
}

describe('no auth', () => {
it('should return 200 and stats for no extended', async () => {
// depends on kibana.yml setting status.allowAnonymous
// skip this test when running against a remote host, as we can't
// validate the status of this setting
const host = config.get('servers.kibana.hostname');
const ifLocalhost = host.includes('localhost') ? it : it.skip;
ifLocalhost('should return 200 and stats for no extended', async () => {
const { body } = await supertestNoAuth.get('/api/stats').expect(200);
expect(body.kibana.uuid).to.eql('5b2de169-2785-441b-ae8c-186a1936b17d');
expect(body.process.uptime_ms).to.be.greaterThan(0);
expect(body.os.uptime_ms).to.be.greaterThan(0);
expect(body.usage).to.be(undefined);
expect(isUUID(body.kibana.uuid)).to.be.ok();
});

// FLAKY: https://github.com/elastic/kibana/issues/29254
it.skip('should return 401 for extended', async () => {
await supertestNoAuth.get('/api/stats?extended').expect(401); // unauthorized
it('should return 401 for extended', async () => {
await supertestNoAuth.get('/api/stats?extended').expect(401);
});
});

describe('with auth', () => {
it('should return 200 and stats for no extended', async () => {
const { body } = await supertest.get('/api/stats').expect(200);
expect(body.kibana.uuid).to.eql('5b2de169-2785-441b-ae8c-186a1936b17d');
expect(body.process.uptime_ms).to.be.greaterThan(0);
expect(body.os.uptime_ms).to.be.greaterThan(0);
expect(isUUID(body.kibana.uuid)).to.be.ok();
});

it('should return 200 for extended', async () => {
const { body } = await supertest.get('/api/stats?extended').expect(200);
expect(body.kibana.uuid).to.eql('5b2de169-2785-441b-ae8c-186a1936b17d');
expect(body.process.uptime_ms).to.be.greaterThan(0);
expect(body.os.uptime_ms).to.be.greaterThan(0);
expect(body.usage.kibana.index).to.be('.kibana');
expect(body.usage.kibana.dashboard.total).to.be(0);
expect(isUUID(body.kibana.uuid)).to.be.ok();
});

it('should return 200 for extended and legacy', async () => {
const { body } = await supertest.get('/api/stats?extended&legacy').expect(200);
expect(body.kibana.uuid).to.eql('5b2de169-2785-441b-ae8c-186a1936b17d');
expect(body.process.uptime_ms).to.be.greaterThan(0);
expect(body.os.uptime_ms).to.be.greaterThan(0);
expect(body.usage.index).to.be('.kibana');
expect(body.usage.dashboard.total).to.be(0);
expect(body.usage.xpack.reporting.available).to.be(true);
expect(isUUID(body.kibana.uuid)).to.be.ok();
});
});
});
Expand Down

0 comments on commit 5ab3e19

Please sign in to comment.