Skip to content

Commit

Permalink
Fix pg replication test
Browse files Browse the repository at this point in the history
  • Loading branch information
fanyang01 committed Dec 20, 2024
1 parent 20849b4 commit dc0112b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,10 @@ func main() {
logrus.WithError(err).Fatalln("Failed to create the `public` schema")
}

pgserver.InitSuperuser(superuserPassword)

pgServer, err := pgserver.NewServer(
provider, pool,
address, postgresPort,
superuserPassword,
func() *sql.Context {
session := backend.NewSession(memory.NewSession(sql.NewBaseSession(), provider), provider, pool)
return sql.NewContext(context.Background(), sql.WithSession(session))
Expand Down
4 changes: 3 additions & 1 deletion pgserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package pgserver

import (
"fmt"

"github.com/apecloud/myduckserver/backend"
"github.com/apecloud/myduckserver/catalog"
"github.com/dolthub/go-mysql-server/server"
Expand All @@ -16,7 +17,8 @@ type Server struct {
NewInternalCtx func() *sql.Context
}

func NewServer(provider *catalog.DatabaseProvider, connPool *backend.ConnectionPool, host string, port int, newCtx func() *sql.Context, options ...ListenerOpt) (*Server, error) {
func NewServer(provider *catalog.DatabaseProvider, connPool *backend.ConnectionPool, host string, port int, password string, newCtx func() *sql.Context, options ...ListenerOpt) (*Server, error) {
InitSuperuser(password)
addr := fmt.Sprintf("%s:%d", host, port)
l, err := server.NewListener("tcp", addr, "")
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pgtest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func CreateTestServer(t *testing.T, port int) (ctx context.Context, pgServer *pg
pgServer, err = pgserver.NewServer(
provider, pool,
"127.0.0.1", port,
"",
func() *sql.Context {
session := backend.NewSession(memory.NewSession(sql.NewBaseSession(), provider), provider, pool)
return sql.NewContext(context.Background(), sql.WithSession(session))
Expand Down

0 comments on commit dc0112b

Please sign in to comment.