Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional tests - fix esArchive mappings with runtime fields #83530

Merged
merged 5 commits into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
}
}
}
}
}