Takes the node name out of the coordinate get call.
This commit is contained in:
parent
acb0dce829
commit
e02ae7b6b4
|
@ -91,13 +91,8 @@ func (c *Coordinate) Get(args *structs.NodeSpecificRequest, reply *structs.Index
|
||||||
&reply.QueryMeta,
|
&reply.QueryMeta,
|
||||||
state.QueryTables("Coordinates"),
|
state.QueryTables("Coordinates"),
|
||||||
func() error {
|
func() error {
|
||||||
idx, coord, err := state.CoordinateGet(args.Node)
|
var err error
|
||||||
reply.Index = idx
|
reply.Index, reply.Coord, err = state.CoordinateGet(args.Node)
|
||||||
if coord == nil {
|
|
||||||
reply.Coord = nil
|
|
||||||
} else {
|
|
||||||
reply.Coord = coord.Coord
|
|
||||||
}
|
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,39 +79,39 @@ func TestCoordinate_Update(t *testing.T) {
|
||||||
// Make sure the updates did not yet apply because the update period
|
// Make sure the updates did not yet apply because the update period
|
||||||
// hasn't expired.
|
// hasn't expired.
|
||||||
state := s1.fsm.State()
|
state := s1.fsm.State()
|
||||||
_, d, err := state.CoordinateGet("node1")
|
_, c, err := state.CoordinateGet("node1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
if d != nil {
|
if c != nil {
|
||||||
t.Fatalf("should be nil because the update should be batched")
|
t.Fatalf("should be nil because the update should be batched")
|
||||||
}
|
}
|
||||||
_, d, err = state.CoordinateGet("node2")
|
_, c, err = state.CoordinateGet("node2")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
if d != nil {
|
if c != nil {
|
||||||
t.Fatalf("should be nil because the update should be batched")
|
t.Fatalf("should be nil because the update should be batched")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait a while and the updates should get picked up.
|
// Wait a while and the updates should get picked up.
|
||||||
time.Sleep(2 * s1.config.CoordinateUpdatePeriod)
|
time.Sleep(2 * s1.config.CoordinateUpdatePeriod)
|
||||||
_, d, err = state.CoordinateGet("node1")
|
_, c, err = state.CoordinateGet("node1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
if d == nil {
|
if c == nil {
|
||||||
t.Fatalf("should return a coordinate but it's nil")
|
t.Fatalf("should return a coordinate but it's nil")
|
||||||
}
|
}
|
||||||
verifyCoordinatesEqual(t, d.Coord, arg1.Coord)
|
verifyCoordinatesEqual(t, c, arg1.Coord)
|
||||||
_, d, err = state.CoordinateGet("node2")
|
_, c, err = state.CoordinateGet("node2")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
if d == nil {
|
if c == nil {
|
||||||
t.Fatalf("should return a coordinate but it's nil")
|
t.Fatalf("should return a coordinate but it's nil")
|
||||||
}
|
}
|
||||||
verifyCoordinatesEqual(t, d.Coord, arg2.Coord)
|
verifyCoordinatesEqual(t, c, arg2.Coord)
|
||||||
|
|
||||||
// Now try spamming coordinates and make sure it starts dropping when
|
// Now try spamming coordinates and make sure it starts dropping when
|
||||||
// the pipe is full.
|
// the pipe is full.
|
||||||
|
@ -132,14 +132,14 @@ func TestCoordinate_Update(t *testing.T) {
|
||||||
// Wait a little while for the batch routine to run, then make sure
|
// Wait a little while for the batch routine to run, then make sure
|
||||||
// all but the last coordinate update made it in.
|
// all but the last coordinate update made it in.
|
||||||
time.Sleep(2 * s1.config.CoordinateUpdatePeriod)
|
time.Sleep(2 * s1.config.CoordinateUpdatePeriod)
|
||||||
_, d, err = state.CoordinateGet("node1")
|
_, c, err = state.CoordinateGet("node1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
if d == nil {
|
if c == nil {
|
||||||
t.Fatalf("should return a coordinate but it's nil")
|
t.Fatalf("should return a coordinate but it's nil")
|
||||||
}
|
}
|
||||||
verifyCoordinatesEqual(t, d.Coord, arg1.Coord)
|
verifyCoordinatesEqual(t, c, arg1.Coord)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCoordinate_Get(t *testing.T) {
|
func TestCoordinate_Get(t *testing.T) {
|
||||||
|
|
|
@ -761,23 +761,23 @@ func TestFSM_CoordinateUpdate(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read back the two coordinates to make sure they got updated.
|
// Read back the two coordinates to make sure they got updated.
|
||||||
_, d, err := fsm.state.CoordinateGet(updates[0].Node)
|
_, c, err := fsm.state.CoordinateGet(updates[0].Node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
if d == nil {
|
if c == nil {
|
||||||
t.Fatalf("missing")
|
t.Fatalf("missing")
|
||||||
}
|
}
|
||||||
verifyCoordinatesEqual(t, updates[0].Coord, d.Coord)
|
verifyCoordinatesEqual(t, c, updates[0].Coord)
|
||||||
|
|
||||||
_, d, err = fsm.state.CoordinateGet(updates[1].Node)
|
_, c, err = fsm.state.CoordinateGet(updates[1].Node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
if d == nil {
|
if c == nil {
|
||||||
t.Fatalf("missing")
|
t.Fatalf("missing")
|
||||||
}
|
}
|
||||||
verifyCoordinatesEqual(t, updates[1].Coord, d.Coord)
|
verifyCoordinatesEqual(t, c, updates[1].Coord)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFSM_SessionCreate_Destroy(t *testing.T) {
|
func TestFSM_SessionCreate_Destroy(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue