-
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 integration test tracking changes performed on all SO types migration metadata #142306
Add integration test tracking changes performed on all SO types migration metadata #142306
Conversation
name: soType.name, | ||
namespaceType: soType.namespaceType, | ||
convertToAliasScript: soType.convertToAliasScript, | ||
convertToMultiNamespaceTypeVersion: soType.convertToMultiNamespaceTypeVersion, | ||
migrationVersions, | ||
schemaVersions, | ||
mappings: getFlattenedObject(soType.mappings ?? {}), | ||
hasExcludeOnUpgrade: !!soType.excludeOnUpgrade, |
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.
These are the fields used for the hashing.
Ideally we would use the 'content' of functions like excludeOnUpgrade
or the registered migration functions, but functions can't safely be serialized because of the transpiler (also depends on the nodejs version), so we will have to do without it.
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.
functions can't safely be serialized because of the transpiler
Yeah that's too bad -- we already pin to specific TS & Node versions and could theoretically update these hashes whenever we perform an upgrade, however I think Babel would be the main issue (we don't pin to a specific Babel version AFAIK).
We're probably fine having this be the one hole in our test... We've seen people do things like mess with already-shipped migration functions before, and it would be good to catch that, but at this point seems impractical to hold up this PR in an attempt to solve for that. This PR will still cover the vast majority of SO-related upgrade problems we've seen in the past.
const hashParts = [ | ||
migInfo.name, | ||
migInfo.namespaceType, | ||
migInfo.convertToAliasScript ?? 'none', | ||
migInfo.hasExcludeOnUpgrade, | ||
migInfo.convertToMultiNamespaceTypeVersion ?? 'none', | ||
migInfo.migrationVersions.join(','), | ||
migInfo.schemaVersions.join(','), | ||
JSON.stringify(migInfo.mappings, Object.keys(migInfo.mappings).sort()), | ||
]; | ||
const hashFeed = hashParts.join('-'); |
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.
And this is the hashing logic.
expect(hashMap).toMatchInlineSnapshot(` | ||
Object { | ||
"action": "7858e6d5a9f231bf23f6f2e57328eb0095b26735", | ||
"action_task_params": "bbd38cbfd74bf6713586fe078e3fa92db2234299", | ||
"alert": "48461f3375d9ba22882ea23a318b62a5b0921a9b", | ||
"api_key_pending_invalidation": "9b4bc1235337da9a87ef05a1d1f4858b2a3b77c6", | ||
"apm-indices": "ceb0870f3a74e2ffc3a1cd3a3c73af76baca0999", | ||
"apm-server-schema": "2bfd2998d3873872e1366458ce553def85418f91", |
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.
So, we can't use dynamic snapshot easily to have one snapshot per type, at least not if we want to keep the snapshot inline (and even with non-inline, looping has its flaws)
So I had two options here:
- use a single snapshot for all types
- not use snapshot at all, and have a manually maintained map in the test field.
2.
would have helped to have a more explicit error message (we could throw something like the comment at the top of the test), however the main upside I see with 1.
is that we can eventually, as a follow-up, run this test with -u
as a pre-run CI task (like it's already done for linting or codeowners file update). If we achieve this, it would avoid the PR author to do anything manually. CI would simply run the test with -u
, update the snapshot, push the change, which would trigger our review.
This is for this reason (even if not implemented in current PR, we will have a follow-up for that) that I went with the 'big single snapshot' approach.
# Reviewing SavedObject PRs | ||
|
||
## How do SO type automatic review assignment works? | ||
|
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.
Input / comments / addition very welcome for this document.
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.
Added a handful of nits/ideas for the docs. Feel free to take whichever ones you think are useful, and leave out the rest.
Otherwise the test itself LGTM and I think the approach is straightforward and should work well. It's a bummer we can't count on consistent hashes for serialized function bodies, but I don't think that would be an easy problem to solve, and doesn't feel like something we should delay this PR over.
name: soType.name, | ||
namespaceType: soType.namespaceType, | ||
convertToAliasScript: soType.convertToAliasScript, | ||
convertToMultiNamespaceTypeVersion: soType.convertToMultiNamespaceTypeVersion, | ||
migrationVersions, | ||
schemaVersions, | ||
mappings: getFlattenedObject(soType.mappings ?? {}), | ||
hasExcludeOnUpgrade: !!soType.excludeOnUpgrade, |
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.
functions can't safely be serialized because of the transpiler
Yeah that's too bad -- we already pin to specific TS & Node versions and could theoretically update these hashes whenever we perform an upgrade, however I think Babel would be the main issue (we don't pin to a specific Babel version AFAIK).
We're probably fine having this be the one hole in our test... We've seen people do things like mess with already-shipped migration functions before, and it would be good to catch that, but at this point seems impractical to hold up this PR in an attempt to solve for that. This PR will still cover the vast majority of SO-related upgrade problems we've seen in the past.
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Unknown metric groupsAPI count
History
To update your PR or re-run it, just comment with: |
…tion metadata (elastic#142306) * create empty test helper package * create extractor * create hash extraction logic * fix pkg names * actually create the test * updating README * [CI] Auto-commit changed files from 'node scripts/generate codeowners' * [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' * documentation draft * add more fields and update snapshot * update review doc * update review documentation * more feedback * updating snapshot Co-authored-by: kibanamachine <[email protected]>
…tion metadata (elastic#142306) * create empty test helper package * create extractor * create hash extraction logic * fix pkg names * actually create the test * updating README * [CI] Auto-commit changed files from 'node scripts/generate codeowners' * [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' * documentation draft * add more fields and update snapshot * update review doc * update review documentation * more feedback * updating snapshot Co-authored-by: kibanamachine <[email protected]>
Summary
Fix #104100