[savedObjects] Use index template (#14271)

* [es][savedObjects/index] put template on each savedObject write

The elasticsearch plugin currently checks for the Kibana index on each iteration of the healthCheck, and creates it if it does not exist. This removes that step from the healthCheck and instead, before each savedObject is written to elasticsearch, ensures that Elasticsearch has the necessary index template should the write result in index creation.

The healthCheck still has the `patchKibanaIndex()` logic, which checks the type in the Kibana index and adds any missing types. This step now does nothing when the Kibana index does not exist, and does what it has always done when it does.

* [ftr] remove unused kibanaIndex service

(cherry picked from commit b1ef897dafeb6d43fe279776e44a9d793a389dc3)

* [savedObjects/integration] create now creates kibana index

* [es/healthCheck] remove use of format()

* [es/healthCheck/tests] use sinon assertions

* [es/patchKibanaIndex] test for kibana index missing behavior

* [savedObjects/errors] add tests for EsAutoCreateIndexError

* [savedObjects/config] deprecate and remove savedObjects.indexCheckTimeout config

* use dangling commas consistently

* [ui/error_auto_create_index] fix class names

* [ui/savedObjectsClient] no need to specify basePath

* [eslint] fix linting issue
This commit is contained in:
Spencer 2017-11-21 17:05:46 -07:00 committed by GitHub
parent cd1a49c392
commit 90e2aa001b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 422 additions and 439 deletions

View file

@ -47,7 +47,7 @@ export default function ({ getService }) {
})
));
it('should return 503 and not create kibana index', async () => {
it('should return 200 and create kibana index', async () => {
await supertest
.post(`/api/saved_objects/visualization`)
.send({
@ -55,22 +55,27 @@ export default function ({ getService }) {
title: 'My favorite vis'
}
})
.expect(503)
.expect(200)
.then(resp => {
// loose uuid validation
expect(resp.body).to.have.property('id').match(/^[0-9a-f-]{36}$/);
// loose ISO8601 UTC time with milliseconds validation
expect(resp.body).to.have.property('updated_at').match(/^[\d-]{10}T[\d:\.]{12}Z$/);
expect(resp.body).to.eql({
error: 'Service Unavailable',
statusCode: 503,
message: 'Service Unavailable'
id: resp.body.id,
type: 'visualization',
updated_at: resp.body.updated_at,
version: 1,
attributes: {
title: 'My favorite vis'
}
});
});
const index = await es.indices.get({
index: '.kibana',
ignore: [404]
});
expect(index).to.have.property('status', 404);
expect(await es.indices.exists({ index: '.kibana' }))
.to.be(true);
});
});
});