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 <robert.oskamp@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Tiago Costa 2020-11-17 22:14:32 +00:00 committed by GitHub
parent b4b3e0ca40
commit 8735b4626b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 40 deletions

1
Jenkinsfile vendored
View file

@ -1,5 +1,6 @@
#!/bin/groovy
env.KBN_ES_SNAPSHOT_USE_UNVERIFIED = 'true'
library 'kibana-pipeline-library'
kibanaLibrary.load()

View file

@ -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

View file

@ -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 @@
}
}
}
}
}

View file

@ -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 @@
}
}
}
}
}