Skip to content
  • YACOVM's avatar
    [FAB-3941] Fix UT failure of port collision · a0c3b954
    YACOVM authored
    
    
    This commit fixes the following possible failure:
    
    panic: listen tcp 127.0.0.1:7050: bind: address already in use [recovered]
    panic: listen tcp 127.0.0.1:7050: bind: address already in use
    
    goroutine 167 [running]:
    panic(0x95a0c0, 0xc4203993b0)
    /opt/go/src/runtime/panic.go:500 +0x1a1
    testing.tRunner.func1(0xc420097200)
    /opt/go/src/testing/testing.go:579 +0x25d
    panic(0x95a0c0, 0xc4203993b0)
    /opt/go/src/runtime/panic.go:458 +0x243
    github.com/hyperledger/fabric/peer/channel.newOrderer
    /opt/gopath/src/github.com/hyperledger/fabric/peer/channel/create_test.go:53
    github.com/hyperledger/fabric/peer/channel.TestCreateChainWithTimeoutErr
    /opt/gopath/src/github.com/hyperledger/fabric/peer/channel/create_test.go:258
    testing.tRunner(0xc420097200, 0xa3cf48)
    /opt/go/src/testing/testing.go:610 +0x81
    created by testing.(*T).Run
    /opt/go/src/testing/testing.go:646 +0x2ec
    FAIL github.com/hyperledger/fabric/peer/channel 3.168s
    error: exit status 1
    panic: EOF
    
    I think this happens because the client doesn't close the connection
    and the server port remains in TIME_WAIT and since we have 2 tests that bind
    to the same port, the one that runs the 2nd time - fails.
    
    The easiest way to solve this is simply by changing the port numbers
    that are used in the test, but I simply added a connection close
    to the getGenesisBlock method.
    
    Change-Id: Ia08c3d8d10a8e01cf96ea2789b4d236921b850b5
    Signed-off-by: default avatarYacov Manevich <yacovm@il.ibm.com>
    a0c3b954