Skip to content

Commit

Permalink
[FAB-4902] Fix to set the GOMAXPROCS in UT
Browse files Browse the repository at this point in the history
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 <kaiho.fukuchi.th@hitachi.com>
  • Loading branch information
kaihof authored and Nao Nishijima committed Jun 23, 2017
1 parent 3bc937e commit a062eb8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/chaincode/exectransaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion core/endorser/endorser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"io/ioutil"
"net"
"os"
"runtime"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/testutil/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a062eb8

Please sign in to comment.