|
|
|
@ -29,8 +29,8 @@ type Framework struct {
|
|
|
|
|
// ports used in this framework indexed by port name.
|
|
|
|
|
usedPorts map[string]int
|
|
|
|
|
|
|
|
|
|
// record ports alloced by this framework and release them after each test
|
|
|
|
|
allocedPorts []int
|
|
|
|
|
// record ports allocated by this framework and release them after each test
|
|
|
|
|
allocatedPorts []int
|
|
|
|
|
|
|
|
|
|
// portAllocator to alloc port for this test case.
|
|
|
|
|
portAllocator *port.Allocator
|
|
|
|
@ -153,11 +153,11 @@ func (f *Framework) AfterEach() {
|
|
|
|
|
}
|
|
|
|
|
f.usedPorts = make(map[string]int)
|
|
|
|
|
|
|
|
|
|
// release alloced ports
|
|
|
|
|
for _, port := range f.allocedPorts {
|
|
|
|
|
// release allocated ports
|
|
|
|
|
for _, port := range f.allocatedPorts {
|
|
|
|
|
f.portAllocator.Release(port)
|
|
|
|
|
}
|
|
|
|
|
f.allocedPorts = make([]int, 0)
|
|
|
|
|
f.allocatedPorts = make([]int, 0)
|
|
|
|
|
|
|
|
|
|
// clear os envs
|
|
|
|
|
f.osEnvs = make([]string, 0)
|
|
|
|
@ -237,7 +237,7 @@ func (f *Framework) PortByName(name string) int {
|
|
|
|
|
func (f *Framework) AllocPort() int {
|
|
|
|
|
port := f.portAllocator.Get()
|
|
|
|
|
ExpectTrue(port > 0, "alloc port failed")
|
|
|
|
|
f.allocedPorts = append(f.allocedPorts, port)
|
|
|
|
|
f.allocatedPorts = append(f.allocatedPorts, port)
|
|
|
|
|
return port
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|