Skip to content

Commit

Permalink
Fixed typo and modified upgrade test for assessment report
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyamsinghal committed Jan 9, 2025
1 parent 9869d5c commit de90d2c
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 41 deletions.
2 changes: 1 addition & 1 deletion migtests/scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ normalize_json() {
.OptimalSelectConnectionsPerNode? = "IGNORED" |
.OptimalInsertConnectionsPerNode? = "IGNORED" |
.RowCount? = "IGNORED" |
.MigrationComplexityExplaination?= "IGNORED" |
.MigrationComplexityExplanation?= "IGNORED" |
# Replace newline characters in SqlStatement with spaces
.SqlStatement? |= (
if type == "string" then
Expand Down
6 changes: 3 additions & 3 deletions yb-voyager/cmd/assessMigrationCommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -1605,11 +1605,11 @@ func generateAssessmentReportJson(reportDir string) error {
log.Infof("writing assessment report to file: %s", jsonReportFilePath)

var err error
assessmentReport.MigrationComplexityExplaination, err = buildMigrationComplexityExplaination(source.DBType, assessmentReport, "")
assessmentReport.MigrationComplexityExplanation, err = buildMigrationComplexityExplanation(source.DBType, assessmentReport, "")
if err != nil {
utils.PrintAndLog("ERROR: unable to build migration complexity explanation for json report: %v", err)
}
log.Info(assessmentReport.MigrationComplexityExplaination)
log.Info(assessmentReport.MigrationComplexityExplanation)

strReport, err := json.MarshalIndent(assessmentReport, "", "\t")
if err != nil {
Expand All @@ -1630,7 +1630,7 @@ func generateAssessmentReportHtml(reportDir string) error {
log.Infof("writing assessment report to file: %s", htmlReportFilePath)

var err error
assessmentReport.MigrationComplexityExplaination, err = buildMigrationComplexityExplaination(source.DBType, assessmentReport, "html")
assessmentReport.MigrationComplexityExplanation, err = buildMigrationComplexityExplanation(source.DBType, assessmentReport, "html")
if err != nil {
utils.PrintAndLog("ERROR: unable to build migration complexity explanation for html report: %v", err)
}
Expand Down
18 changes: 9 additions & 9 deletions yb-voyager/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -1051,15 +1051,15 @@ func storeTableListInMSR(tableList []sqlname.NameTuple) error {

// TODO: consider merging all unsupported field with single AssessmentReport struct member as AssessmentIssue
type AssessmentReport struct {
VoyagerVersion string `json:"VoyagerVersion"`
TargetDBVersion *ybversion.YBVersion `json:"TargetDBVersion"`
MigrationComplexity string `json:"MigrationComplexity"`
MigrationComplexityExplaination string `json:"MigrationComplexityExplaination"`
SchemaSummary utils.SchemaSummary `json:"SchemaSummary"`
Sizing *migassessment.SizingAssessmentReport `json:"Sizing"`
Issues []AssessmentIssue `json:"-"` // disabled in reports till corresponding UI changes are done(json and html reports)
TableIndexStats *[]migassessment.TableIndexStats `json:"TableIndexStats"`
Notes []string `json:"Notes"`
VoyagerVersion string `json:"VoyagerVersion"`
TargetDBVersion *ybversion.YBVersion `json:"TargetDBVersion"`
MigrationComplexity string `json:"MigrationComplexity"`
MigrationComplexityExplanation string `json:"MigrationComplexityExplanation"`
SchemaSummary utils.SchemaSummary `json:"SchemaSummary"`
Sizing *migassessment.SizingAssessmentReport `json:"Sizing"`
Issues []AssessmentIssue `json:"-"` // disabled in reports till corresponding UI changes are done(json and html reports)
TableIndexStats *[]migassessment.TableIndexStats `json:"TableIndexStats"`
Notes []string `json:"Notes"`

// fields going to be deprecated
UnsupportedDataTypes []utils.TableColumnsDataTypes `json:"UnsupportedDataTypes"`
Expand Down
40 changes: 21 additions & 19 deletions yb-voyager/cmd/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,22 @@ func TestAssessmentReportStructs(t *testing.T) {
name: "Validate AssessmentReport Struct Definition",
actualType: reflect.TypeOf(AssessmentReport{}),
expectedType: struct {
VoyagerVersion string `json:"VoyagerVersion"`
TargetDBVersion *ybversion.YBVersion `json:"TargetDBVersion"`
MigrationComplexity string `json:"MigrationComplexity"`
SchemaSummary utils.SchemaSummary `json:"SchemaSummary"`
Sizing *migassessment.SizingAssessmentReport `json:"Sizing"`
Issues []AssessmentIssue `json:"-"`
TableIndexStats *[]migassessment.TableIndexStats `json:"TableIndexStats"`
Notes []string `json:"Notes"`
UnsupportedDataTypes []utils.TableColumnsDataTypes `json:"UnsupportedDataTypes"`
UnsupportedDataTypesDesc string `json:"UnsupportedDataTypesDesc"`
UnsupportedFeatures []UnsupportedFeature `json:"UnsupportedFeatures"`
UnsupportedFeaturesDesc string `json:"UnsupportedFeaturesDesc"`
UnsupportedQueryConstructs []utils.UnsupportedQueryConstruct `json:"UnsupportedQueryConstructs"`
UnsupportedPlPgSqlObjects []UnsupportedFeature `json:"UnsupportedPlPgSqlObjects"`
MigrationCaveats []UnsupportedFeature `json:"MigrationCaveats"`
VoyagerVersion string `json:"VoyagerVersion"`
TargetDBVersion *ybversion.YBVersion `json:"TargetDBVersion"`
MigrationComplexity string `json:"MigrationComplexity"`
MigrationComplexityExplanation string `json:"MigrationComplexityExplanation"`
SchemaSummary utils.SchemaSummary `json:"SchemaSummary"`
Sizing *migassessment.SizingAssessmentReport `json:"Sizing"`
Issues []AssessmentIssue `json:"-"`
TableIndexStats *[]migassessment.TableIndexStats `json:"TableIndexStats"`
Notes []string `json:"Notes"`
UnsupportedDataTypes []utils.TableColumnsDataTypes `json:"UnsupportedDataTypes"`
UnsupportedDataTypesDesc string `json:"UnsupportedDataTypesDesc"`
UnsupportedFeatures []UnsupportedFeature `json:"UnsupportedFeatures"`
UnsupportedFeaturesDesc string `json:"UnsupportedFeaturesDesc"`
UnsupportedQueryConstructs []utils.UnsupportedQueryConstruct `json:"UnsupportedQueryConstructs"`
UnsupportedPlPgSqlObjects []UnsupportedFeature `json:"UnsupportedPlPgSqlObjects"`
MigrationCaveats []UnsupportedFeature `json:"MigrationCaveats"`
}{},
},
}
Expand All @@ -165,9 +166,10 @@ func TestAssessmentReportJson(t *testing.T) {
}

assessmentReport = AssessmentReport{
VoyagerVersion: "v1.0.0",
TargetDBVersion: newYbVersion,
MigrationComplexity: "High",
VoyagerVersion: "v1.0.0",
TargetDBVersion: newYbVersion,
MigrationComplexity: "High",
MigrationComplexityExplanation: "",
SchemaSummary: utils.SchemaSummary{
Description: "Test Schema Summary",
DBName: "test_db",
Expand Down Expand Up @@ -302,12 +304,12 @@ func TestAssessmentReportJson(t *testing.T) {
if err != nil {
t.Fatalf("Failed to write assessment report to JSON file: %v", err)
}

// expected JSON
expectedJSON := `{
"VoyagerVersion": "v1.0.0",
"TargetDBVersion": "2024.1.1.1",
"MigrationComplexity": "High",
"MigrationComplexityExplanation": "",
"SchemaSummary": {
"Description": "Test Schema Summary",
"DbName": "test_db",
Expand Down
14 changes: 7 additions & 7 deletions yb-voyager/cmd/migration_complexity.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ const explainTemplateHTML = `

const explainTemplateText = `Reasoning: {{ .ComplexityRationale }}`

type ExplainationData struct {
type ExplanationData struct {
Summaries []CategorySummary
ComplexityRationale string // short reasoning or explanation text
}
Expand All @@ -261,15 +261,15 @@ type CategorySummary struct {
ImpactCounts map[string]int // e.g. {"Level-1": 3, "Level-2": 5, "Level-3": 2}
}

func buildMigrationComplexityExplaination(sourceDBType string, assessmentReport AssessmentReport, reportFormat string) (string, error) {
func buildMigrationComplexityExplanation(sourceDBType string, assessmentReport AssessmentReport, reportFormat string) (string, error) {
if sourceDBType != POSTGRESQL {
return "", nil
}

var explaination ExplainationData
explaination.ComplexityRationale = migrationComplexityRationale
var explanation ExplanationData
explanation.ComplexityRationale = migrationComplexityRationale

explaination.Summaries = buildCategorySummary(assessmentReport.Issues)
explanation.Summaries = buildCategorySummary(assessmentReport.Issues)

var tmpl *template.Template
var err error
Expand All @@ -280,11 +280,11 @@ func buildMigrationComplexityExplaination(sourceDBType string, assessmentReport
}

if err != nil {
return "", fmt.Errorf("failed creating the explaination template: %w", err)
return "", fmt.Errorf("failed creating the explanation template: %w", err)
}

var buf bytes.Buffer
if err := tmpl.Execute(&buf, explaination); err != nil {
if err := tmpl.Execute(&buf, explanation); err != nil {
return "", fmt.Errorf("failed executing the template with data: %w", err)
}
return buf.String(), nil
Expand Down
4 changes: 2 additions & 2 deletions yb-voyager/cmd/templates/migration_assessment_report.template
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@
{{end}}

{{if ne .MigrationComplexity "NOT AVAILABLE"}}
<h2>Migration Complexity Explaination</h2>
<p>{{ .MigrationComplexityExplaination }}</p>
<h2>Migration Complexity Explanation</h2>
<p>{{ .MigrationComplexityExplanation }}</p>
{{end}}

<h2>Unsupported Data Types</h2>
Expand Down

0 comments on commit de90d2c

Please sign in to comment.