-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Add test for detecting new and removed SO types #104507
Add test for detecting new and removed SO types #104507
Conversation
@@ -415,11 +415,31 @@ describe('ElasticIndex', () => { | |||
query: { | |||
bool: { | |||
must_not: [ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test probably needs to change so that we don't have to update every time a new type is added to REMOVED_TYPES
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could just import excludeUnusedTypesQuery
for now to assert against, OTOH it would break once we register removed types at runtime, so...
86e6dc9
to
a555b9a
Compare
import * as kbnTestServer from '../../../../test_helpers/kbn_server'; | ||
|
||
// Types should NEVER be removed from this array | ||
const previouslyRegisteredTypes = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran this test on all branches from 7.7 forward. We can and should do it for the prior 7.x versions but it will take some extra work since the typeRegistry API didn't exist yet. Will do as a follow up.
/** | ||
* Types that are no longer registered and need to be removed | ||
*/ | ||
export const REMOVED_TYPES: string[] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty basic for now, but can be improved in #104246
@@ -149,6 +149,7 @@ export interface SavedObjectsServiceSetup { | |||
*/ | |||
export interface InternalSavedObjectsServiceSetup extends SavedObjectsServiceSetup { | |||
status$: Observable<ServiceStatus<SavedObjectStatusMeta>>; | |||
getTypeRegistry: () => ISavedObjectTypeRegistry; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not strictly necessary, but makes the test faster since I don't have to wait for start
to complete
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The types are only guaranteed to be registered once all plugins completed their setup, but it's probably fine as long as we keep it internal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I'll just add that to the docstring to make it clear
].sort(); | ||
|
||
describe('SO type registrations', () => { | ||
it('does not remove types from registrations without updating unusedTypesQuery', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pgayvallet any thoughts on this approach before I continue?
a555b9a
to
92ec28b
Compare
Pinging @elastic/kibana-core (Team:Core) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't really like that we need to maintain an hardcoded list in the test file, but I don't see any other option, so I guess it will have to do.
@@ -415,11 +415,31 @@ describe('ElasticIndex', () => { | |||
query: { | |||
bool: { | |||
must_not: [ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could just import excludeUnusedTypesQuery
for now to assert against, OTOH it would break once we register removed types at runtime, so...
src/core/server/saved_objects/migrationsv2/initial_state.test.ts
Outdated
Show resolved
Hide resolved
@@ -149,6 +149,7 @@ export interface SavedObjectsServiceSetup { | |||
*/ | |||
export interface InternalSavedObjectsServiceSetup extends SavedObjectsServiceSetup { | |||
status$: Observable<ServiceStatus<SavedObjectStatusMeta>>; | |||
getTypeRegistry: () => ISavedObjectTypeRegistry; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The types are only guaranteed to be registered once all plugins completed their setup, but it's probably fine as long as we keep it internal
src/core/server/saved_objects/migrationsv2/integration_tests/type_registrations.test.ts
Show resolved
Hide resolved
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
Summary
Fixes #104418
This adds a test that checks that any first-party SO types that are removed are added to our query for documents that should be removed on the next upgrade. In the future, we may explore automating this by only migrating known document types or adding a dedicated API (#104246).
I ran this test against 7.8+ to find any types that have been removed since then and I found these 5 types and added them to the query so they will be filtered out on subsequent upgrades:
apm-services-telemetry
background-session
cases-sub-case
file-upload-telemetry
ml-telemetry
This needs to be backported to 7.14 so that any users with these documents can successfully upgrade.
Checklist
Delete any items that are not applicable to this PR.