swarm/network: skip TestSyncingViaGlobalSync with -race

As panics on Travis.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7e351b]
This commit is contained in:
Ferenc Szabo 2019-02-19 15:19:05 +01:00
parent eb9f11e16c
commit 3c48738c15

View file

@ -19,7 +19,6 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"runtime" "runtime"
"sync" "sync"
@ -78,37 +77,31 @@ func TestSyncingViaGlobalSync(t *testing.T) {
if runtime.GOOS == "darwin" && os.Getenv("TRAVIS") == "true" { if runtime.GOOS == "darwin" && os.Getenv("TRAVIS") == "true" {
t.Skip("Flaky on mac on travis") t.Skip("Flaky on mac on travis")
} }
if testutil.RaceEnabled {
t.Skip("Segfaults on Travis with -race")
}
//if nodes/chunks have been provided via commandline, //if nodes/chunks have been provided via commandline,
//run the tests with these values //run the tests with these values
if *nodes != 0 && *chunks != 0 { if *nodes != 0 && *chunks != 0 {
log.Info(fmt.Sprintf("Running test with %d chunks and %d nodes...", *chunks, *nodes)) log.Info(fmt.Sprintf("Running test with %d chunks and %d nodes...", *chunks, *nodes))
testSyncingViaGlobalSync(t, *chunks, *nodes) testSyncingViaGlobalSync(t, *chunks, *nodes)
} else { } else {
var nodeCnt []int chunkCounts := []int{4, 32}
var chnkCnt []int nodeCounts := []int{32, 16}
//if the `longrunning` flag has been provided //if the `longrunning` flag has been provided
//run more test combinations //run more test combinations
if *longrunning { if *longrunning {
chnkCnt = []int{1, 8, 32, 256, 1024} chunkCounts = []int{1, 8, 32, 256, 1024}
nodeCnt = []int{16, 32, 64, 128, 256} nodeCounts = []int{16, 32, 64, 128, 256}
} else if testutil.RaceEnabled {
// TestSyncingViaGlobalSync allocates a lot of memory
// with race detector. By reducing the number of chunks
// and nodes, memory consumption is lower and data races
// are still checked, while correctness of syncing is
// tested with more chunks and nodes in regular (!race)
// tests.
chnkCnt = []int{4}
nodeCnt = []int{16}
} else {
//default test
chnkCnt = []int{4, 32}
nodeCnt = []int{32, 16}
} }
for _, chnk := range chnkCnt {
for _, n := range nodeCnt { for _, chunkCount := range chunkCounts {
log.Info(fmt.Sprintf("Long running test with %d chunks and %d nodes...", chnk, n)) for _, n := range nodeCounts {
testSyncingViaGlobalSync(t, chnk, n) log.Info(fmt.Sprintf("Long running test with %d chunks and %d nodes...", chunkCount, n))
testSyncingViaGlobalSync(t, chunkCount, n)
} }
} }
} }
@ -121,21 +114,7 @@ var simServiceMap = map[string]simulation.ServiceFunc{
return nil, nil, err return nil, nil, err
} }
var dir string store := state.NewInmemoryStore()
var store *state.DBStore
if testutil.RaceEnabled {
// Use on-disk DBStore to reduce memory consumption in race tests.
dir, err = ioutil.TempDir("", "swarm-stream-")
if err != nil {
return nil, nil, err
}
store, err = state.NewDBStore(dir)
if err != nil {
return nil, nil, err
}
} else {
store = state.NewInmemoryStore()
}
r := NewRegistry(addr.ID(), delivery, netStore, store, &RegistryOptions{ r := NewRegistry(addr.ID(), delivery, netStore, store, &RegistryOptions{
Retrieval: RetrievalDisabled, Retrieval: RetrievalDisabled,