chore: establish local platform baseline
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
package rtcconformance
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestRealDeviceRTCCompleteMatrixPasses(t *testing.T) {
|
||||
t.Parallel()
|
||||
capture := rtcFixture("HARDWARE_PROVIDER_CAPTURE")
|
||||
report := Evaluate(capture, capture.CandidateVersion, capture.BuildDigest, time.Now())
|
||||
if report.Result != "PASS" || report.EvidenceScope != "REAL_DEVICE_RTC_PROVIDER" || report.ExternalValidationRequired || report.DeviceCount != 3 || report.SessionCount != 6 {
|
||||
t.Fatalf("unexpected report: %+v", report)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRealDeviceRTCMissingNormalModeFails(t *testing.T) {
|
||||
t.Parallel()
|
||||
capture := rtcFixture("HARDWARE_PROVIDER_CAPTURE")
|
||||
capture.Sessions[2].EngineMode = "s2s_pure"
|
||||
report := Evaluate(capture, capture.CandidateVersion, capture.BuildDigest, time.Now())
|
||||
if report.Result != "FAIL" || !report.ExternalValidationRequired {
|
||||
t.Fatalf("expected failed report: %+v", report)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProtocolSimulationCannotCompleteExternalValidation(t *testing.T) {
|
||||
t.Parallel()
|
||||
capture := rtcFixture("PROTOCOL_SIMULATION")
|
||||
capture.Devices = capture.Devices[:1]
|
||||
capture.Sessions = capture.Sessions[:1]
|
||||
report := Evaluate(capture, capture.CandidateVersion, capture.BuildDigest, time.Now())
|
||||
if report.Result != "PASS" || report.EvidenceScope != "PROTOCOL_SIMULATION" || !report.ExternalValidationRequired {
|
||||
t.Fatalf("unexpected simulation report: %+v", report)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseCaptureRejectsUnknownFields(t *testing.T) {
|
||||
t.Parallel()
|
||||
content, err := json.Marshal(rtcFixture("PROTOCOL_SIMULATION"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
content = []byte(strings.TrimSuffix(string(content), "}") + `,"unexpected":true}`)
|
||||
if _, err = ParseCapture(content); err == nil {
|
||||
t.Fatal("expected unknown field rejection")
|
||||
}
|
||||
}
|
||||
|
||||
func rtcFixture(source string) Capture {
|
||||
startedAt := time.Date(2026, 8, 25, 9, 0, 0, 0, time.UTC)
|
||||
collectedAt := startedAt.Add(3 * time.Hour)
|
||||
devices := make([]DeviceEvidence, 0, 3)
|
||||
for device := 1; device <= 3; device++ {
|
||||
devices = append(devices, DeviceEvidence{DeviceID: fmt.Sprintf("device-%d", device), HardwareModel: "terminal-model", HardwareRevision: fmt.Sprintf("rev-%d", device), FirmwareVersion: "1.0.0", IdentityRef: fmt.Sprintf("identity:%d", device), AudioProfileRef: fmt.Sprintf("audio:%d", device)})
|
||||
}
|
||||
tests := []struct{ mode, scenario string }{
|
||||
{"s2s_pure", "NORMAL_COMPLETION"}, {"s2s_hybrid", "NORMAL_COMPLETION"}, {"cascade", "NORMAL_COMPLETION"},
|
||||
{"s2s_pure", "TOKEN_RENEWAL"}, {"s2s_hybrid", "NETWORK_SWITCH_RECOVERY"}, {"cascade", "CONTROLLED_STOP"},
|
||||
}
|
||||
sessions := make([]SessionEvidence, 0, len(tests))
|
||||
for position, item := range tests {
|
||||
sessions = append(sessions, SessionEvidence{
|
||||
ConversationID: fmt.Sprintf("conversation-%d", position+1), DeviceID: fmt.Sprintf("device-%d", position%3+1), EngineMode: item.mode, Scenario: item.scenario,
|
||||
RoomRef: fmt.Sprintf("room:%d", position+1), DeviceRTCUserRef: fmt.Sprintf("device-user:%d", position+1), AgentRTCUserRef: fmt.Sprintf("agent-user:%d", position+1), ProviderTaskRef: fmt.Sprintf("task:%d", position+1),
|
||||
StartedAt: startedAt.Add(time.Duration(position) * 10 * time.Minute), EndedAt: startedAt.Add(time.Duration(position)*10*time.Minute + 5*time.Minute), Lifecycle: append([]string(nil), RequiredLifecycle...),
|
||||
RTCJoinSucceeded: true, UplinkSucceeded: true, DownlinkSucceeded: true, NearAudioPublished: true, FarAudioPlayed: true,
|
||||
CredentialRenewed: item.scenario == "TOKEN_RENEWAL", NetworkRecovered: item.scenario == "NETWORK_SWITCH_RECOVERY",
|
||||
ProviderStartAccepted: true, ProviderStopConfirmed: true, FinalTranscriptReceived: true, UsageRecorded: true, QualityResult: "PASS", NoDuplicateProviderTask: true, ResourcesReleased: true,
|
||||
CloudEvidenceRef: fmt.Sprintf("cloud:%d", position+1), DeviceEvidenceRef: fmt.Sprintf("device:%d", position+1), ProviderEvidenceRef: fmt.Sprintf("provider:%d", position+1), QualityEvidenceRef: fmt.Sprintf("quality:%d", position+1), UsageEvidenceRef: fmt.Sprintf("usage:%d", position+1),
|
||||
})
|
||||
}
|
||||
environment := "STAGING"
|
||||
if source == "PROTOCOL_SIMULATION" {
|
||||
environment = "LOCAL"
|
||||
}
|
||||
return Capture{
|
||||
SchemaVersion: CaptureSchema, EvidenceSource: source, CandidateVersion: "0.63.0-rc.1", BuildDigest: "sha256:" + strings.Repeat("a", 64), Environment: environment,
|
||||
RTCProviderRef: "volc-rtc:test", VoiceProviderRef: "doubao-voice:test", RTCApplicationRef: "rtc-app:test", RegionRef: "cn-region-a", ChangeTicketRef: "change-20260825",
|
||||
ExecutedByRef: "device-qa", AttestedByRef: "release-qa", AttestedAt: collectedAt.Add(-time.Hour), CollectedAt: collectedAt, Devices: devices, Sessions: sessions,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user