From 7c5a140bc1734a127e35d326ad93c9b8fa979cd9 Mon Sep 17 00:00:00 2001 From: sinomoe Date: Fri, 8 Nov 2024 18:54:33 +0800 Subject: [PATCH] feat(ci): complete test cases --- .github/workflows/ci.yml | 6 ++++++ canal/canal_test.go | 23 ++++++++++++++++++++++- mysql/const.go | 1 + 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe75cb5aa..6036731df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,11 @@ jobs: echo -n "mysqldump -V: " ; mysqldump -V echo -e '[mysqld]\nserver-id=1\nlog-bin=mysql\nbinlog-format=row\ngtid-mode=ON\nenforce_gtid_consistency=ON\n' | sudo tee /etc/mysql/conf.d/replication.cnf + + # bind to :: for dual-stack listening + sudo sed -i 's/bind-address.*= 127.0.0.1/bind-address = ::/' /etc/mysql/mysql.conf.d/mysqld.cnf + sudo sed -i 's/mysqlx-bind-address.*= 127.0.0.1/mysqlx-bind-address = ::/' /etc/mysql/mysql.conf.d/mysqld.cnf + sudo service mysql start # apply this for mysql5 & mysql8 compatibility @@ -109,5 +114,6 @@ jobs: uses: actions/setup-go@v5 with: go-version: "1.22" + - name: Build on ${{ matrix.os }}/${{ matrix.arch }} run: GOARCH=${{ matrix.arch }} GOOS=${{ matrix.os }} go build ./... diff --git a/canal/canal_test.go b/canal/canal_test.go index 14a7056b9..444256076 100644 --- a/canal/canal_test.go +++ b/canal/canal_test.go @@ -16,12 +16,30 @@ import ( ) type canalTestSuite struct { + addr string suite.Suite c *Canal } +type canalTestSuiteOption func(c *canalTestSuite) + +func withAddr(addr string) canalTestSuiteOption { + return func(c *canalTestSuite) { + c.addr = addr + } +} + +func newCanalTestSuite(opts ...canalTestSuiteOption) *canalTestSuite { + c := new(canalTestSuite) + for _, opt := range opts { + opt(c) + } + return c +} + func TestCanalSuite(t *testing.T) { - suite.Run(t, new(canalTestSuite)) + suite.Run(t, newCanalTestSuite()) + suite.Run(t, newCanalTestSuite(withAddr(mysql.DEFAULT_IPV6_ADDR))) } const ( @@ -37,6 +55,9 @@ const ( func (s *canalTestSuite) SetupSuite() { cfg := NewDefaultConfig() cfg.Addr = fmt.Sprintf("%s:%s", *test_util.MysqlHost, *test_util.MysqlPort) + if s.addr != "" { + cfg.Addr = s.addr + } cfg.User = "root" cfg.HeartbeatPeriod = 200 * time.Millisecond cfg.ReadTimeout = 300 * time.Millisecond diff --git a/mysql/const.go b/mysql/const.go index b6da2e736..a11b05370 100644 --- a/mysql/const.go +++ b/mysql/const.go @@ -172,6 +172,7 @@ const ( const ( DEFAULT_ADDR = "127.0.0.1:3306" + DEFAULT_IPV6_ADDR = "[::1]:3306" DEFAULT_USER = "root" DEFAULT_PASSWORD = "" DEFAULT_FLAVOR = "mysql"