mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
swarm: move race/norace helpers from stream to testutil
As we will need to use the flag in other packages, too.
This commit is contained in:
parent
d145d77895
commit
f33736df56
4 changed files with 15 additions and 15 deletions
|
|
@ -42,8 +42,6 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/swarm/testutil"
|
"github.com/ethereum/go-ethereum/swarm/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
const MaxTimeout = 600
|
|
||||||
|
|
||||||
type synctestConfig struct {
|
type synctestConfig struct {
|
||||||
addrs [][]byte
|
addrs [][]byte
|
||||||
hashes []storage.Address
|
hashes []storage.Address
|
||||||
|
|
@ -93,7 +91,7 @@ func TestSyncingViaGlobalSync(t *testing.T) {
|
||||||
if *longrunning {
|
if *longrunning {
|
||||||
chnkCnt = []int{1, 8, 32, 256, 1024}
|
chnkCnt = []int{1, 8, 32, 256, 1024}
|
||||||
nodeCnt = []int{16, 32, 64, 128, 256}
|
nodeCnt = []int{16, 32, 64, 128, 256}
|
||||||
} else if raceTest {
|
} else if testutil.RaceEnabled {
|
||||||
// TestSyncingViaGlobalSync allocates a lot of memory
|
// TestSyncingViaGlobalSync allocates a lot of memory
|
||||||
// with race detector. By reducing the number of chunks
|
// with race detector. By reducing the number of chunks
|
||||||
// and nodes, memory consumption is lower and data races
|
// and nodes, memory consumption is lower and data races
|
||||||
|
|
@ -125,7 +123,7 @@ var simServiceMap = map[string]simulation.ServiceFunc{
|
||||||
|
|
||||||
var dir string
|
var dir string
|
||||||
var store *state.DBStore
|
var store *state.DBStore
|
||||||
if raceTest {
|
if testutil.RaceEnabled {
|
||||||
// Use on-disk DBStore to reduce memory consumption in race tests.
|
// Use on-disk DBStore to reduce memory consumption in race tests.
|
||||||
dir, err = ioutil.TempDir("", "swarm-stream-")
|
dir, err = ioutil.TempDir("", "swarm-stream-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ func TestSyncerSimulation(t *testing.T) {
|
||||||
// race detector. Allow it to finish successfully by
|
// race detector. Allow it to finish successfully by
|
||||||
// reducing its scope, and still check for data races
|
// reducing its scope, and still check for data races
|
||||||
// with the smallest number of nodes.
|
// with the smallest number of nodes.
|
||||||
if !raceTest {
|
if !testutil.RaceEnabled {
|
||||||
testSyncBetweenNodes(t, 4, dataChunkCount, true, 1)
|
testSyncBetweenNodes(t, 4, dataChunkCount, true, 1)
|
||||||
testSyncBetweenNodes(t, 8, dataChunkCount, true, 1)
|
testSyncBetweenNodes(t, 8, dataChunkCount, true, 1)
|
||||||
testSyncBetweenNodes(t, 16, dataChunkCount, true, 1)
|
testSyncBetweenNodes(t, 16, dataChunkCount, true, 1)
|
||||||
|
|
@ -88,7 +88,7 @@ func testSyncBetweenNodes(t *testing.T, nodes, chunkCount int, skipCheck bool, p
|
||||||
|
|
||||||
var dir string
|
var dir string
|
||||||
var store *state.DBStore
|
var store *state.DBStore
|
||||||
if raceTest {
|
if testutil.RaceEnabled {
|
||||||
// Use on-disk DBStore to reduce memory consumption in race tests.
|
// Use on-disk DBStore to reduce memory consumption in race tests.
|
||||||
dir, err = ioutil.TempDir("", "swarm-stream-")
|
dir, err = ioutil.TempDir("", "swarm-stream-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,11 @@
|
||||||
|
|
||||||
// +build !race
|
// +build !race
|
||||||
|
|
||||||
package stream
|
package testutil
|
||||||
|
|
||||||
// Provide a flag to reduce the scope of tests when running them
|
// RaceEnabled is true when -race flag is provided to the go tool. This const
|
||||||
// with race detector. Some of the tests are doing a lot of allocations
|
// might be used in tests to skip some cases as the race detector may increase
|
||||||
// on the heap, and race detector uses much more memory to track them.
|
// memory usage 5-10x and execution time by 2-20x. That might causes problems
|
||||||
const raceTest = false
|
// on Travis. Please, use this flag sparingly and keep your unit tests
|
||||||
|
// as light on resources as possible.
|
||||||
|
const RaceEnabled = false
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
|
|
||||||
// +build race
|
// +build race
|
||||||
|
|
||||||
package stream
|
package testutil
|
||||||
|
|
||||||
// Reduce the scope of some tests when running with race detector,
|
// RaceEnabled is true when -race flag is provided to the go tool.
|
||||||
// as it raises the memory consumption significantly.
|
// See norace.go for more.
|
||||||
const raceTest = true
|
const RaceEnabled = true
|
||||||
Loading…
Reference in a new issue