Skip to content

Commit

Permalink
fix: remove ip check; remove wrong testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
newborn22 committed Dec 3, 2024
1 parent aee5e01 commit 3e91354
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 32 deletions.
5 changes: 0 additions & 5 deletions go/vt/vtgate/branch/branch_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package branch

import (
"fmt"
"net"
"strings"
"vitess.io/vitess/go/vt/schemadiff"
)
Expand Down Expand Up @@ -78,10 +77,6 @@ func (meta *BranchMeta) Validate() error {

if meta.SourceHost == "" {
return fmt.Errorf("branch SourceHost cannot be empty")
} else {
if net.ParseIP(meta.SourceHost) == nil {
return fmt.Errorf("source host %v is not a valid ip address", meta.SourceHost)
}
}

if meta.SourcePort <= 0 || meta.SourcePort > 65535 {
Expand Down
20 changes: 0 additions & 20 deletions go/vt/vtgate/branch/target_mysql_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package branch

import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
)

Expand All @@ -19,25 +18,6 @@ func TestGetAllDatabases(t *testing.T) {
}
}

func TestSelectBranchMeta(t *testing.T) {
mysqlService, mock := NewMockMysqlService(t)
defer mysqlService.Close()
TargetMySQLServiceForTest := NewTargetMySQLService(mysqlService)

InitMockBranchMetas(mock)

for i, _ := range BranchMetasForTest {
meta, err := TargetMySQLServiceForTest.SelectAndValidateBranchMeta(fmt.Sprintf("test%d", i))
if err != nil {
t.Error(err)
}
assert.Equal(t, true, compareBranchMetas(BranchMetasForTest[i], meta))
}
meta, err := TargetMySQLServiceForTest.SelectAndValidateBranchMeta("no this test")
assert.Nil(t, meta)
assert.NotNil(t, err)
}

func compareBranchMetas(first, second *BranchMeta) bool {
if first == nil || second == nil {
if first != second {
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/branch/test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ var (
SourcePort: 3306,
SourceUser: "repl_user",
SourcePassword: "password123",
IncludeDatabases: []string{},
IncludeDatabases: []string{"*"},
ExcludeDatabases: []string{},
TargetDBPattern: "",
Status: "unknown",
Expand Down
6 changes: 0 additions & 6 deletions go/vt/vtgate/engine/branch_primitive.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"github.com/go-sql-driver/mysql"
"net"
"strconv"
"strings"
"vitess.io/vitess/go/sqltypes"
Expand Down Expand Up @@ -294,14 +293,9 @@ func (bcp *BranchCreateParams) setValues(params map[string]string) error {
return checkRedundantParams(params)
}

// todo complete me
func (bcp *BranchCreateParams) validate() error {
if bcp.SourceHost == "" {
return fmt.Errorf("branch create: source host is required")
} else {
if net.ParseIP(bcp.SourceHost) == nil {
return fmt.Errorf("branch create: source host %v is not a valid ip address", bcp.SourceHost)
}
}

if bcp.SourcePort == "" {
Expand Down

0 comments on commit 3e91354

Please sign in to comment.