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

Add model version testing section to documentation #168453

Merged

Conversation

pgayvallet
Copy link
Contributor

@pgayvallet pgayvallet commented Oct 10, 2023

Summary

Follow-up of #167501 and #167861

Add section in the model version documentation about testing plan

@pgayvallet pgayvallet added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc release_note:skip Skip the PR/issue when compiling release notes v8.12.0 labels Oct 10, 2023
@pgayvallet pgayvallet marked this pull request as ready for review October 10, 2023 11:36
@pgayvallet pgayvallet requested a review from a team as a code owner October 10, 2023 11:36
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

Copy link
Member

@afharo afharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just 1 nit

Comment on lines 914 to 938
describe('Model version 2', () => {
it('properly backfill the expected fields when converting from v1 to v2', () => {
const obj = createSomeSavedObject();

const migrated = migrator.migrate({
document: obj,
fromVersion: 1,
toVersion: 2,
});

expect(migrated.properties).toEqual(myExpectedProperties);
});

it('properly removes the expected fields when converting from v2 to v1', () => {
const obj = createSomeSavedObject();

const migrated = migrator.migrate({
document: obj,
fromVersion: 2,
toVersion: 1,
});

expect(migrated.properties).toEqual(myExpectedProperties);
});
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For best practices, should we recommend having a global myExpectedProperties for each version so that we can test symmetric migrations (when possible)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say it's probably a developer's preference? e.g I usually use different documents / attributes between different tests (just to increase the potential branch coverage), so I think I would be using different attributes when testing the up and down parts of the migration 😄

@pgayvallet pgayvallet merged commit 9b59e84 into elastic:main Oct 11, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Oct 11, 2023
dej611 pushed a commit to dej611/kibana that referenced this pull request Oct 17, 2023
## Summary

Follow-up of elastic#167501 and elastic#167861

Add section in the model version documentation about testing plan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants