Skip to content

(Chore): Better telemetry for quarantine query#1100

Open
TylerJang27 wants to merge 1 commit into
tyler/reorganize-report-testsfrom
tyler/better-telemetry-quarantining
Open

(Chore): Better telemetry for quarantine query#1100
TylerJang27 wants to merge 1 commit into
tyler/reorganize-report-testsfrom
tyler/better-telemetry-quarantining

Conversation

@TylerJang27
Copy link
Copy Markdown
Collaborator

@TylerJang27 TylerJang27 commented May 28, 2026

Stacked on #1099. Adds missing observability for the result of querying quarantined tests.

Inputs to quarantine query status:
Screenshot 2026-05-28 at 9 19 50 AM

}

#[test]
fn test_quarantine_query_result_mapper() {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

unit test for this

Comment thread cli/src/upload_command.rs
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>,
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

Comment thread cli/tests/upload.rs
}

#[tokio::test(flavor = "multi_thread")]
async fn telemetry_upload_metrics_quarantine_query_result_success() {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

These CLI integration tests require a bit more custom setup because of the scenarios they test

Comment on lines +8 to +16
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;
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

  • 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Worth making any of those points an inline comment alongside any of those?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

agreed, I think those comments are nice :)

Comment thread test_report/src/report.rs
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum QuarantineLookupSource {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Special enum for the rspec/report case

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

"Integration" tests underlying the rspec flow. Meaningfully distinct from the CLI integration tests above

}
}

fn publish_minimal_success_test(test_report: &MutTestReport) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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-commenter
Copy link
Copy Markdown

codecov-commenter commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.25%. Comparing base (8a07de4) to head (5e8f731).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@trunk-staging-io
Copy link
Copy Markdown

trunk-staging-io Bot commented May 28, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

Failed Test Failure Summary Logs
quarantine_disk_cache The test failed because the quarantine configuration was called more than once for the same repository, which should not happen. Logs ↗︎
Flaky Test Failure Summary Logs
quarantine_disk_cache Logs ↗︎

View Full Report ↗︎Docs

@TylerJang27 TylerJang27 force-pushed the tyler/better-telemetry-quarantining branch from 40ac68a to 5e8f731 Compare May 29, 2026 02:06
Comment thread cli/src/upload_command.rs
Comment on lines 358 to +363
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>,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These arguments are getting kind of long and hard to decipher at call sites. I think we should consider creating an options struct.

Comment on lines +8 to +16
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;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

agreed, I think those comments are nice :)

Comment on lines +84 to +85
assert!(repo_setup_res.is_ok());
assert!(env::set_current_dir(&temp_dir).is_ok());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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(|| {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Comment on lines +146 to +147
let repo_url = "https://github.com/test-org/test-repo-cache-telemetry.git";
set_uncloned_repo_publish_env(repo_url);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants