Skip to content

refactor: update log output formatting in tests for clarity #786

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

Merged
Merged
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
27 changes: 13 additions & 14 deletions core/src/ten_manager/tests/test_case/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ mod tests {

// Get the first chunk.
let chunk = stream.next().await.expect("Should receive data")?;
println!("chunk: {:?}", chunk);
println!("chunk 1: {:?}", chunk);
assert_eq!(chunk.line, test_content);

// Write more content to the file.
Expand All @@ -52,7 +52,7 @@ mod tests {

// Get the second chunk.
let chunk = stream.next().await;
println!("chunk: {:?}", chunk);
println!("chunk 2: {:?}", chunk);
match chunk {
Some(chunk) => match chunk {
Ok(chunk) => assert_eq!(chunk.line, more_content),
Expand Down Expand Up @@ -102,7 +102,7 @@ mod tests {

// Get the first chunk
let chunk = stream.next().await.expect("Should receive data")?;
println!("chunk: {:?}", chunk);
println!("chunk 1: {:?}", chunk);
assert_eq!(chunk.line, "Initial content");

// Simulate log rotation - delete and recreate file
Expand All @@ -124,7 +124,7 @@ mod tests {
// Get the content after rotation
let chunk =
stream.next().await.expect("Should receive rotated data")?;
println!("chunk: {:?}", chunk);
println!("chunk 2: {:?}", chunk);
assert_eq!(chunk.line, "Rotated content");

// Stop watching
Expand Down Expand Up @@ -156,7 +156,7 @@ mod tests {

// Get the first chunk.
let chunk = stream.next().await.expect("Should receive data")?;
println!("chunk: {:?}", chunk);
println!("chunk 1: {:?}", chunk);
assert_eq!(chunk.line, "Test content");

// Wait for the timeout to occur (no new content being written).
Expand Down Expand Up @@ -195,16 +195,15 @@ mod tests {
\"msgpack://127.0.0.1:8001/\", \"graph name\": \"\", \"graph \
id\": \"38097178-1712-4562-b60d-8e6ab15ba0cf\", \
\"extension_threads\": {\"1713045\": {\"extensions\": \
[\"test_extension\"]}}}";
[\"test_extension\"]}}}\n";

temp_file.write_all(graph_resources_with_thread.as_bytes())?;
temp_file.write_all(b"\n")?;
temp_file.flush()?;

// Get the graph resources line
let chunk =
stream.next().await.expect("Should receive graph resources")?;
println!("chunk: {:?}", chunk);
println!("chunk 1: {:?}", chunk);
assert!(chunk.line.contains("[graph resources]"));

// Now write logs that contain extension metadata in format
Expand All @@ -225,27 +224,27 @@ mod tests {
.next()
.await
.expect("Should receive log with extension")?;
println!("chunk: {:?}", chunk);
println!("chunk 2: {:?}", chunk);
assert!(chunk.line.contains("on_start()"));

// The metadata should include the extension name
assert!(chunk.metadata.is_some(), "Should have metadata");
let metadata = chunk.metadata.unwrap();
println!("metadata: {:?}", metadata);
println!("metadata 2: {:?}", metadata);
assert_eq!(metadata.extension, Some("test_extension".to_string()));

// Get second log with extension metadata
let chunk = stream
.next()
.await
.expect("Should receive log with extension")?;
println!("chunk: {:?}", chunk);
println!("chunk 3: {:?}", chunk);
assert!(chunk.line.contains("on_start() done"));

// The metadata should include the extension name
assert!(chunk.metadata.is_some(), "Should have metadata");
let metadata = chunk.metadata.unwrap();
println!("metadata: {:?}", metadata);
println!("metadata 3: {:?}", metadata);
assert_eq!(metadata.extension, Some("test_extension".to_string()));

// Stop watching
Expand Down Expand Up @@ -376,10 +375,9 @@ mod tests {
05-02 22:23:37.535 1713000(1713002) D \
ten_protocol_integrated_on_close@close.c:107 \
[2b11c6a8-9a63-4e9e-b18a-92456dee49d5] Integrated protocol \
can be closed now";
can be closed now\n";

temp_file.write_all(complete_log.as_bytes())?;
temp_file.write_all(b"\n")?;
temp_file.flush()?;

// We need to iterate through all log lines to find the specific
Expand All @@ -395,6 +393,7 @@ mod tests {
// Process all log lines
while let Some(result) = stream.next().await {
let chunk = result?;
println!("chunk: {:?}", chunk);

// Check if this is one of our target lines
if chunk.line.contains(target_start_line)
Expand Down
Loading