Skip to content

Commit

Permalink
tests for issues-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
priyanshi-yb committed Jan 31, 2025
1 parent b2d7b27 commit d0212f7
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
36 changes: 36 additions & 0 deletions yb-voyager/src/query/queryissue/issues_ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,39 @@ ORDER BY name;`)

}

func testCompressionClauseIssue(t *testing.T) {
ctx := context.Background()
conn, err := getConn()
assert.NoError(t, err)

defer conn.Close(context.Background())

_, err = conn.Exec(ctx, `CREATE TABLE tbl_comp1(id int, v text COMPRESSION pglz);`)
//CREATE works on 2.25

var errMsg string
switch {
case testYbVersion.ReleaseType() == ybversion.V2_25_0_0.ReleaseType() && testYbVersion.GreaterThanOrEqual(ybversion.V2_25_0_0):
assert.NoError(t, err)
err = fmt.Errorf("")
errMsg = ""
default:
errMsg = `syntax error at or near "COMPRESSION"`
}
assertErrorCorrectlyThrownForIssueForYBVersion(t, err, errMsg, compressionClauseForToasting)

_, err = conn.Exec(ctx, `ALTER TABLE ONLY public.tbl_comp ALTER COLUMN v SET COMPRESSION pglz;`)
//ALTER not supported in 2.25
switch {
case testYbVersion.ReleaseType() == ybversion.V2_25_0_0.ReleaseType() && testYbVersion.GreaterThanOrEqual(ybversion.V2_25_0_0):
errMsg = "This ALTER TABLE command is not yet supported."
default:
errMsg = `syntax error at or near "COMPRESSION"`
}
assertErrorCorrectlyThrownForIssueForYBVersion(t, err, errMsg, compressionClauseForToasting)

}

func TestDDLIssuesInYBVersion(t *testing.T) {
var err error
ybVersion := os.Getenv("YB_VERSION")
Expand Down Expand Up @@ -535,4 +568,7 @@ func TestDDLIssuesInYBVersion(t *testing.T) {

success = t.Run(fmt.Sprintf("%s-%s", "before row triggers on partitioned table", ybVersion), testBeforeRowTriggerOnPartitionedTable)
assert.True(t, success)

success = t.Run(fmt.Sprintf("%s-%s", "compression clause", ybVersion), testCompressionClauseIssue)
assert.True(t, success)
}
23 changes: 23 additions & 0 deletions yb-voyager/src/query/queryissue/issues_dml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,26 @@ func testEventsListenNotifyIssue(t *testing.T) {
}
}

func testTwoPhaseCommitIssue(t *testing.T) {
ctx := context.Background()
conn, err := getConn()
assert.NoError(t, err)

defer conn.Close(context.Background())

sqls := map[string]string{
`PREPARE TRANSACTION 'tx1';`: `PREPARE TRANSACTION not supported yet`,
`COMMIT PREPARED 'tx1';`: `COMMIT PREPARED not supported yet`,
`ROLLBACK PREPARED 'tx1';`: `ROLLBACK PREPARED not supported yet`,
}
for sql, errMsg := range sqls {

_, err = conn.Exec(ctx, sql)

assertErrorCorrectlyThrownForIssueForYBVersion(t, err, errMsg, twoPhaseCommitIssue)
}
}

func TestDMLIssuesInYBVersion(t *testing.T) {
var err error
ybVersion := os.Getenv("YB_VERSION")
Expand Down Expand Up @@ -483,4 +503,7 @@ func TestDMLIssuesInYBVersion(t *testing.T) {
success = t.Run(fmt.Sprintf("%s-%s", "events listen / notify", ybVersion), testEventsListenNotifyIssue)
assert.True(t, success)

success = t.Run(fmt.Sprintf("%s-%s", "two-phase commit", ybVersion), testTwoPhaseCommitIssue)
assert.True(t, success)

}
2 changes: 1 addition & 1 deletion yb-voyager/src/query/queryissue/parser_issue_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (p *ParserIssueDetector) getPLPGSQLIssues(query string) ([]QueryIssue, erro
issues = append(issues, issuesInQuery...)
}
if errorneousQueriesStr != "" {
log.Errorf("Found some PL/pgSQL queries in stmt [%s]: %s", query, errorneousQueriesStr)
log.Warnf("Found some errorneous PL/pgSQL queries in stmt [%s]: %s", query, errorneousQueriesStr)
}
percentTypeSyntaxIssues, err := p.GetPercentTypeSyntaxIssues(query)
if err != nil {
Expand Down

0 comments on commit d0212f7

Please sign in to comment.