-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into security/tests/assignments-flaky-tests
- Loading branch information
Showing
119 changed files
with
2,184 additions
and
649 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -523,6 +523,7 @@ | |
"hosts", | ||
"is_default", | ||
"is_default_monitoring", | ||
"is_internal", | ||
"is_preconfigured", | ||
"key", | ||
"name", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/plugins/data_views/server/rest_api_routes/internal/utils.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { getIndexFilterDsl } from './utils'; | ||
|
||
describe('getIndexFilterDsl', () => { | ||
const indexFilter = { term: { _id: '1' } }; | ||
const tiersQuery = { | ||
bool: { | ||
must_not: [ | ||
{ | ||
terms: { | ||
_tier: ['data_cold', 'data_frozen'], | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
const excludedTiers = 'data_cold, data_frozen'; | ||
|
||
it('no indexFilter, no excluded tiers', () => { | ||
expect(getIndexFilterDsl({})).toBeUndefined(); | ||
}); | ||
|
||
it('indexFilter, no excluded tiers', () => { | ||
expect(getIndexFilterDsl({ indexFilter })).toEqual(indexFilter); | ||
}); | ||
|
||
it('excluded tiers, no indexFilter', () => { | ||
expect(getIndexFilterDsl({ excludedTiers })).toEqual(tiersQuery); | ||
}); | ||
|
||
it('indexFilter and excluded tiers', () => { | ||
const combinedQuery = { | ||
bool: { | ||
must: [indexFilter, tiersQuery], | ||
}, | ||
}; | ||
|
||
expect(getIndexFilterDsl({ indexFilter, excludedTiers })).toEqual(combinedQuery); | ||
}); | ||
}); |
46 changes: 46 additions & 0 deletions
46
src/plugins/data_views/server/rest_api_routes/internal/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import type { QueryDslQueryContainer } from '../../../common/types'; | ||
|
||
const excludeTiersDsl = (excludedTiers: string) => { | ||
const _tier = excludedTiers.split(',').map((tier) => tier.trim()); | ||
return { | ||
bool: { | ||
must_not: [ | ||
{ | ||
terms: { | ||
_tier, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
}; | ||
|
||
interface GetIndexFilterDslOptions { | ||
indexFilter?: QueryDslQueryContainer; | ||
excludedTiers?: string; | ||
} | ||
|
||
export const getIndexFilterDsl = ({ | ||
indexFilter, | ||
excludedTiers, | ||
}: GetIndexFilterDslOptions): QueryDslQueryContainer | undefined => { | ||
if (!indexFilter) { | ||
return excludedTiers ? excludeTiersDsl(excludedTiers) : undefined; | ||
} | ||
|
||
return !excludedTiers | ||
? indexFilter | ||
: { | ||
bool: { | ||
must: [indexFilter, excludeTiersDsl(excludedTiers)], | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.