Skip to content

Commit

Permalink
Fix tests for new Servers (task, master)
Browse files Browse the repository at this point in the history
  • Loading branch information
araddon committed Aug 29, 2016
1 parent c7c4f22 commit 3d8868c
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 29 deletions.
2 changes: 1 addition & 1 deletion backends/cassandra/cass_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ CREATE TABLE IF NOT EXISTS event (

func jobMaker(ctx *plan.Context) (*planner.ExecutorGrid, error) {
ctx.Schema = testmysql.Schema
return planner.BuildSqlJob(ctx, testmysql.ServerCtx.Grid)
return planner.BuildSqlJob(ctx, testmysql.ServerCtx.PlanGrid)
}

func RunTestServer(t *testing.T) func() {
Expand Down
2 changes: 1 addition & 1 deletion backends/datastore/datastore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func init() {
func jobMaker(ctx *plan.Context) (*planner.ExecutorGrid, error) {
// func BuildSqlJob(ctx *plan.Context, gs *Server) (*ExecutorGrid, error) {
ctx.Schema = testmysql.Schema
return planner.BuildSqlJob(ctx, testmysql.ServerCtx.Grid)
return planner.BuildSqlJob(ctx, testmysql.ServerCtx.PlanGrid)
}

func RunTestServer(t *testing.T) func() {
Expand Down
2 changes: 1 addition & 1 deletion backends/elasticsearch/es_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func init() {
func jobMaker(ctx *plan.Context) (*planner.ExecutorGrid, error) {
// func BuildSqlJob(ctx *plan.Context, gs *Server) (*ExecutorGrid, error) {
ctx.Schema = testmysql.Schema
return planner.BuildSqlJob(ctx, testmysql.ServerCtx.Grid)
return planner.BuildSqlJob(ctx, testmysql.ServerCtx.PlanGrid)
}

func RunTestServer(t *testing.T) func() {
Expand Down
2 changes: 1 addition & 1 deletion backends/files/filesource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func init() {

func jobMaker(ctx *plan.Context) (*planner.ExecutorGrid, error) {
ctx.Schema = testmysql.Schema
return planner.BuildSqlJob(ctx, testmysql.ServerCtx.Grid)
return planner.BuildSqlJob(ctx, testmysql.ServerCtx.PlanGrid)
}

func RunTestServer(t *testing.T) {
Expand Down
4 changes: 1 addition & 3 deletions frontends/mysqlfe/sql_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,7 @@ func TableCreate(tbl *schema.Table) (string, error) {
fmt.Fprint(w, "\n ")
writeField(w, fld)
}
fmt.Fprint(w, "\n) ENGINE=InnoDB DEFAULT CHARSET=utf8")
//tblStr := fmt.Sprintf("CREATE TABLE `%s` (\n\n);", tbl.Name, strings.Join(cols, ","))
//return tblStr, nil
fmt.Fprint(w, "\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;")
return w.String(), nil
}
func writeField(w *bytes.Buffer, fld *schema.Field) {
Expand Down
16 changes: 9 additions & 7 deletions frontends/mysqlfe/sql_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ ADD "column_name" "Data Type";
func TestSqlCreate(t *testing.T) {
t.Parallel()

ss := schema.NewSourceSchema("test", "test")
tbl := schema.NewTable("equipment", ss)
tbl.AddField(schema.NewField("id", value.IntType, 64, "Id is auto-generated random uuid"))
tbl.AddField(schema.NewField("name", value.StringType, 20, ""))
tbl.AddField(schema.NewField("installed", value.TimeType, 0, "When was this installed?"))
tbl.AddField(schema.NewField("jsondata", value.ByteSliceType, 0, "Json Data"))
//ss := schema.NewSourceSchema("test", "test")
tbl := schema.NewTable("equipment")
tbl.AddField(schema.NewFieldBase("id", value.IntType, 64, "Id is auto-generated random uuid"))
tbl.AddField(schema.NewFieldBase("name", value.StringType, 20, ""))
tbl.AddField(schema.NewFieldBase("installed", value.TimeType, 0, "When was this installed?"))
tbl.AddField(schema.NewFieldBase("jsondata", value.ByteSliceType, 0, "Json Data"))

expected := "CREATE TABLE `equipment` (\n" +
" `id` bigint DEFAULT NULL COMMENT \"Id is auto-generated random uuid\",\n" +
Expand All @@ -96,7 +96,9 @@ func TestSqlCreate(t *testing.T) {
") ENGINE=InnoDB DEFAULT CHARSET=utf8;"

createStmt, err := TableCreate(tbl)
assert.T(t, err == nil)
assert.Equal(t, err, nil)
u.Debugf("\n%s\n%s", expected, createStmt)
assert.Equal(t, expected, createStmt)
for i, _ := range expected {
if expected[i] != createStmt[i] {
end := i + 20
Expand Down
2 changes: 1 addition & 1 deletion vendored/mixer/client/clientconn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func init() {
func newTestConn() *Conn {
c := new(Conn)

if err := c.Connect("localhost:3307", "mixer", "", "mixer"); err != nil {
if err := c.Connect("localhost:13307", "mixer", "", "mixer"); err != nil {
panic(err)
}

Expand Down
23 changes: 14 additions & 9 deletions vendored/mixer/proxy/handler_sharded.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ type HandlerSharded struct {
conn *Conn
}

// func NewHandlerSharded(conf *models.Config) (models.Listener, error) {
// sharedHandler := &HandlerShardedShared{
// conf: conf,
// }
// handler := &HandlerSharded{HandlerShardedShared: sharedHandler}
// err := handler.Init()
// return handler, err
// }
func NewHandlerSharded(conf *models.Config) (models.Listener, error) {
sharedHandler := &HandlerShardedShared{
conf: conf,
}
handler := &HandlerSharded{HandlerShardedShared: sharedHandler}
//err := handler.Init()
return handler, nil
}

func (m *HandlerSharded) Init() error {
func (m *HandlerSharded) Init(*models.ListenerConfig, *models.ServerCtx) error {

if err := m.startBackendNodes(); err != nil {
return err
Expand All @@ -82,6 +82,11 @@ func (m *HandlerSharded) Init() error {
return nil
}

func (m *HandlerSharded) Run(stop chan bool) error {

return nil
}

func (m *HandlerShardedShared) Open(connI interface{}) models.StatementHandler {

handler := HandlerSharded{HandlerShardedShared: m}
Expand Down
14 changes: 9 additions & 5 deletions vendored/mixer/proxy/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,24 +107,28 @@ schemas : [
`

type testListenerWraper struct {
*MysqlListener
*mysqlListener
nodes map[string]*Node
}

func newTestServer(t *testing.T) *testListenerWraper {
f := func() {
cfg, err := models.LoadConfig(testConfigData)
Conf, err := models.LoadConfig(testConfigData)
assert.Tf(t, err == nil, "must load config without err: %v", err)

myl, err := NewMysqlListener(cfg.Frontends[0], cfg)
u.Debugf("conf: %+v", Conf.Frontends[0])
myl, err := newMysqlListener(Conf.Frontends[0], Conf, nil)
assert.Tf(t, err == nil, "must create listener without err: %v", err)
handler, err := NewHandlerSharded(cfg)
handler, err := NewHandlerSharded(Conf)
assert.Tf(t, err == nil, "must create handler without err: %v", err)
testHandler = handler.(*HandlerSharded)

ServerCtx := models.NewServerCtx(Conf)

testListener = &testListenerWraper{myl, testHandler.nodes}
testListener.Init(Conf.Frontends[0], ServerCtx)

go testListener.Run(testHandler, make(chan bool))
go testListener.Run(make(chan bool))

// delay to ensure we have time to connect
time.Sleep(100 * time.Millisecond)
Expand Down

0 comments on commit 3d8868c

Please sign in to comment.