Skip to content

Commit 6910cc7

Browse files
committed
[FAB-7275] Comm test intermittent failure
Sometimees the test TestClientConnections failes. It is probably due to the port being incremented non atomically while the tests are being run in parallel. I made the ports be different per test. Change-Id: Ia0120794a04343e438ec3e65cbab0346bd203ed9 Signed-off-by: yacovm <yacovm@il.ibm.com>
1 parent fb32914 commit 6910cc7

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

core/comm/connection_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ VQQLDAtIeXBlcmxlZGdlcjESMBAGA1UEAwwJbG9jYWxob3N0MFkwEwYHKoZIzj0C
4949
func TestClientConnections(t *testing.T) {
5050
t.Parallel()
5151

52-
testPort := 9050
5352
//use Org1 test crypto material
5453
fileBase := "Org1"
5554
certPEMBlock, _ := ioutil.ReadFile(filepath.Join("testdata", "certs", fileBase+"-server1-cert.pem"))
@@ -64,12 +63,14 @@ func TestClientConnections(t *testing.T) {
6463
creds credentials.TransportCredentials
6564
clientPort int
6665
fail bool
66+
serverPort int
6767
}{
6868
{
6969
name: "ValidConnection",
7070
sc: ServerConfig{
7171
SecOpts: &SecureOptions{
7272
UseTLS: false}},
73+
serverPort: 8050,
7374
},
7475
{
7576
name: "InvalidConnection",
@@ -78,6 +79,7 @@ func TestClientConnections(t *testing.T) {
7879
UseTLS: false}},
7980
clientPort: 20040,
8081
fail: true,
82+
serverPort: 8051,
8183
},
8284
{
8385
name: "ValidConnectionTLS",
@@ -86,7 +88,8 @@ func TestClientConnections(t *testing.T) {
8688
UseTLS: true,
8789
ServerCertificate: certPEMBlock,
8890
ServerKey: keyPEMBlock}},
89-
creds: credentials.NewClientTLSFromCert(certPool, ""),
91+
creds: credentials.NewClientTLSFromCert(certPool, ""),
92+
serverPort: 8052,
9093
},
9194
{
9295
name: "InvalidConnectionTLS",
@@ -95,8 +98,9 @@ func TestClientConnections(t *testing.T) {
9598
UseTLS: true,
9699
ServerCertificate: certPEMBlock,
97100
ServerKey: keyPEMBlock}},
98-
creds: credentials.NewClientTLSFromCert(nil, ""),
99-
fail: true,
101+
creds: credentials.NewClientTLSFromCert(nil, ""),
102+
fail: true,
103+
serverPort: 8053,
100104
},
101105
}
102106

@@ -105,8 +109,7 @@ func TestClientConnections(t *testing.T) {
105109
t.Run(test.name, func(t *testing.T) {
106110
t.Parallel()
107111
t.Logf("Running test %s ...", test.name)
108-
testPort++
109-
serverAddress := fmt.Sprintf("localhost:%d", testPort)
112+
serverAddress := fmt.Sprintf("localhost:%d", test.serverPort)
110113
clientAddress := serverAddress
111114
if test.clientPort > 0 {
112115
clientAddress = fmt.Sprintf("localhost:%d", test.clientPort)

0 commit comments

Comments
 (0)