From 8735b4626b8daaec8f06c3e7311c755201a2dcb1 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Tue, 17 Nov 2020 22:14:32 +0000 Subject: [PATCH] Functional tests - fix esArchive mappings with runtime fields (#83530) (#83581) * Functional tests - fix esArchive mappings with runtime fields * Modify jenkinsfile to run with unverified ES snapshot * Adjust security index fields test for the new mapping structure Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Robert Oskamp Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- Jenkinsfile | 1 + .../apis/security/index_fields.ts | 28 +++++++-------- .../logstash_functional/mappings.json | 35 ++++++++++--------- .../security/flstest/data/mappings.json | 17 ++++----- 4 files changed, 41 insertions(+), 40 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3b68cde206573..e33bf67f28df5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,6 @@ #!/bin/groovy +env.KBN_ES_SNAPSHOT_USE_UNVERIFIED = 'true' library 'kibana-pipeline-library' kibanaLibrary.load() diff --git a/x-pack/test/api_integration/apis/security/index_fields.ts b/x-pack/test/api_integration/apis/security/index_fields.ts index 193d0eea1590e..b0462143a8ad4 100644 --- a/x-pack/test/api_integration/apis/security/index_fields.ts +++ b/x-pack/test/api_integration/apis/security/index_fields.ts @@ -6,15 +6,17 @@ import expect from '@kbn/expect/expect.js'; import { FtrProviderContext } from '../../ftr_provider_context'; - -interface FLSFieldMappingResponse { +interface FLSMappingResponse { flstest: { mappings: { - [fieldName: string]: { - mapping: { - [fieldName: string]: { - type: string; - }; + runtime?: { + [fieldName: string]: { + type: string; + }; + }; + properties: { + [fieldName: string]: { + type: string; }; }; }; @@ -56,16 +58,10 @@ export default function ({ getService }: FtrProviderContext) { it('should not include runtime fields', async () => { // First, make sure the mapping actually includes a runtime field - const fieldMapping = (await es.indices.getFieldMapping({ - index: 'flstest', - fields: '*', - includeDefaults: true, - })) as FLSFieldMappingResponse; + const mapping = (await es.indices.getMapping({ index: 'flstest' })) as FLSMappingResponse; - expect(Object.keys(fieldMapping.flstest.mappings)).to.contain('runtime_customer_ssn'); - expect( - fieldMapping.flstest.mappings.runtime_customer_ssn.mapping.runtime_customer_ssn.type - ).to.eql('runtime'); + expect(Object.keys(mapping.flstest.mappings)).to.contain('runtime'); + expect(Object.keys(mapping.flstest.mappings.runtime!)).to.contain('runtime_customer_ssn'); // Now, make sure it's not returned here const { body: actualFields } = (await supertest diff --git a/x-pack/test/functional/es_archives/logstash_functional/mappings.json b/x-pack/test/functional/es_archives/logstash_functional/mappings.json index ee7feedd77530..12853523615bd 100644 --- a/x-pack/test/functional/es_archives/logstash_functional/mappings.json +++ b/x-pack/test/functional/es_archives/logstash_functional/mappings.json @@ -19,6 +19,12 @@ } } ], + "runtime": { + "runtime_number": { + "type": "long", + "script" : { "source" : "emit(doc['bytes'].value)" } + } + }, "properties": { "@message": { "fields": { @@ -342,11 +348,6 @@ } }, "type": "text" - }, - "runtime_number": { - "type": "runtime", - "runtime_type" : "long", - "script" : { "source" : "emit(doc['bytes'].value)" } } } }, @@ -389,6 +390,12 @@ } } ], + "runtime": { + "runtime_number": { + "type": "long", + "script" : { "source" : "emit(doc['bytes'].value)" } + } + }, "properties": { "@message": { "fields": { @@ -712,11 +719,6 @@ } }, "type": "text" - }, - "runtime_number": { - "type": "runtime", - "runtime_type" : "long", - "script" : { "source" : "emit(doc['bytes'].value)" } } } }, @@ -759,6 +761,12 @@ } } ], + "runtime": { + "runtime_number": { + "type": "long", + "script" : { "source" : "emit(doc['bytes'].value)" } + } + }, "properties": { "@message": { "fields": { @@ -1082,11 +1090,6 @@ } }, "type": "text" - }, - "runtime_number": { - "type": "runtime", - "runtime_type" : "long", - "script" : { "source" : "emit(doc['bytes'].value)" } } } }, @@ -1106,4 +1109,4 @@ } } } -} \ No newline at end of file +} diff --git a/x-pack/test/functional/es_archives/security/flstest/data/mappings.json b/x-pack/test/functional/es_archives/security/flstest/data/mappings.json index 3605533618a93..4f419e4b6ade4 100644 --- a/x-pack/test/functional/es_archives/security/flstest/data/mappings.json +++ b/x-pack/test/functional/es_archives/security/flstest/data/mappings.json @@ -3,6 +3,14 @@ "value": { "index": "flstest", "mappings": { + "runtime": { + "runtime_customer_ssn": { + "type": "keyword", + "script": { + "source": "emit(doc['customer_ssn'].value + ' calculated at runtime')" + } + } + }, "properties": { "customer_name": { "fields": { @@ -30,13 +38,6 @@ } }, "type": "text" - }, - "runtime_customer_ssn": { - "type": "runtime", - "runtime_type": "keyword", - "script": { - "source": "emit(doc['customer_ssn'].value + ' calculated at runtime')" - } } } }, @@ -47,4 +48,4 @@ } } } -} \ No newline at end of file +}