Support api_integration/kibana/stats against remote hosts (#53000)
* 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>
This commit is contained in:
parent
32a7f8134a
commit
5ab3e19e5b
|
@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue