mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[eem] _count guards against no valid sources (#204224)
The query generation expects at least 1 source to be passed
This commit is contained in:
parent
7e4e8592f4
commit
9a8ed0d135
2 changed files with 46 additions and 1 deletions
|
@ -144,6 +144,10 @@ export class EntityClient {
|
|||
errors: results.filter(isRejectedResult).map((result) => result.reason.message as string),
|
||||
}));
|
||||
|
||||
if (validSources.length === 0) {
|
||||
return { type, value: 0, errors };
|
||||
}
|
||||
|
||||
const { query, filter } = getEntityCountQuery({
|
||||
sources: validSources,
|
||||
filters,
|
||||
|
|
|
@ -361,7 +361,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
});
|
||||
});
|
||||
|
||||
it('is resilient to invalid sources', async () => {
|
||||
it('is resilient to partially valid sources', async () => {
|
||||
await createEntityTypeDefinition(supertest, {
|
||||
type: { id: 'chumble', display_name: 'chumble' },
|
||||
});
|
||||
|
@ -417,5 +417,46 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('is resilient to no valid sources', async () => {
|
||||
await createEntityTypeDefinition(supertest, {
|
||||
type: { id: 'chumble', display_name: 'chumble' },
|
||||
});
|
||||
await Promise.all([
|
||||
createEntitySourceDefinition(supertest, {
|
||||
source: {
|
||||
id: 'source1-with-chumbles',
|
||||
type_id: 'chumble',
|
||||
index_patterns: ['index-1-with-chumbles'],
|
||||
identity_fields: ['service.name'],
|
||||
metadata_fields: [],
|
||||
filters: [],
|
||||
},
|
||||
}),
|
||||
createEntitySourceDefinition(supertest, {
|
||||
source: {
|
||||
id: 'source2-with-chumbles',
|
||||
type_id: 'chumble',
|
||||
index_patterns: ['index-2-with-chumbles'],
|
||||
identity_fields: ['service.name'],
|
||||
metadata_fields: [],
|
||||
filters: [],
|
||||
},
|
||||
}),
|
||||
]);
|
||||
|
||||
const result = await countEntities(supertest, {}, 200);
|
||||
|
||||
expect(result).toEqual({
|
||||
total: 0,
|
||||
types: {
|
||||
chumble: 0,
|
||||
},
|
||||
errors: [
|
||||
'No index found for source [source: source1-with-chumbles, type: chumble] with index patterns [index-1-with-chumbles]',
|
||||
'No index found for source [source: source2-with-chumbles, type: chumble] with index patterns [index-2-with-chumbles]',
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue