func TestVTGateExecuteBatchKeyspaceIds(t *testing.T) { //TODO(sougou): Fix test t.Skip() s := createSandbox("TestVTGateExecuteBatchKeyspaceIds") s.MapTestConn("-20", &sandboxConn{}) s.MapTestConn("20-40", &sandboxConn{}) kid10, err := key.HexKeyspaceId("10").Unhex() if err != nil { t.Errorf("want nil, got %v", err) } kid30, err := key.HexKeyspaceId("30").Unhex() if err != nil { t.Errorf("want nil, got %v", err) } q := proto.KeyspaceIdBatchQuery{ Queries: []proto.BoundKeyspaceIdQuery{{ Sql: "query", BindVariables: nil, Keyspace: "TestVTGateExecuteBatchKeyspaceIds", KeyspaceIds: []key.KeyspaceId{kid10, kid30}, }, { Sql: "query", BindVariables: nil, Keyspace: "TestVTGateExecuteBatchKeyspaceIds", KeyspaceIds: []key.KeyspaceId{kid10, kid30}, }}, TabletType: topo.TYPE_MASTER, } qrl := new(proto.QueryResultList) err = rpcVTGate.ExecuteBatchKeyspaceIds(context.Background(), &q, qrl) if err != nil { t.Errorf("want nil, got %v", err) } if len(qrl.List) != 2 { t.Errorf("want 2, got %v", len(qrl.List)) } if qrl.List[0].RowsAffected != 2 { t.Errorf("want 2, got %v", qrl.List[0].RowsAffected) } if qrl.Session != nil { t.Errorf("want nil, got %+v\n", qrl.Session) } q.Session = new(proto.Session) rpcVTGate.Begin(context.Background(), q.Session) rpcVTGate.ExecuteBatchKeyspaceIds(context.Background(), &q, qrl) if len(q.Session.ShardSessions) != 2 { t.Errorf("want 2, got %d", len(q.Session.ShardSessions)) } }
func TestVTGateExecuteBatchKeyspaceIds(t *testing.T) { s := createSandbox("TestVTGateExecuteBatchKeyspaceIds") s.MapTestConn("-20", &sandboxConn{}) s.MapTestConn("20-40", &sandboxConn{}) kid10, err := key.HexKeyspaceId("10").Unhex() if err != nil { t.Errorf("want nil, got %v", err) } kid30, err := key.HexKeyspaceId("30").Unhex() if err != nil { t.Errorf("want nil, got %v", err) } q := proto.KeyspaceIdBatchQuery{ Queries: []tproto.BoundQuery{{ "query", nil, }, { "query", nil, }}, Keyspace: "TestVTGateExecuteBatchKeyspaceIds", KeyspaceIds: []key.KeyspaceId{kid10, kid30}, TabletType: topo.TYPE_MASTER, } qrl := new(proto.QueryResultList) err = RpcVTGate.ExecuteBatchKeyspaceIds(nil, &q, qrl) if err != nil { t.Errorf("want nil, got %v", err) } if len(qrl.List) != 2 { t.Errorf("want 2, got %v", len(qrl.List)) } if qrl.List[0].RowsAffected != 2 { t.Errorf("want 2, got %v", qrl.List[0].RowsAffected) } if qrl.Session != nil { t.Errorf("want nil, got %+v\n", qrl.Session) } q.Session = new(proto.Session) RpcVTGate.Begin(nil, q.Session) err = RpcVTGate.ExecuteBatchKeyspaceIds(nil, &q, qrl) if len(q.Session.ShardSessions) != 2 { t.Errorf("want 2, got %d", len(q.Session.ShardSessions)) } }