Skip to content

Commit

Permalink
Functional tests - fix esArchive mappings with runtime fields (#83530) (
Browse files Browse the repository at this point in the history
#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 <[email protected]>

Co-authored-by: Robert Oskamp <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
3 people authored Nov 17, 2020
1 parent b4b3e0c commit 8735b46
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 40 deletions.
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/groovy

env.KBN_ES_SNAPSHOT_USE_UNVERIFIED = 'true'
library 'kibana-pipeline-library'
kibanaLibrary.load()

Expand Down
28 changes: 12 additions & 16 deletions x-pack/test/api_integration/apis/security/index_fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
};
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
}
}
],
"runtime": {
"runtime_number": {
"type": "long",
"script" : { "source" : "emit(doc['bytes'].value)" }
}
},
"properties": {
"@message": {
"fields": {
Expand Down Expand Up @@ -342,11 +348,6 @@
}
},
"type": "text"
},
"runtime_number": {
"type": "runtime",
"runtime_type" : "long",
"script" : { "source" : "emit(doc['bytes'].value)" }
}
}
},
Expand Down Expand Up @@ -389,6 +390,12 @@
}
}
],
"runtime": {
"runtime_number": {
"type": "long",
"script" : { "source" : "emit(doc['bytes'].value)" }
}
},
"properties": {
"@message": {
"fields": {
Expand Down Expand Up @@ -712,11 +719,6 @@
}
},
"type": "text"
},
"runtime_number": {
"type": "runtime",
"runtime_type" : "long",
"script" : { "source" : "emit(doc['bytes'].value)" }
}
}
},
Expand Down Expand Up @@ -759,6 +761,12 @@
}
}
],
"runtime": {
"runtime_number": {
"type": "long",
"script" : { "source" : "emit(doc['bytes'].value)" }
}
},
"properties": {
"@message": {
"fields": {
Expand Down Expand Up @@ -1082,11 +1090,6 @@
}
},
"type": "text"
},
"runtime_number": {
"type": "runtime",
"runtime_type" : "long",
"script" : { "source" : "emit(doc['bytes'].value)" }
}
}
},
Expand All @@ -1106,4 +1109,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -30,13 +38,6 @@
}
},
"type": "text"
},
"runtime_customer_ssn": {
"type": "runtime",
"runtime_type": "keyword",
"script": {
"source": "emit(doc['customer_ssn'].value + ' calculated at runtime')"
}
}
}
},
Expand All @@ -47,4 +48,4 @@
}
}
}
}
}

0 comments on commit 8735b46

Please sign in to comment.