Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
empiredan committed Mar 8, 2024
1 parent 5ac8ac1 commit 2f85866
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions go-client/admin/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func defaultConfig() Config {
}
}

func defaultReplicaServers() []string {
return []string{"0.0.0.0:34801", "0.0.0.0:34802", "0.0.0.0:34803"}
func defaultReplicaServerPorts() []int {
return []int{34801, 34802, 34803}
}

func timeoutConfig() Config {
Expand Down Expand Up @@ -166,20 +166,20 @@ func TestAdmin_ListNodes(t *testing.T) {
nodes, err := c.ListNodes()
assert.Nil(t, err)

expectedReplicaServers := defaultReplicaServers()
expectedReplicaServerPorts := defaultReplicaServerPorts()

// Compare slice length.
assert.Equal(t, len(expectedReplicaServers), len(nodes))
assert.Equal(t, len(expectedReplicaServerPorts), len(nodes))

actualReplicaServers := make([]string, len(nodes))
actualReplicaServerPorts := make([]int, len(nodes))
for i, node := range nodes {
// Each node should be alive.
assert.Equal(t, admin.NodeStatus_NS_ALIVE, node.Status)
actualReplicaServers[i] = node.Address.GetAddress()
actualReplicaServerPorts[i] = node.Address.GetPort()
}

// Match elements without extra ordering.
assert.ElementsMatch(t, expectedReplicaServers, actualReplicaServers)
assert.ElementsMatch(t, expectedReplicaServerPorts, actualReplicaServerPorts)
}

func TestAdmin_ListNodesTimeout(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions go-client/idl/base/rpc_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ func (r *RPCAddress) String() string {
return fmt.Sprintf("RPCAddress(%s)", r.GetAddress())
}

func (r *RPCAddress) getIp() net.IP {
func (r *RPCAddress) GetIP() net.IP {
return net.IPv4(byte(0xff&(r.address>>56)), byte(0xff&(r.address>>48)), byte(0xff&(r.address>>40)), byte(0xff&(r.address>>32)))
}

func (r *RPCAddress) getPort() int {
func (r *RPCAddress) GetPort() int {
return int(0xffff & (r.address >> 16))
}

func (r *RPCAddress) GetAddress() string {
return fmt.Sprintf("%s:%d", r.getIp(), r.getPort())
return fmt.Sprintf("%s:%d", r.GetIP(), r.GetPort())
}

func (r *RPCAddress) GetRawAddress() int64 {
Expand Down

0 comments on commit 2f85866

Please sign in to comment.