From a062eb83fbe2e2ed43ff66d0cfe1638669a9d761 Mon Sep 17 00:00:00 2001 From: Kaiho Fukuchi Date: Sat, 24 Jun 2017 04:34:51 +0900 Subject: [PATCH] [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 --- core/chaincode/exectransaction_test.go | 2 +- core/endorser/endorser_test.go | 3 ++- core/testutil/config.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/chaincode/exectransaction_test.go b/core/chaincode/exectransaction_test.go index b00eaff34d9..7b60fd864bc 100644 --- a/core/chaincode/exectransaction_test.go +++ b/core/chaincode/exectransaction_test.go @@ -1812,7 +1812,7 @@ func setupTestConfig() { // Set the number of maxprocs var numProcsDesired = viper.GetInt("peer.gomaxprocs") - chaincodeLogger.Debugf("setting Number of procs to %d, was %d\n", numProcsDesired, runtime.GOMAXPROCS(2)) + chaincodeLogger.Debugf("setting Number of procs to %d, was %d\n", numProcsDesired, runtime.GOMAXPROCS(numProcsDesired)) // Init the BCCSP err = factory.InitFactories(nil) diff --git a/core/endorser/endorser_test.go b/core/endorser/endorser_test.go index 3e83dc9a33d..77fcb74cf20 100644 --- a/core/endorser/endorser_test.go +++ b/core/endorser/endorser_test.go @@ -22,6 +22,7 @@ import ( "io/ioutil" "net" "os" + "runtime" "strings" "testing" "time" @@ -750,7 +751,7 @@ func setupTestConfig() { testutil.SetupTestLogging() // Set the number of maxprocs - viper.GetInt("peer.gomaxprocs") + runtime.GOMAXPROCS(viper.GetInt("peer.gomaxprocs")) // Init the BCCSP var bccspConfig *factory.FactoryOpts diff --git a/core/testutil/config.go b/core/testutil/config.go index b872339f84a..1c447850596 100644 --- a/core/testutil/config.go +++ b/core/testutil/config.go @@ -83,7 +83,7 @@ func SetupTestConfig() { // Set the number of maxprocs var numProcsDesired = viper.GetInt("peer.gomaxprocs") - configLogger.Debugf("setting Number of procs to %d, was %d\n", numProcsDesired, runtime.GOMAXPROCS(2)) + configLogger.Debugf("setting Number of procs to %d, was %d\n", numProcsDesired, runtime.GOMAXPROCS(numProcsDesired)) // Init the BCCSP var bccspConfig *factory.FactoryOpts