Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions cli/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -913,20 +913,20 @@ pub(crate) mod tests {
}

async fn stalled_keychain_lookup() -> Result<
Option<services::telemetry_credential_storage::TelemetryCredential>,
services::telemetry_credential_storage::TelemetryCredentialLookup,
services::token_storage::TokenStorageError,
> {
let _ = tokio::task::spawn_blocking(|| std::thread::sleep(Duration::from_hours(1))).await;
Ok(None)
Ok(services::telemetry_credential_storage::TelemetryCredentialLookup::Missing)
}

async fn stalled_blocking_database_lookup() -> Result<
Option<services::telemetry_credential_storage::TelemetryCredential>,
services::telemetry_credential_storage::TelemetryCredentialLookup,
services::token_storage::TokenStorageError,
> {
tokio::task::yield_now().await;
std::thread::sleep(Duration::from_hours(1));
Ok(None)
Ok(services::telemetry_credential_storage::TelemetryCredentialLookup::Missing)
}

#[test]
Expand Down Expand Up @@ -990,7 +990,11 @@ pub(crate) mod tests {
false,
|| true,
|_: &std::path::Path| Some("repository-a".to_string()),
|_: String| stalled_keychain_lookup(),
|_: String| async {
stalled_keychain_lookup().await.map(
services::telemetry_credential_storage::TelemetryCredentialLookup::into_valid,
)
},
));
finish_runtime(runtime);
let mut stdout = Vec::new();
Expand Down
14 changes: 0 additions & 14 deletions cli/src/app/doctor_reconciliation_cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const RECONCILIATION_DETAIL_PREFIX: &str = "Snapshot ref reconciliation";

const AUTH_DB_TEST_SECRET: &str = "doctor-cli-test-secret";
const UNREADABLE_AUTH_DB: &[u8] = b"not an encrypted auth database";
const FAR_FUTURE_READINESS: &[u8] = br#"{"expires_at_unix_seconds":4102444800}"#;

const TELEMETRY_ENABLED_CONFIG: &str = r#"{"telemetry":{"enabled":true}}"#;
const TELEMETRY_OPT_IN_NOTE: &str = "Managed telemetry export is off because telemetry.enabled is not true; set telemetry.enabled: true in the global SCE config to resume it.";
Expand Down Expand Up @@ -644,7 +643,6 @@ async fn doctor_on_fresh_state_reports_unconfigured_telemetry_without_a_warning(
let warnings = global_state_warnings(&report);
assert!(warnings.is_empty(), "{warnings:#?}");
assert!(!auth_dir.join("auth.db").exists());
assert!(!auth_dir.join("telemetry-ready.json").exists());
}

#[tokio::test(flavor = "multi_thread")]
Expand All @@ -653,9 +651,7 @@ async fn doctor_fix_reports_unreadable_telemetry_credentials_without_auth_side_e
let auth_dir = sandbox.state_root().join("sce");
std::fs::create_dir_all(&auth_dir).expect("auth dir");
let auth_db = auth_dir.join("auth.db");
let readiness = auth_dir.join("telemetry-ready.json");
std::fs::write(&auth_db, UNREADABLE_AUTH_DB).expect("auth DB");
std::fs::write(&readiness, FAR_FUTURE_READINESS).expect("readiness");
let config = sandbox.telemetry_enabled_config();
let env = [
(AUTH_DB_ENCRYPTION_KEY_ENV, AUTH_DB_TEST_SECRET),
Expand Down Expand Up @@ -699,10 +695,6 @@ async fn doctor_fix_reports_unreadable_telemetry_credentials_without_auth_side_e
std::fs::read(&auth_db).expect("auth DB kept"),
UNREADABLE_AUTH_DB
);
assert_eq!(
std::fs::read(&readiness).expect("readiness kept"),
FAR_FUTURE_READINESS
);
assert!(!fix.stdout.contains(AUTH_DB_TEST_SECRET));
assert!(!fix.stderr.contains(AUTH_DB_TEST_SECRET));
}
Expand Down Expand Up @@ -766,9 +758,7 @@ async fn doctor_with_telemetry_disabled_by_config_never_reads_the_auth_db() {

std::fs::create_dir_all(&auth_dir).expect("auth dir");
let auth_db = auth_dir.join("auth.db");
let readiness = auth_dir.join("telemetry-ready.json");
std::fs::write(&auth_db, UNREADABLE_AUTH_DB).expect("auth DB");
std::fs::write(&readiness, FAR_FUTURE_READINESS).expect("readiness");

let report = sandbox
.run_with_env(&["doctor", "--format", "json"], &env)
Expand Down Expand Up @@ -798,8 +788,4 @@ async fn doctor_with_telemetry_disabled_by_config_never_reads_the_auth_db() {
std::fs::read(&auth_db).expect("auth DB kept"),
UNREADABLE_AUTH_DB
);
assert_eq!(
std::fs::read(&readiness).expect("readiness kept"),
FAR_FUTURE_READINESS
);
}
Loading
Loading