Skip to content

Commit

Permalink
RSDK-4588 Set manual mode prior to waypoint tests to prevent races (v…
Browse files Browse the repository at this point in the history
  • Loading branch information
biotinker committed Aug 23, 2023
1 parent d445eff commit 4bff6b8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions services/navigation/builtin/builtin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,11 @@ func TestStartWaypoint(t *testing.T) {
pt1, pt2, pt3 := geo.NewPoint(1, 2), geo.NewPoint(2, 3), geo.NewPoint(3, 4)
points := []*geo.Point{pt1, pt2, pt3}
t.Run("MoveOnGlobe error results in skipping the current waypoint", func(t *testing.T) {
// Set manual mode to ensure waypoint loop from prior test exits
err = ns.SetMode(ctx, navigation.ModeManual, map[string]interface{}{"experimental": true})
test.That(t, err, test.ShouldBeNil)
ctx, cancelFunc := context.WithCancel(ctx)
defer ns.(*builtIn).activeBackgroundWorkers.Wait()
defer cancelFunc()
err = deleteAllWaypoints(ctx, ns)
for _, pt := range points {
Expand Down Expand Up @@ -334,6 +338,7 @@ func TestStartWaypoint(t *testing.T) {
currentInputsShouldEqual(ctx, t, kinematicBase, pt3)
})
t.Run("Calling SetMode cancels current and future MoveOnGlobe calls", func(t *testing.T) {
// Set manual mode to ensure waypoint loop from prior test exits
err = deleteAllWaypoints(ctx, ns)
test.That(t, err, test.ShouldBeNil)
for _, pt := range points {
Expand All @@ -342,7 +347,6 @@ func TestStartWaypoint(t *testing.T) {
}

// start navigation - set ModeManual first to ensure navigation starts up
ns.(*builtIn).mode = navigation.ModeManual
err = ns.SetMode(ctx, navigation.ModeWaypoint, map[string]interface{}{"experimental": true})

// Reach the first waypoint
Expand All @@ -363,14 +367,16 @@ func TestStartWaypoint(t *testing.T) {
})

t.Run("Calling RemoveWaypoint on the waypoint in progress cancels current MoveOnGlobe call", func(t *testing.T) {
// Set manual mode to ensure waypoint loop from prior test exits
err = ns.SetMode(ctx, navigation.ModeManual, map[string]interface{}{"experimental": true})
test.That(t, err, test.ShouldBeNil)
err = deleteAllWaypoints(ctx, ns)
for _, pt := range points {
err = ns.AddWaypoint(ctx, pt, nil)
test.That(t, err, test.ShouldBeNil)
}

// start navigation - set ModeManual first to ensure navigation starts up
ns.(*builtIn).mode = navigation.ModeManual
err = ns.SetMode(ctx, navigation.ModeWaypoint, map[string]interface{}{"experimental": true})

// Get the ID of the first waypoint
Expand Down Expand Up @@ -412,6 +418,9 @@ func TestStartWaypoint(t *testing.T) {
})

t.Run("Calling RemoveWaypoint on a waypoint that is not in progress does not cancel MoveOnGlobe", func(t *testing.T) {
// Set manual mode to ensure waypoint loop from prior test exits
err = ns.SetMode(ctx, navigation.ModeManual, map[string]interface{}{"experimental": true})
test.That(t, err, test.ShouldBeNil)
err = deleteAllWaypoints(ctx, ns)
var wp3 navigation.Waypoint
for i, pt := range points {
Expand All @@ -425,7 +434,6 @@ func TestStartWaypoint(t *testing.T) {
}

// start navigation - set ModeManual first to ensure navigation starts up
ns.(*builtIn).mode = navigation.ModeManual
err = ns.SetMode(ctx, navigation.ModeWaypoint, map[string]interface{}{"experimental": true})

// Reach the first waypoint
Expand Down

0 comments on commit 4bff6b8

Please sign in to comment.