aKode fase 2c: eliminato il codice di invio dati (crate analytics, otel-trace-websocket, sentry, esportatori OTLP); /feedback salva solo in locale; chiavi legacy [analytics]/[otel] accettate e ignorate; test di analytics/OTLP/upload rimossi
Some checks failed
blocking-ci / rust-ci (push) Has been cancelled
blocking-ci / sdk (push) Has been cancelled
blocking-ci / CI required (push) Has been cancelled
blocking-ci / Bazel (push) Has been cancelled
blocking-ci / Blob size policy (push) Has been cancelled
blocking-ci / cargo-deny (push) Has been cancelled
blocking-ci / Codespell (push) Has been cancelled
blocking-ci / repo-checks (push) Has been cancelled
postmerge-ci / rust-ci-full (push) Has been cancelled
postmerge-ci / v8-canary (push) Has been cancelled
postmerge-ci / Postmerge CI results (push) Has been cancelled
Some checks failed
blocking-ci / rust-ci (push) Has been cancelled
blocking-ci / sdk (push) Has been cancelled
blocking-ci / CI required (push) Has been cancelled
blocking-ci / Bazel (push) Has been cancelled
blocking-ci / Blob size policy (push) Has been cancelled
blocking-ci / cargo-deny (push) Has been cancelled
blocking-ci / Codespell (push) Has been cancelled
blocking-ci / repo-checks (push) Has been cancelled
postmerge-ci / rust-ci-full (push) Has been cancelled
postmerge-ci / v8-canary (push) Has been cancelled
postmerge-ci / Postmerge CI results (push) Has been cancelled
This commit is contained in:
@@ -2,16 +2,12 @@
|
||||
|
||||
//! Unit tests for the crate and its related test suites.
|
||||
|
||||
use std::ffi::OsStr;
|
||||
use std::fs;
|
||||
|
||||
use super::*;
|
||||
use crate::FeedbackDiagnostic;
|
||||
use codex_http_client::OutboundProxyPolicy;
|
||||
use pretty_assertions::assert_eq;
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
use wiremock::MockServer;
|
||||
|
||||
#[test]
|
||||
fn ring_buffer_drops_front_when_full() {
|
||||
@@ -94,132 +90,6 @@ fn metadata_layer_records_tags_from_feedback_target() {
|
||||
pretty_assertions::assert_eq!(snap.tags.get("cached").map(String::as_str), Some("true"));
|
||||
}
|
||||
|
||||
async fn upload_test_feedback(
|
||||
feedback: &CodexFeedback,
|
||||
dsn: &str,
|
||||
extra_attachments: Vec<FeedbackAttachment>,
|
||||
) -> Result<()> {
|
||||
feedback
|
||||
.snapshot(/*session_id*/ None)
|
||||
.with_feedback_diagnostics(FeedbackDiagnostics::default())
|
||||
.upload_feedback_with_dsn(
|
||||
FeedbackUploadOptions {
|
||||
classification: "bug",
|
||||
reason: Some("private feedback"),
|
||||
tags: None,
|
||||
include_logs: true,
|
||||
extra_attachments,
|
||||
extra_attachment_paths: &[],
|
||||
session_source: Some(SessionSource::Cli),
|
||||
logs_override: Some(b"private log contents".to_vec()),
|
||||
},
|
||||
&HttpClientFactory::new(OutboundProxyPolicy::ReqwestDefault),
|
||||
dsn,
|
||||
Instant::now() + UPLOAD_TIMEOUT,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
// aKode: feedback is never uploaded; the upload path fails without sending any request.
|
||||
#[tokio::test]
|
||||
async fn feedback_upload_is_disabled_and_sends_nothing() {
|
||||
let server = MockServer::start().await;
|
||||
let dsn = format!("http://public@{}/42", server.address());
|
||||
|
||||
upload_test_feedback(&CodexFeedback::new(), &dsn, Vec::new())
|
||||
.await
|
||||
.expect_err("feedback upload must be disabled");
|
||||
|
||||
assert!(server.received_requests().await.unwrap().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn feedback_attachments_gate_connectivity_diagnostics() {
|
||||
let extra_filename = format!("codex-feedback-extra-{}.jsonl", ThreadId::new());
|
||||
let extra_path = std::env::temp_dir().join(&extra_filename);
|
||||
let extra_attachment_path = FeedbackAttachmentPath {
|
||||
path: extra_path.clone(),
|
||||
attachment_filename_override: None,
|
||||
};
|
||||
fs::write(&extra_path, "rollout").expect("extra attachment should be written");
|
||||
|
||||
let snapshot_with_diagnostics = CodexFeedback::new()
|
||||
.snapshot(/*session_id*/ None)
|
||||
.with_feedback_diagnostics(FeedbackDiagnostics::new(vec![FeedbackDiagnostic {
|
||||
headline: "Proxy environment variables are set and may affect connectivity."
|
||||
.to_string(),
|
||||
details: vec!["HTTPS_PROXY = https://example.com:443".to_string()],
|
||||
}]));
|
||||
|
||||
let attachments_with_diagnostics = snapshot_with_diagnostics
|
||||
.feedback_attachments(
|
||||
&sentry::protocol::EnvelopeHeaders::default(),
|
||||
/*include_logs*/ true,
|
||||
vec![FeedbackAttachment {
|
||||
filename: DOCTOR_REPORT_ATTACHMENT_FILENAME.to_string(),
|
||||
content_type: Some("application/json".to_string()),
|
||||
buffer: b"{\"overallStatus\":\"ok\"}".to_vec(),
|
||||
}],
|
||||
&[extra_attachment_path],
|
||||
Some(vec![1]),
|
||||
)
|
||||
.collect::<Result<Vec<_>>>()
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
attachments_with_diagnostics
|
||||
.iter()
|
||||
.map(|attachment| attachment.filename.as_str())
|
||||
.collect::<Vec<_>>(),
|
||||
vec![
|
||||
"codex-logs.log",
|
||||
DOCTOR_REPORT_ATTACHMENT_FILENAME,
|
||||
FEEDBACK_DIAGNOSTICS_ATTACHMENT_FILENAME,
|
||||
extra_filename.as_str()
|
||||
]
|
||||
);
|
||||
assert_eq!(attachments_with_diagnostics[0].buffer, vec![1]);
|
||||
assert_eq!(
|
||||
attachments_with_diagnostics[1].buffer,
|
||||
b"{\"overallStatus\":\"ok\"}".to_vec()
|
||||
);
|
||||
assert_eq!(
|
||||
attachments_with_diagnostics[2].buffer,
|
||||
b"Connectivity diagnostics\n\n- Proxy environment variables are set and may affect connectivity.\n - HTTPS_PROXY = https://example.com:443".to_vec()
|
||||
);
|
||||
assert_eq!(attachments_with_diagnostics[3].buffer, b"rollout".to_vec());
|
||||
assert_eq!(
|
||||
attachments_with_diagnostics[3].content_type.as_deref(),
|
||||
Some("text/plain")
|
||||
);
|
||||
assert_eq!(
|
||||
OsStr::new(attachments_with_diagnostics[3].filename.as_str()),
|
||||
OsStr::new(extra_filename.as_str())
|
||||
);
|
||||
let attachments_without_diagnostics = CodexFeedback::new()
|
||||
.snapshot(/*session_id*/ None)
|
||||
.with_feedback_diagnostics(FeedbackDiagnostics::default())
|
||||
.feedback_attachments(
|
||||
&sentry::protocol::EnvelopeHeaders::default(),
|
||||
/*include_logs*/ true,
|
||||
Vec::new(),
|
||||
&[],
|
||||
Some(vec![1]),
|
||||
)
|
||||
.collect::<Result<Vec<_>>>()
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
attachments_without_diagnostics
|
||||
.iter()
|
||||
.map(|attachment| attachment.filename.as_str())
|
||||
.collect::<Vec<_>>(),
|
||||
vec!["codex-logs.log"]
|
||||
);
|
||||
assert_eq!(attachments_without_diagnostics[0].buffer, vec![1]);
|
||||
fs::remove_file(extra_path).expect("extra attachment should be removed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn path_backed_attachments_use_binary_content_types() {
|
||||
let suffix = ThreadId::new();
|
||||
@@ -232,26 +102,18 @@ fn path_backed_attachments_use_binary_content_types() {
|
||||
fs::write(&gzip_path, gzip_bytes).expect("gzip attachment should be written");
|
||||
fs::write(&unknown_path, unknown_bytes).expect("unknown attachment should be written");
|
||||
|
||||
let attachments = CodexFeedback::new()
|
||||
.snapshot(/*session_id*/ None)
|
||||
.feedback_attachments(
|
||||
&sentry::protocol::EnvelopeHeaders::default(),
|
||||
/*include_logs*/ false,
|
||||
Vec::new(),
|
||||
&[
|
||||
FeedbackAttachmentPath {
|
||||
path: gzip_path.clone(),
|
||||
attachment_filename_override: None,
|
||||
},
|
||||
FeedbackAttachmentPath {
|
||||
path: unknown_path.clone(),
|
||||
attachment_filename_override: None,
|
||||
},
|
||||
],
|
||||
/*logs_override*/ None,
|
||||
)
|
||||
.collect::<Result<Vec<_>>>()
|
||||
.unwrap();
|
||||
let attachments = [&gzip_path, &unknown_path]
|
||||
.into_iter()
|
||||
.map(|path| {
|
||||
FeedbackAttachmentPath {
|
||||
path: path.clone(),
|
||||
attachment_filename_override: None,
|
||||
}
|
||||
.read_attachment(DEFAULT_MAX_BYTES)
|
||||
.unwrap()
|
||||
.expect("attachment should be readable")
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
fs::remove_file(gzip_path).expect("gzip attachment should be removed");
|
||||
fs::remove_file(unknown_path).expect("unknown attachment should be removed");
|
||||
@@ -280,7 +142,7 @@ fn path_backed_attachments_use_binary_content_types() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn upload_tags_include_client_tags_and_preserve_reserved_fields() {
|
||||
fn report_tags_include_client_tags_and_preserve_reserved_fields() {
|
||||
let mut tags = BTreeMap::new();
|
||||
tags.insert("thread_id".to_string(), "wrong-thread".to_string());
|
||||
tags.insert("turn_id".to_string(), "wrong-turn".to_string());
|
||||
@@ -320,7 +182,7 @@ fn upload_tags_include_client_tags_and_preserve_reserved_fields() {
|
||||
client_tags.insert("model".to_string(), "mewthree".to_string());
|
||||
client_tags.insert("effort".to_string(), "Some(Ultra)".to_string());
|
||||
|
||||
let upload_tags = snapshot.upload_tags(
|
||||
let report_tags = snapshot.report_tags(
|
||||
"bug",
|
||||
Some("actual reason"),
|
||||
Some(&client_tags),
|
||||
@@ -328,39 +190,39 @@ fn upload_tags_include_client_tags_and_preserve_reserved_fields() {
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
upload_tags.get("thread_id").map(String::as_str),
|
||||
report_tags.get("thread_id").map(String::as_str),
|
||||
Some("thread-123")
|
||||
);
|
||||
assert_eq!(
|
||||
upload_tags.get("turn_id").map(String::as_str),
|
||||
report_tags.get("turn_id").map(String::as_str),
|
||||
Some("turn-456")
|
||||
);
|
||||
assert_eq!(
|
||||
upload_tags.get("classification").map(String::as_str),
|
||||
report_tags.get("classification").map(String::as_str),
|
||||
Some("bug")
|
||||
);
|
||||
assert_eq!(
|
||||
upload_tags.get("session_source").map(String::as_str),
|
||||
report_tags.get("session_source").map(String::as_str),
|
||||
Some("cli")
|
||||
);
|
||||
assert_eq!(
|
||||
upload_tags.get("reason").map(String::as_str),
|
||||
report_tags.get("reason").map(String::as_str),
|
||||
Some("actual reason")
|
||||
);
|
||||
assert_eq!(
|
||||
upload_tags.get("account_id").map(String::as_str),
|
||||
report_tags.get("account_id").map(String::as_str),
|
||||
Some("actual-account")
|
||||
);
|
||||
assert_eq!(
|
||||
upload_tags.get("model").map(String::as_str),
|
||||
report_tags.get("model").map(String::as_str),
|
||||
Some("mewthree")
|
||||
);
|
||||
assert_eq!(
|
||||
upload_tags.get("effort").map(String::as_str),
|
||||
report_tags.get("effort").map(String::as_str),
|
||||
Some("Some(Ultra)")
|
||||
);
|
||||
assert_eq!(
|
||||
upload_tags.get("client_tag").map(String::as_str),
|
||||
report_tags.get("client_tag").map(String::as_str),
|
||||
Some("from-client")
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user