Skip to content

Commit a062eb8

Browse files
kaihofNao Nishijima
authored and
Nao Nishijima
committed
[FAB-4902] Fix to set the GOMAXPROCS in UT
Config "peer.gomaxprocs" is not reflected in some unit tests. They read the config, but apply a fixed value or don't apply it. Thic patch fixes to set the number of maxprocs with "peer.gomaxprocs" rather than a fixed value. Change-Id: If347286cad44bad31b0cca719b23f45e40aa2930 Signed-off-by: Kaiho Fukuchi <[email protected]>
1 parent 3bc937e commit a062eb8

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

core/chaincode/exectransaction_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1812,7 +1812,7 @@ func setupTestConfig() {
18121812

18131813
// Set the number of maxprocs
18141814
var numProcsDesired = viper.GetInt("peer.gomaxprocs")
1815-
chaincodeLogger.Debugf("setting Number of procs to %d, was %d\n", numProcsDesired, runtime.GOMAXPROCS(2))
1815+
chaincodeLogger.Debugf("setting Number of procs to %d, was %d\n", numProcsDesired, runtime.GOMAXPROCS(numProcsDesired))
18161816

18171817
// Init the BCCSP
18181818
err = factory.InitFactories(nil)

core/endorser/endorser_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"io/ioutil"
2323
"net"
2424
"os"
25+
"runtime"
2526
"strings"
2627
"testing"
2728
"time"
@@ -750,7 +751,7 @@ func setupTestConfig() {
750751
testutil.SetupTestLogging()
751752

752753
// Set the number of maxprocs
753-
viper.GetInt("peer.gomaxprocs")
754+
runtime.GOMAXPROCS(viper.GetInt("peer.gomaxprocs"))
754755

755756
// Init the BCCSP
756757
var bccspConfig *factory.FactoryOpts

core/testutil/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func SetupTestConfig() {
8383

8484
// Set the number of maxprocs
8585
var numProcsDesired = viper.GetInt("peer.gomaxprocs")
86-
configLogger.Debugf("setting Number of procs to %d, was %d\n", numProcsDesired, runtime.GOMAXPROCS(2))
86+
configLogger.Debugf("setting Number of procs to %d, was %d\n", numProcsDesired, runtime.GOMAXPROCS(numProcsDesired))
8787

8888
// Init the BCCSP
8989
var bccspConfig *factory.FactoryOpts

0 commit comments

Comments
 (0)