MCPcopy Create free account
hub / github.com/docker/model-test / RunAgentTestSuite

Method RunAgentTestSuite

services/test_runner.go:40–113  ·  view source on GitHub ↗

RunAgentTestSuite executes a test suite using the agent loop approach

(ctx context.Context, testCases []models.TestCase)

Source from the content-addressed store, hash-verified

38
39// RunAgentTestSuite executes a test suite using the agent loop approach
40func (tr *TestRunner) RunAgentTestSuite(ctx context.Context, testCases []models.TestCase) (*models.AgentReport, error) {
41 fmt.Printf("Starting agent test suite with %d test cases\n", len(testCases))
42
43 var wg sync.WaitGroup
44 resultsChan := make(chan models.AgentTestResult, len(testCases))
45
46 // Execute tests concurrently
47 for _, testCase := range testCases {
48 wg.Add(1)
49 go func(tc models.TestCase) {
50 defer wg.Done()
51
52 fmt.Printf("Running agent test: %s\n", tc.Name)
53 result := tr.runAgentTest(ctx, tc)
54 resultsChan <- result
55 }(testCase)
56 }
57
58 // Wait for all tests to complete
59 go func() {
60 wg.Wait()
61 close(resultsChan)
62 }()
63
64 // Collect results and aggregate LLM metrics
65 var results []models.AgentTestResult
66 var totalTime time.Duration
67 var totalLLMRequests int
68 var totalLLMTime time.Duration
69 passedTests := 0
70 failedTests := 0
71
72 for result := range resultsChan {
73 results = append(results, result)
74 totalTime += result.ResponseTime
75
76 // Aggregate LLM metrics from successful responses
77 if result.Response != nil {
78 totalLLMRequests += result.Response.LLMRequests
79 totalLLMTime += result.Response.LLMTotalTime
80 }
81
82 if result.Success {
83 passedTests++
84 } else {
85 failedTests++
86 }
87 }
88
89 // Calculate average times
90 var averageTime time.Duration
91 var avgTimePerReq time.Duration
92 if len(results) > 0 {
93 averageTime = totalTime / time.Duration(len(results))
94 }
95 if totalLLMRequests > 0 {
96 avgTimePerReq = totalLLMTime / time.Duration(totalLLMRequests)
97 }

Callers 1

mainFunction · 0.80

Calls 1

runAgentTestMethod · 0.95

Tested by

no test coverage detected