| 233 | } |
| 234 | |
| 235 | func (f *Framework) AllocPortExcludingRanges(ranges ...[2]int) int { |
| 236 | for range 1000 { |
| 237 | port := f.portAllocator.Get() |
| 238 | ExpectTrue(port > 0, "alloc port failed") |
| 239 | |
| 240 | inExcludedRange := false |
| 241 | for _, portRange := range ranges { |
| 242 | if port >= portRange[0] && port <= portRange[1] { |
| 243 | inExcludedRange = true |
| 244 | break |
| 245 | } |
| 246 | } |
| 247 | if inExcludedRange { |
| 248 | f.portAllocator.Release(port) |
| 249 | continue |
| 250 | } |
| 251 | |
| 252 | f.allocatedPorts = append(f.allocatedPorts, port) |
| 253 | return port |
| 254 | } |
| 255 | |
| 256 | Failf("alloc port outside excluded ranges failed") |
| 257 | return 0 |
| 258 | } |
| 259 | |
| 260 | func (f *Framework) RunServer(portName string, s server.Server) { |
| 261 | f.servers = append(f.servers, s) |