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

Dashboard V0->V1 Migration: Schema migration v39 #99631

Merged
merged 5 commits into from
Feb 5, 2025

Conversation

ivanortegaalba
Copy link
Contributor

I took #99392 as a reference.

I ported the migration for v39. This migration updates the configuration of the timeSeriesTable transformation to support new options. This is the PR implementing these changes in the JS migrator.

I'm not using DashboardSpec in Go since this would involve a lot of typing, which is not available nowadays. I don't know how to face this issue for coming PRs. In the end, v1 should use a defined type.

@@ -55,3 +55,21 @@ func TestGetSchemaVersion(t *testing.T) {
})
}
}

type migrationTestCase struct {
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 moved it here, to be reusable by the different vXX_test.go files.

Comment on lines +90 to +100
"transformations": [
{
"id": "timeSeriesTable",
"options": {
"refIdToStat": {
"A": "mean",
"B": "max"
}
}
}
],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the transformation that should be migrated

Comment on lines +123 to +138
"transformations": [
{
"id": "timeSeriesTable",
"options": {
"A": {
"stat": "mean"
},
"B": {
"stat": "max"
}
}
}
],
"type": "timeseries"
}
],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the expected result

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this file be created?

Copy link
Member

Choose a reason for hiding this comment

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

do you mean automatically? We can, but I think it may be better to compare to real input/output values from the typescript -- otherwise we run the risk of testing the behavior we wrote, not our target 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ups, sorry to make sure I understood.

The input value is a dashboard that could be fetched from the DB in version X. For example, in case pkg/apis/dashboard/migration/testdata/output/39.refresh_true.39.json, the input file is in version 39, and it will not change after the v39 migration is executed.

However, I experienced that the output is automatically generated, so I assumed it is a "Snapshot testing" where we create the output the first time and ensure it is the correct one. Then, it stays there to make sure no other migration breaks it.

In this context, why introduce the "input/output from typescript" here? Should we add the output JSON file as the result of the DashboardMigrator.updateSchema()? I was using the output as the result of the migration, it will be compared against for following test runs.

Copy link
Member

Choose a reason for hiding this comment

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

The behavior is entirely our choice and whatever makes this easiest/best to develop+maintain :)

The line that generates the snapshot is:
https://github.com/grafana/grafana/blob/main/pkg/apis/dashboard/migration/migrate_test.go#L73
we can choose to keep that or not

@ivanortegaalba ivanortegaalba marked this pull request as ready for review January 28, 2025 14:30
@ivanortegaalba ivanortegaalba requested a review from a team as a code owner January 28, 2025 14:30
@github-actions github-actions bot added this to the 11.5.x milestone Jan 28, 2025
@ivanortegaalba ivanortegaalba added no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes labels Jan 28, 2025
Copy link
Member

@dprokop dprokop left a comment

Choose a reason for hiding this comment

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

all crystal clear!

@ivanortegaalba ivanortegaalba merged commit d53b269 into main Feb 5, 2025
14 checks passed
@ivanortegaalba ivanortegaalba deleted the iortega/migration-v39-dashboard-v0-v1 branch February 5, 2025 12:50
@github-actions github-actions bot modified the milestones: 11.5.x, 11.6.x Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/backend area/dashboard no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes type/tech
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants