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

[mock_uss] Add user notifications for missing fields in injected flights #911

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

the-glu
Copy link
Contributor

@the-glu the-glu commented Jan 29, 2025

Follow #910

Tested, I added a filter + a new raw_telemetry field for internal purpose, because everything was crashing with bad telemetry data ^^'

@the-glu the-glu force-pushed the user-notifications-missing-fields branch 2 times, most recently from f5677c5 to b6f033c Compare January 30, 2025 08:52
@the-glu the-glu marked this pull request as ready for review January 30, 2025 08:53
Copy link
Contributor

@Shastick Shastick left a comment

Choose a reason for hiding this comment

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

Sounds like a wise thing to do :)

monitoring/mock_uss/ridsp/routes_injection.py Outdated Show resolved Hide resolved
@@ -29,3 +31,20 @@ def record_notification(
self.user_notifications.append(
UserNotification(observed_at=observed_at_time, message=message)
)

def create_notifications_if_nedded(self, record: "database.TestRecord"):
Copy link
Contributor

Choose a reason for hiding this comment

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

This is going to trigger a notification for every single missing field in any telemetry point. That's not realistic since we'd want that only if there are missing fields for a while, but that could be acceptable behavior for the mock USS.
However what it is not covering is the lack of any telemetry point for a while. Which we will need for NET0400. Could you add that? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which we will need for NET0400. Could you add that? Thanks!

We planned with @Shastick to implement that one in a different PR, this is only for NET0030 on purpose :)

This is going to trigger a notification for every single missing field in any telemetry point. That's not realistic since we'd want that only if there are missing fields for a while, but that could be acceptable behavior for the mock USS.

For the mock uss we probably want that for testing: It's reporting all missing fields with location on purpose if debugging is needed (and that shouldn't add much overhead, when testing we do only set one missing field in one telemetry). Also I'm not sure, but complaining immediately is not an issue based on the standard no?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, I don't see a reason to limit ourselves to a single notification, and the current approach makes the logic very simple.

The intention for the scenario is to assume that we have at least one notification sent (ie, the notification count over the period is non-zero, and/or the total number of notifications at the end of the scenario is higher than when it started.

Copy link
Contributor

Choose a reason for hiding this comment

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

We planned with @Shastick to implement that one in a different PR, this is only for NET0030 on purpose :)

OK!

Also I'm not sure, but complaining immediately is not an issue based on the standard no?

Not an issue indeed regarding standard indeed.

The intention for the scenario is to assume that we have at least one notification sent (ie, the notification count over the period is non-zero, and/or the total number of notifications at the end of the scenario is higher than when it started.

Alright 👍

@the-glu the-glu force-pushed the user-notifications-missing-fields branch 2 times, most recently from d3966b8 to 6fcca5a Compare February 4, 2025 07:29

filtered_telemetry.append(telemetry)

self.telemetry = filtered_telemetry
Copy link
Contributor

Choose a reason for hiding this comment

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

This is changing behavior of TestFlight.telemetry: at init this does not have anymore the invalid telemetry. Why is that needed? At a quick glance this is notably used by the uss_qualifier injection logic.
In all cases I think that we wouldn't expect the constructor to modify existing data of injection.TestFlight. Adding some fields/accessors though yes. So if we need to have some additionally processed telemetry, rather add it on top of existing data?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's needed because TestFlight functions / helpers are not supporting invalid telemetry: there are a lot of fields accessed in various helpers everywhere (like get_span just bellow ^^').

Maybe we can add a flag to do the telemetry filtering only on purpose, when we inject know-bad telemetry data and have the tests crash with bad telemetry not-on-purpose? But if I'm remember correctly it was not easy to add, as this class is initialized 'deep bellow' under the test layer.

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 forgot: the flag is already added in #916, but inverted (the default is to filter))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So after discussions, I back ported the flag form #916 :)

@the-glu the-glu force-pushed the user-notifications-missing-fields branch from 9febd30 to fd6f219 Compare February 4, 2025 15:56
# We filter out bad telemetry but keep a copy in raw_telemetry
self.raw_telemetry = self.telemetry

verify_telemetry_data = kwargs.pop("verify_telemetry_data", True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason why not putting this as parameter of init with a default value?
(should be OK for existing callers if it is a default value, or not?)

Copy link
Contributor

Choose a reason for hiding this comment

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

Also I'd clarify the name with e.g. filter_invalid_telemetry
I'd expect a parameter named validate to return an error if invalid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you have callers using args and not kwargs, it will behave differently, because it will change the arguments order, so this ensure backward compatibility :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(Field has been renamed)

@the-glu the-glu force-pushed the user-notifications-missing-fields branch from fd6f219 to aecd341 Compare February 5, 2025 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants