runRepositoryContentionTest runs the core repository contention test logic
(t *testing.T, servers []*MCPServerProcess, testPrefix string)
| 244 | |
| 245 | // runRepositoryContentionTest runs the core repository contention test logic |
| 246 | func runRepositoryContentionTest(t *testing.T, servers []*MCPServerProcess, testPrefix string) { |
| 247 | numServers := len(servers) |
| 248 | var wg sync.WaitGroup |
| 249 | envIDs := make([]string, numServers) |
| 250 | errors := make([]error, numServers) |
| 251 | |
| 252 | for i := range numServers { |
| 253 | wg.Add(1) |
| 254 | go func(serverIdx int) { |
| 255 | defer wg.Done() |
| 256 | |
| 257 | envID, err := servers[serverIdx].CreateEnvironment( |
| 258 | fmt.Sprintf("%s Test %d", testPrefix, serverIdx), |
| 259 | fmt.Sprintf("Testing %s repository contention %d", testPrefix, serverIdx), |
| 260 | ) |
| 261 | if err != nil { |
| 262 | errors[serverIdx] = fmt.Errorf("environment creation failed: %w", err) |
| 263 | return |
| 264 | } |
| 265 | envIDs[serverIdx] = envID |
| 266 | |
| 267 | for j := range 3 { |
| 268 | err := servers[serverIdx].FileWrite( |
| 269 | envID, |
| 270 | fmt.Sprintf("server%d_file%d.txt", serverIdx, j), |
| 271 | fmt.Sprintf("Content from server %d, file %d\nTimestamp: concurrent test", serverIdx, j), |
| 272 | fmt.Sprintf("Writing file %d from server %d", j, serverIdx), |
| 273 | ) |
| 274 | if err != nil { |
| 275 | errors[serverIdx] = fmt.Errorf("file write failed: %w", err) |
| 276 | return |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | content, err := servers[serverIdx].FileRead(envID, fmt.Sprintf("server%d_file0.txt", serverIdx)) |
| 281 | if err != nil { |
| 282 | errors[serverIdx] = fmt.Errorf("file read failed: %w", err) |
| 283 | return |
| 284 | } |
| 285 | if content == "" { |
| 286 | errors[serverIdx] = fmt.Errorf("file read returned empty content") |
| 287 | return |
| 288 | } |
| 289 | |
| 290 | listOutput, err := servers[serverIdx].RunCommand( |
| 291 | envID, |
| 292 | fmt.Sprintf("ls -la server%d_*.txt | wc -l", serverIdx), |
| 293 | "Count files created by this server", |
| 294 | ) |
| 295 | if err != nil { |
| 296 | errors[serverIdx] = fmt.Errorf("command execution failed: %w", err) |
| 297 | return |
| 298 | } |
| 299 | |
| 300 | lines := strings.Split(strings.TrimSpace(listOutput), "\n") |
| 301 | if len(lines) == 0 { |
| 302 | errors[serverIdx] = fmt.Errorf("command returned empty output") |
| 303 | return |
no test coverage detected