Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unittests and etcd paths #344

Merged
merged 4 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/shard/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package shard

func ShardIDs(shards []Shard) []string {
ret := []string{}
for _, shard := range shards {
ret = append(ret, shard.ID())
}
return ret
}
16 changes: 8 additions & 8 deletions qdb/etcdqdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ func NewEtcdQDB(addr string) (*EtcdQDB, error) {
}

const (
keyspace = "key_space"
keyRangesNamespace = "/keyranges"
dataspaceNamespace = "/dataspaces"
keyRangeMovesNamespace = "/krmoves"
routersNamespace = "/routers"
shardingRulesNamespace = "/sharding_rules"
shardsNamespace = "/shards"
keyRangesNamespace = "/keyranges/"
dataspaceNamespace = "/dataspaces/"
keyRangeMovesNamespace = "/krmoves/"
routersNamespace = "/routers/"
shardingRulesNamespace = "/sharding_rules/"
shardsNamespace = "/shards/"

CoordKeepAliveTtl = 3
keyspace = "key_space"
coordLockKey = "coordinator_exists"
coordLockVal = "exists"
)

func keyLockPath(key string) string {
Expand Down
4 changes: 4 additions & 0 deletions router/frontend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ func TestFrontendSimple(t *testing.T) {

beRule := &config.BackendRule{}


srv.EXPECT().Datashards().AnyTimes().Return([]shard.Shard{})
srv.EXPECT().Name().AnyTimes().Return("serv1")

cl.EXPECT().Server().AnyTimes().Return(srv)
Expand Down Expand Up @@ -167,6 +169,7 @@ func TestFrontendXProto(t *testing.T) {
beRule := &config.BackendRule{}

srv.EXPECT().Name().AnyTimes().Return("serv1")
srv.EXPECT().Datashards().AnyTimes().Return([]shard.Shard{})

/* query Router */

Expand Down Expand Up @@ -302,6 +305,7 @@ func TestFrontendSimpleCopyIn(t *testing.T) {
beRule := &config.BackendRule{}

srv.EXPECT().Name().AnyTimes().Return("serv1")
srv.EXPECT().Datashards().AnyTimes().Return([]shard.Shard{})

cl.EXPECT().Server().AnyTimes().Return(srv)

Expand Down
175 changes: 87 additions & 88 deletions router/mock/server/mock_server.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions router/relay/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ func (rst *RelayStateImpl) ProcQuery(query pgproto3.FrontendMessage, waitForResp
}

spqrlog.Zero.Debug().
Str("server", server.Datashards()[0].ID()).
Strs("shards", shard.ShardIDs(server.Datashards())).
Type("query-type", query).
Msg("client process query")

Expand Down Expand Up @@ -918,7 +918,7 @@ func (rst *RelayStateImpl) DeployPrepStmt(qname string) (shard.PreparedStatement
Str("query", query).
Uint64("hash", hash).
Str("client", rst.Client().ID()).
Str("shard", rst.Client().Server().Datashards()[0].ID()).
Strs("shards", shard.ShardIDs(rst.Client().Server().Datashards())).
Msg("deploy prepared statement")

// TODO: multi-shard statements
Expand Down
2 changes: 1 addition & 1 deletion router/server/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (srv *ShardServer) Receive() (pgproto3.BackendMessage, error) {
Uint("single-shard", spqrlog.GetPointer(srv)).
Type("message-type", msg).
Str("txstatus", srv.TxStatus().String()).
Str("shard", srv.Datashards()[0].ID()).
Strs("shards", shard.ShardIDs(srv.Datashards())).
Msg("single-shard receiving msg from server")
return msg, err
}
Expand Down
Loading