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

Fast integration test for artificial driver #6799

Merged
merged 8 commits into from
Jan 16, 2023

Conversation

VysotskiVadim
Copy link
Contributor

@VysotskiVadim VysotskiVadim commented Jan 10, 2023

Added a test which verifies that NN follows location updates generated by "artificial driver" without reroutes.

It works very fast, because it makes NN process location updates as fast as it can, so I can this PR a POC of fast integration tests(https://mapbox.atlassian.net/browse/NN-418). Route Munich-Nuremberg(duration 16240.29) completes in 1 minute on Pixel 6.

@VysotskiVadim VysotskiVadim force-pushed the vv-test-integration-of-artificial-driver-and-nn branch from 220d55a to 1ea6c0a Compare January 10, 2023 10:31
@github-actions
Copy link

github-actions bot commented Jan 10, 2023

Changelog

Features

  • Introduced ViewStyleCustomization.infoPanelGuidelineMaxPosPercent that allows customization of the NavigationView InfoPanel bottom guideline maximum position. Increased default value to 50%. #6792

Bug fixes and improvements

  • Fixed an issue with NavigationView that caused info panel to shrink in landscape mode with a full screen theme. #6780

  • ⚠️ Updated the NavigationView default navigation puck asset. #6678

    Previous puck can be restored by injecting LocationPuck2D with the bearingImage set to com.mapbox.navigation.ui.maps.R.drawable.mapbox_navigation_puck_icon drawable:

    navigationView.customizeViewStyles {
        locationPuckOptions = LocationPuckOptions.Builder(context)
            .defaultPuck(
                LocationPuck2D(
                    bearingImage = ContextCompat.getDrawable(
                        context,
                        com.mapbox.navigation.ui.maps.R.drawable.mapbox_navigation_puck_icon,
                    )
                )
            )
            .idlePuck(regularPuck(context))
            .build()
    }
  • Fixed an issue where the first voice instruction might have been played twice. #6766

  • Added guarantees that route progress with RouteProgress#currentState == OFF_ROUTE arrives earlier than NavigationRerouteController#reroute is called. #6764

  • Introduced NavigationViewListener.onSpeedInfoClicked that would be triggered when MapboxSpeedInfoView is clicked upon. #6770

  • Each newly instantiated MapboxRouteArrowView class will initialize the layers with the provided options on the first render call. Previously this would only be done if the layers hadn't already been initialized. #6466

  • Fixed a rare java.lang.NullPointerException: Attempt to read from field 'SpeechAnnouncement PlayCallback.announcement' on a null object reference crash in PlayCallback.getAnnouncement. #6760

  • Fixed standalone MapboxManeuverView appearance when the app also integrates Drop-In UI. #6774

Known issues ⚠️

Other changes

Android Auto Changelog

Features

Bug fixes and improvements

@codecov
Copy link

codecov bot commented Jan 10, 2023

Codecov Report

Merging #6799 (428cd54) into main (61415ea) will increase coverage by 0.00%.
The diff coverage is 94.44%.

Impacted file tree graph

@@            Coverage Diff            @@
##               main    #6799   +/-   ##
=========================================
  Coverage     72.64%   72.64%           
+ Complexity     5569     5565    -4     
=========================================
  Files           780      781    +1     
  Lines         30104    30110    +6     
  Branches       3553     3554    +1     
=========================================
+ Hits          21869    21874    +5     
- Misses         6808     6809    +1     
  Partials       1427     1427           
Impacted Files Coverage Δ
...n/core/replay/history/ReplayEventLocationMapper.kt 93.75% <93.75%> (ø)
...box/navigation/core/replay/ReplayLocationEngine.kt 100.00% <100.00%> (ø)

@VysotskiVadim VysotskiVadim added the skip changelog Should not be added into version changelog. label Jan 10, 2023
@VysotskiVadim VysotskiVadim requested a review from kmadsen January 10, 2023 13:48
Comment on lines +57 to +59
for (location in events.map { it.location.mapToLocation() }) {
assertTrue(nativeNavigator.updateLocation(location.toFixLocation()))
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mapbox/navnative , we have already discussed it, but can you please confirm that this is valid usage of native navigator?
I generated location updates so that they looks like the regular ones, but I pass them to NN faster than they happen in reality keeping the original time, i.e. for the native navigator time goes faster than real time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like history recording replay, you can take the locations with proper monotonic time in them and feed back-to-back into the navigator - it will produce the correct result.

Comment on lines +13 to +17
internal fun ReplayEventLocation.mapToLocation(
eventTimeOffset: Double = time ?: 0.0,
@VisibleForTesting currentTimeMilliseconds: Long = Date().time,
@VisibleForTesting elapsedTimeNano: Long = SystemClock.elapsedRealtimeNanos()
): Location {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kmadsen , I didn't understand which problems mapboxReplayer.eventRealtimeOffset solves, so maybe it isn't the best API for the mapper. Any suggestions?

@VysotskiVadim VysotskiVadim changed the title Fast integration test for artificial driver [work in progress] Fast integration test for artificial driver Jan 10, 2023
@VysotskiVadim VysotskiVadim marked this pull request as ready for review January 10, 2023 13:54
.build()
)
block(mapboxNavigation, MapboxNativeNavigatorImpl)
mapboxNavigation.onDestroy()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onDestroyed won't be called if the test fails, you should use a rule for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. I think try-finaly will work too, won't they? 250aa56

Copy link
Contributor

@dzinad dzinad Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will, yes.


val states = statusesTracking.await()
val historyFile = suspendCoroutine<String> { continuation ->
mapboxNavigation.historyRecorder.stopRecording {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a suspend version of this method:

val historyFile = mapboxNavigation.historyRecorder.startRecording()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please help me find it? I don't see suspend version here

Copy link
Contributor Author

@VysotskiVadim VysotskiVadim Jan 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably meant this one, but artificial driver test is in a different module as it accesses internal APIs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this one. Oh, it's a different module. OK then.

continuation.resume(it ?: "null")
}
}
val notTrackingStates = states.filter { it.routeState != RouteState.TRACKING }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the right check? I mean do we want to test that we only have tracking or that we don't have off_route? What about INITIALIZED state for example?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think the right check should be?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote this test to verify absence of reroutes when location updates are simulated by our artificial driver. That's why I check only tracking part. But I'm open to suggestions, if you think a different check will bring us more benefits, I'm happy to change the current one 🙂

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I thought I left a comment but I didn't. Judging by the name of the test, I'd do sth like:

val offRouteStates = states.filter { it.routeState == RouteState.OFF_ROUTE }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! applied

@VysotskiVadim VysotskiVadim force-pushed the vv-test-integration-of-artificial-driver-and-nn branch from 250aa56 to d9471d9 Compare January 11, 2023 09:37
@VysotskiVadim VysotskiVadim requested a review from dzinad January 11, 2023 09:39
@VysotskiVadim VysotskiVadim force-pushed the vv-test-integration-of-artificial-driver-and-nn branch from 261c1f7 to 428cd54 Compare January 13, 2023 10:25
"&language=en" +
"&overview=full" +
"&steps=true" +
"&access_token=YOUR_MAPBOX_ACCESS_TOKEN",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See NativeNavigatorCallbackOrderTest, it already uses access token that is being injected on CI.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you don't want it to be present in the URL.

@VysotskiVadim VysotskiVadim merged commit 6fc4e70 into main Jan 16, 2023
@VysotskiVadim VysotskiVadim deleted the vv-test-integration-of-artificial-driver-and-nn branch January 16, 2023 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip changelog Should not be added into version changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants