(Chore): Better telemetry for quarantine query#1100
Conversation
| } | ||
|
|
||
| #[test] | ||
| fn test_quarantine_query_result_mapper() { |
There was a problem hiding this comment.
unit test for this
| pre_test_context: Option<PreTestContext>, | ||
| test_run_result: Option<TestRunResult>, | ||
| render_sender: Option<Sender<DisplayMessage>>, | ||
| quarantine_query_result_override: Option<proto::upload_metrics::trunk::QuarantineQueryResult>, |
There was a problem hiding this comment.
RSpec calls the quarantine config at a separate time than the upload flow. There's a gate above this where we conditionally call GetQuarantineConfig depending on if there are JUnits (which there aren't in RSpec). That's a smell, but I didn't want to undertake that refactor right now, and it's not a meaningful increase in burden to wire in a quarantine query result override here
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread")] | ||
| async fn telemetry_upload_metrics_quarantine_query_result_success() { |
There was a problem hiding this comment.
These CLI integration tests require a bit more custom setup because of the scenarios they test
| enum QuarantineQueryResult { | ||
| QUARANTINE_QUERY_RESULT_UNSPECIFIED = 0; | ||
| QUARANTINE_QUERY_RESULT_SUCCESS = 1; | ||
| QUARANTINE_QUERY_RESULT_FAILURE = 2; | ||
| QUARANTINE_QUERY_RESULT_DISABLED = 3; | ||
| QUARANTINE_QUERY_RESULT_SKIPPED = 4; | ||
| // rspec only | ||
| QUARANTINE_QUERY_RESULT_CACHED = 5; | ||
| } |
There was a problem hiding this comment.
- Unspecified: default, shouldn't be sent from new CLI versions in practice
- Success: we successfully got quarantined results back
- Failure: something went wrong. This could also be an auth error (403/404), but we don't differentiate rn here. Realistically we want to track both
- Disabled: either disabled via the command line/env var, or via the repo setting (from our db)
- Skipped: no tests actually failed, no need to look up quarantine config
- Cached: rspec only, quarantined results served from file on disk
There was a problem hiding this comment.
Worth making any of those points an inline comment alongside any of those?
There was a problem hiding this comment.
agreed, I think those comments are nice :)
| } | ||
|
|
||
| #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| enum QuarantineLookupSource { |
There was a problem hiding this comment.
Special enum for the rspec/report case
There was a problem hiding this comment.
"Integration" tests underlying the rspec flow. Meaningfully distinct from the CLI integration tests above
| } | ||
| } | ||
|
|
||
| fn publish_minimal_success_test(test_report: &MutTestReport) { |
There was a problem hiding this comment.
This helper keeps things simple for most of the tests below. Note that test_report.publish() is what calls upload and the telemetry call
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## tyler/reorganize-report-tests #1100 +/- ##
=================================================================
+ Coverage 82.15% 82.25% +0.09%
=================================================================
Files 69 69
Lines 15039 15114 +75
=================================================================
+ Hits 12356 12432 +76
+ Misses 2683 2682 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
40ac68a to
5e8f731
Compare
| pub async fn run_upload( | ||
| upload_args: UploadArgs, | ||
| pre_test_context: Option<PreTestContext>, | ||
| test_run_result: Option<TestRunResult>, | ||
| render_sender: Option<Sender<DisplayMessage>>, | ||
| quarantine_query_result_override: Option<proto::upload_metrics::trunk::QuarantineQueryResult>, |
There was a problem hiding this comment.
These arguments are getting kind of long and hard to decipher at call sites. I think we should consider creating an options struct.
| enum QuarantineQueryResult { | ||
| QUARANTINE_QUERY_RESULT_UNSPECIFIED = 0; | ||
| QUARANTINE_QUERY_RESULT_SUCCESS = 1; | ||
| QUARANTINE_QUERY_RESULT_FAILURE = 2; | ||
| QUARANTINE_QUERY_RESULT_DISABLED = 3; | ||
| QUARANTINE_QUERY_RESULT_SKIPPED = 4; | ||
| // rspec only | ||
| QUARANTINE_QUERY_RESULT_CACHED = 5; | ||
| } |
There was a problem hiding this comment.
agreed, I think those comments are nice :)
| assert!(repo_setup_res.is_ok()); | ||
| assert!(env::set_current_dir(&temp_dir).is_ok()); |
There was a problem hiding this comment.
nit, optional: I'd say to just unwrap these since it's functionality equivalent and more succinct. Same goes for any other tests.
| env::set_var(TRUNK_QUARANTINED_TESTS_DISK_CACHE_TTL_SECS_ENV, "0"); | ||
| } | ||
|
|
||
| thread::spawn(|| { |
There was a problem hiding this comment.
is there a specific reason to do this in a separate thread? same goes for the other tests
| async fn telemetry_query_result_skipped_without_lookup_on_publish() { | ||
| cleanup_env_vars(); | ||
| let temp_dir = tempdir().unwrap(); | ||
| let _ = env::set_current_dir(&temp_dir); |
There was a problem hiding this comment.
nit, optional: I'd just unwrap on this rather than drop it. If the env isn't set, this test will fail, no? same goes for the other tests
| let repo_url = "https://github.com/test-org/test-repo-cache-telemetry.git"; | ||
| set_uncloned_repo_publish_env(repo_url); |
There was a problem hiding this comment.
nit, optional: Some tests define repo_url others just put the string inline for the set_uncloned_repo_publish_env call. IMO, make it consistent and put this string inline
Stacked on #1099. Adds missing observability for the result of querying quarantined tests.
Inputs to quarantine query status:
