[Data Views] Fix flaky test #156129 (#160472)

Resolves: #156129.

Flaky test runs:
- x100:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2472
🟥
- x100:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2487
This commit is contained in:
Davis McPhee 2023-06-29 11:52:51 -03:00 committed by GitHub
parent d9744464dc
commit 6310e8c6fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,6 +6,11 @@
* Side Public License, v 1.
*/
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
import {
INITIAL_REST_VERSION,
INITIAL_REST_VERSION_INTERNAL,
} from '@kbn/data-views-plugin/server/constants';
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../ftr_provider_context';
import { configArray } from '../constants';
@ -15,8 +20,7 @@ export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const es = getService('es');
// FLAKY: https://github.com/elastic/kibana/issues/156129
describe.skip('has user index pattern API', () => {
describe('has user index pattern API', () => {
configArray.forEach((config) => {
describe(config.name, () => {
beforeEach(async () => {
@ -33,7 +37,11 @@ export default function ({ getService }: FtrProviderContext) {
const servicePath = `${config.basePath}/has_user_${config.serviceKey}`;
it('should return false if no index patterns', async () => {
const response = await supertest.get(servicePath);
// Make sure all saved objects including data views are cleared
await esArchiver.emptyKibanaIndex();
const response = await supertest
.get(servicePath)
.set(ELASTIC_HTTP_VERSION_HEADER, INITIAL_REST_VERSION_INTERNAL);
expect(response.status).to.be(200);
expect(response.body.result).to.be(false);
});
@ -42,14 +50,19 @@ export default function ({ getService }: FtrProviderContext) {
await esArchiver.load(
'test/api_integration/fixtures/es_archiver/index_patterns/basic_index'
);
await supertest.post(config.path).send({
override: true,
[config.serviceKey]: {
title: 'basic_index',
},
});
await supertest
.post(config.path)
.set(ELASTIC_HTTP_VERSION_HEADER, INITIAL_REST_VERSION)
.send({
override: true,
[config.serviceKey]: {
title: 'basic_index',
},
});
const response = await supertest.get(servicePath);
const response = await supertest
.get(servicePath)
.set(ELASTIC_HTTP_VERSION_HEADER, INITIAL_REST_VERSION_INTERNAL);
expect(response.status).to.be(200);
expect(response.body.result).to.be(true);
@ -59,15 +72,20 @@ export default function ({ getService }: FtrProviderContext) {
});
it('should return true if has user index pattern without data', async () => {
await supertest.post(config.path).send({
override: true,
[config.serviceKey]: {
title: 'basic_index',
allowNoIndex: true,
},
});
await supertest
.post(config.path)
.set(ELASTIC_HTTP_VERSION_HEADER, INITIAL_REST_VERSION)
.send({
override: true,
[config.serviceKey]: {
title: 'basic_index',
allowNoIndex: true,
},
});
const response = await supertest.get(servicePath);
const response = await supertest
.get(servicePath)
.set(ELASTIC_HTTP_VERSION_HEADER, INITIAL_REST_VERSION_INTERNAL);
expect(response.status).to.be(200);
expect(response.body.result).to.be(true);
});