Add capture index manifest for group testing
This commit is contained in:
@@ -55,8 +55,13 @@ public sealed class FileProtocolTelemetrySinkTests : IDisposable
|
||||
|
||||
var captureFile = Directory.GetFiles(captureDirectory, "*.events.ndjson").Single();
|
||||
var contents = await File.ReadAllTextAsync(captureFile);
|
||||
var indexPath = Path.Combine(captureDirectory, "capture-index.ndjson");
|
||||
var indexLines = await File.ReadAllLinesAsync(indexPath);
|
||||
|
||||
Assert.Contains("Notification_20150505", contents);
|
||||
Assert.DoesNotContain(Path.Combine("bin", "Debug"), captureFile, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains(indexLines, line => line.Contains("\"eventType\":\"protocol_record\"", StringComparison.Ordinal));
|
||||
Assert.Contains(indexLines, line => line.Contains("\"servicePrefix\":\"Notification_20150505\"",
|
||||
StringComparison.Ordinal));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,35 @@ public sealed class FileTurnTelemetrySinkTests
|
||||
Assert.Equal(1234, payload.GetProperty("details").GetProperty("bufferedAudioBytes").GetInt32());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RecordsCaptureIndexForTurnDiagnosticsAndErrors()
|
||||
{
|
||||
var directoryPath = Path.Combine(Path.GetTempPath(), "OpenJibo.Tests", Guid.NewGuid().ToString("N"));
|
||||
var sink = new FileTurnTelemetrySink(
|
||||
NullLogger<FileTurnTelemetrySink>.Instance,
|
||||
Options.Create(new TurnTelemetryOptions
|
||||
{
|
||||
Enabled = true,
|
||||
DirectoryPath = directoryPath
|
||||
}));
|
||||
|
||||
await sink.RecordTurnDiagnosticAsync("yes_no_turn_received", new Dictionary<string, object?>
|
||||
{
|
||||
["transID"] = "trans-1",
|
||||
["bufferedAudioBytes"] = 1234
|
||||
});
|
||||
|
||||
await sink.RecordTranscriptError(new InvalidOperationException("boom"), "turn error");
|
||||
|
||||
var indexPath = Path.Combine(directoryPath, "capture-index.ndjson");
|
||||
var lines = await File.ReadAllLinesAsync(indexPath);
|
||||
|
||||
Assert.Contains(lines, line => line.Contains("\"eventType\":\"yes_no_turn_received\"", StringComparison.Ordinal));
|
||||
Assert.Contains(lines, line => line.Contains("\"eventType\":\"transcript_error\"", StringComparison.Ordinal));
|
||||
Assert.Contains(lines, line => line.Contains("\"message\":\"Turn telemetry diagnostic\"", StringComparison.Ordinal));
|
||||
Assert.Contains(lines, line => line.Contains("\"message\":\"Turn telemetry error\"", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RecordsTranscriptErrorOnTurnError()
|
||||
{
|
||||
@@ -148,4 +177,4 @@ public sealed class FileTurnTelemetrySinkTests
|
||||
It.IsAny<CancellationToken>()),
|
||||
Times.AtLeastOnce());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,14 @@ public sealed class FileWebSocketTelemetrySinkTests : IDisposable
|
||||
Assert.Equal(1, document.RootElement.GetProperty("steps").GetArrayLength());
|
||||
Assert.Equal("LISTEN",
|
||||
document.RootElement.GetProperty("steps")[0].GetProperty("expectedReplyTypes")[0].GetString());
|
||||
|
||||
var indexPath = Path.Combine(_directoryPath, "capture-index.ndjson");
|
||||
var indexEntries = await ReadNdjsonAsync(indexPath);
|
||||
Assert.Contains(indexEntries, entry => entry.GetProperty("eventType").GetString() == "connection_opened");
|
||||
Assert.Contains(indexEntries, entry => entry.GetProperty("eventType").GetString() == "message_in");
|
||||
Assert.Contains(indexEntries, entry => entry.GetProperty("eventType").GetString() == "message_out");
|
||||
Assert.Contains(indexEntries, entry => entry.GetProperty("eventType").GetString() == "connection_closed");
|
||||
Assert.Contains(indexEntries, entry => entry.GetProperty("eventType").GetString() == "fixture_export");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -124,4 +132,18 @@ public sealed class FileWebSocketTelemetrySinkTests : IDisposable
|
||||
DirectoryPath = _directoryPath
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<List<JsonElement>> ReadNdjsonAsync(string filePath)
|
||||
{
|
||||
var entries = new List<JsonElement>();
|
||||
foreach (var line in await File.ReadAllLinesAsync(filePath))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(line)) continue;
|
||||
|
||||
using var document = JsonDocument.Parse(line);
|
||||
entries.Add(document.RootElement.Clone());
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user