swarm/network: fixed longrunning tests

This commit is contained in:
Fabio Barone 2019-03-01 12:12:46 -05:00
parent 211255aed7
commit 6d15944543
4 changed files with 16 additions and 15 deletions

View file

@ -840,7 +840,8 @@ func (net *Network) snapshot(addServices []string, removeServices []string) (*Sn
return snap, nil
}
var snapshotLoadTimeout = 6000 * time.Second
// longrunning tests may need a longer timeout
var snapshotLoadTimeout = 7200 * time.Second
// Load loads a network snapshot
func (net *Network) Load(snap *Snapshot) error {

View file

@ -53,8 +53,7 @@ func TestFileRetrieval(t *testing.T) {
nodeCount = []int{16}
if *longrunning {
//nodeCount = append(nodeCount, 32, 64, 128)
nodeCount = append(nodeCount, 48)
nodeCount = append(nodeCount, 32, 64, 128)
} else if testutil.RaceEnabled {
nodeCount = []int{4}
}
@ -87,10 +86,8 @@ func TestRetrieval(t *testing.T) {
chnkCnt := []int{32}
if *longrunning {
//nodeCnt = []int{16, 32, 128}
nodeCnt = []int{32, 48}
chnkCnt = []int{64, 128}
//chnkCnt = []int{4, 32, 256}
nodeCnt = []int{16, 32, 128}
chnkCnt = []int{4, 32, 256}
} else if testutil.RaceEnabled {
nodeCnt = []int{4}
chnkCnt = []int{4}

View file

@ -95,8 +95,7 @@ func TestSyncingViaGlobalSync(t *testing.T) {
//run more test combinations
if *longrunning {
chunkCounts = []int{64, 128}
//nodeCounts = []int{16, 32, 64, 128, 256}
nodeCounts = []int{32, 48}
nodeCounts = []int{64, 128}
}
for _, chunkCount := range chunkCounts {

View file

@ -1188,12 +1188,13 @@ func TestGetSubscriptionsRPC(t *testing.T) {
// arbitrarily set to 4
nodeCount := 4
// set the syncUpdateDelay for sync registrations to start
syncUpdateDelay := 200 * time.Millisecond
// run with more nodes if `longrunning` flag is set
if *longrunning {
nodeCount = 64
syncUpdateDelay = 10 * time.Second
}
// set the syncUpdateDelay for sync registrations to start
syncUpdateDelay := 200 * time.Millisecond
// holds the msg code for SubscribeMsg
var subscribeMsgCode uint64
var ok bool
@ -1241,7 +1242,7 @@ func TestGetSubscriptionsRPC(t *testing.T) {
})
defer sim.Close()
ctx, cancelSimRun := context.WithTimeout(context.Background(), 1*time.Minute)
ctx, cancelSimRun := context.WithTimeout(context.Background(), 3*time.Minute)
defer cancelSimRun()
// upload a snapshot
@ -1267,6 +1268,9 @@ func TestGetSubscriptionsRPC(t *testing.T) {
go func() {
//for long running sims, waiting 1 sec will not be enough
waitDuration := time.Duration(nodeCount/16) * time.Second
if *longrunning {
waitDuration = syncUpdateDelay
}
for {
select {
case <-ctx.Done():
@ -1328,11 +1332,11 @@ func TestGetSubscriptionsRPC(t *testing.T) {
}
}
}
log.Debug("All node streams counted", "realCount", realCount)
}
// every node is mutually subscribed to each other, so the actual count is half of it
emc := expectedMsgCount.count()
if realCount/2 != emc {
return fmt.Errorf("Real subscriptions and expected amount don't match; real: %d, expected: %d", realCount/2, emc)
if realCount != emc {
return fmt.Errorf("Real subscriptions and expected amount don't match; real: %d, expected: %d", realCount, emc)
}
return nil
})