Skip to content

Commit 81ed700

Browse files
holisticodezelig
authored andcommitted
Enable longrunning tests to run (#19208)
* p2p/simulations: increased snapshot load timeout for debugging * swarm/network/stream: less nodes for snapshot longrunning tests * swarm/network: fixed longrunning tests * swarm/network/stream: store kademlia in bucket * swarm/network/stream: disabled healthy check in delivery tests * swarm/network/stream: longer SyncUpdateDelay for longrunning tests * swarm/network/stream: more debug output * swarm/network/stream: reduced longrunning snapshot tests to 64 nodes * swarm/network/stream: don't WaitTillHealthy in SyncerSimulation * swarm/network/stream: cleanup for PR
1 parent 216bd2c commit 81ed700

7 files changed

Lines changed: 32 additions & 23 deletions

File tree

‎p2p/simulations/network.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,8 @@ func (net *Network) snapshot(addServices []string, removeServices []string) (*Sn
840840
return snap, nil
841841
}
842842

843-
var snapshotLoadTimeout = 120 * time.Second
843+
// longrunning tests may need a longer timeout
844+
var snapshotLoadTimeout = 900 * time.Second
844845

845846
// Load loads a network snapshot
846847
func (net *Network) Load(snap *Snapshot) error {

‎swarm/network/stream/common_test.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ func netStoreAndDeliveryWithAddr(ctx *adapters.ServiceContext, bucket *sync.Map,
134134
bucket.Store(bucketKeyDB, netStore)
135135
bucket.Store(bucketKeyDelivery, delivery)
136136
bucket.Store(bucketKeyFileStore, fileStore)
137+
// for the kademlia object, we use the global key from the simulation package,
138+
// as the simulation will try to access it in the WaitTillHealthy with that key
139+
bucket.Store(simulation.BucketKeyKademlia, kad)
137140

138141
cleanup := func() {
139142
netStore.Close()

‎swarm/network/stream/delivery_test.go‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -534,12 +534,6 @@ func testDeliveryFromNodes(t *testing.T, nodes, chunkCount int, skipCheck bool)
534534
return err
535535
}
536536

537-
log.Debug("Waiting for kademlia")
538-
// TODO this does not seem to be correct usage of the function, as the simulation may have no kademlias
539-
if _, err := sim.WaitTillHealthy(ctx); err != nil {
540-
return err
541-
}
542-
543537
//get the pivot node's filestore
544538
item, ok := sim.NodeItem(pivot, bucketKeyFileStore)
545539
if !ok {

‎swarm/network/stream/snapshot_retrieval_test.go‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestFileRetrieval(t *testing.T) {
5353
nodeCount = []int{16}
5454

5555
if *longrunning {
56-
nodeCount = append(nodeCount, 32, 64, 128)
56+
nodeCount = append(nodeCount, 32, 64)
5757
} else if testutil.RaceEnabled {
5858
nodeCount = []int{4}
5959
}
@@ -86,7 +86,7 @@ func TestRetrieval(t *testing.T) {
8686
chnkCnt := []int{32}
8787

8888
if *longrunning {
89-
nodeCnt = []int{16, 32, 128}
89+
nodeCnt = []int{16, 32, 64}
9090
chnkCnt = []int{4, 32, 256}
9191
} else if testutil.RaceEnabled {
9292
nodeCnt = []int{4}
@@ -113,10 +113,15 @@ var retrievalSimServiceMap = map[string]simulation.ServiceFunc{
113113
return nil, nil, err
114114
}
115115

116+
syncUpdateDelay := 1 * time.Second
117+
if *longrunning {
118+
syncUpdateDelay = 3 * time.Second
119+
}
120+
116121
r := NewRegistry(addr.ID(), delivery, netStore, state.NewInmemoryStore(), &RegistryOptions{
117122
Retrieval: RetrievalEnabled,
118123
Syncing: SyncingAutoSubscribe,
119-
SyncUpdateDelay: 3 * time.Second,
124+
SyncUpdateDelay: syncUpdateDelay,
120125
}, nil)
121126

122127
cleanup = func() {
@@ -140,7 +145,7 @@ func runFileRetrievalTest(nodeCount int) error {
140145
sim := simulation.New(retrievalSimServiceMap)
141146
defer sim.Close()
142147

143-
log.Info("Initializing test config")
148+
log.Info("Initializing test config", "node count", nodeCount)
144149

145150
conf := &synctestConfig{}
146151
//map of discover ID to indexes of chunks expected at that ID
@@ -158,6 +163,8 @@ func runFileRetrievalTest(nodeCount int) error {
158163
ctx, cancelSimRun := context.WithTimeout(context.Background(), 3*time.Minute)
159164
defer cancelSimRun()
160165

166+
log.Info("Starting simulation")
167+
161168
result := sim.Run(ctx, func(ctx context.Context, sim *simulation.Simulation) error {
162169
nodeIDs := sim.UpNodeIDs()
163170
for _, n := range nodeIDs {
@@ -185,6 +192,8 @@ func runFileRetrievalTest(nodeCount int) error {
185192
return err
186193
}
187194

195+
log.Info("network healthy, start file checks")
196+
188197
// File retrieval check is repeated until all uploaded files are retrieved from all nodes
189198
// or until the timeout is reached.
190199
REPEAT:
@@ -212,6 +221,8 @@ func runFileRetrievalTest(nodeCount int) error {
212221
}
213222
})
214223

224+
log.Info("Simulation terminated")
225+
215226
if result.Error != nil {
216227
return result.Error
217228
}

‎swarm/network/stream/snapshot_sync_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ func TestSyncingViaGlobalSync(t *testing.T) {
9494
//if the `longrunning` flag has been provided
9595
//run more test combinations
9696
if *longrunning {
97-
chunkCounts = []int{1, 8, 32, 256, 1024}
98-
nodeCounts = []int{16, 32, 64, 128, 256}
97+
chunkCounts = []int{64, 128}
98+
nodeCounts = []int{32, 64}
9999
}
100100

101101
for _, chunkCount := range chunkCounts {

‎swarm/network/stream/streamer_test.go‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,12 +1188,13 @@ func TestGetSubscriptionsRPC(t *testing.T) {
11881188

11891189
// arbitrarily set to 4
11901190
nodeCount := 4
1191+
// set the syncUpdateDelay for sync registrations to start
1192+
syncUpdateDelay := 200 * time.Millisecond
11911193
// run with more nodes if `longrunning` flag is set
11921194
if *longrunning {
11931195
nodeCount = 64
1196+
syncUpdateDelay = 10 * time.Second
11941197
}
1195-
// set the syncUpdateDelay for sync registrations to start
1196-
syncUpdateDelay := 200 * time.Millisecond
11971198
// holds the msg code for SubscribeMsg
11981199
var subscribeMsgCode uint64
11991200
var ok bool
@@ -1241,7 +1242,7 @@ func TestGetSubscriptionsRPC(t *testing.T) {
12411242
})
12421243
defer sim.Close()
12431244

1244-
ctx, cancelSimRun := context.WithTimeout(context.Background(), 1*time.Minute)
1245+
ctx, cancelSimRun := context.WithTimeout(context.Background(), 3*time.Minute)
12451246
defer cancelSimRun()
12461247

12471248
// upload a snapshot
@@ -1267,6 +1268,9 @@ func TestGetSubscriptionsRPC(t *testing.T) {
12671268
go func() {
12681269
//for long running sims, waiting 1 sec will not be enough
12691270
waitDuration := time.Duration(nodeCount/16) * time.Second
1271+
if *longrunning {
1272+
waitDuration = syncUpdateDelay
1273+
}
12701274
for {
12711275
select {
12721276
case <-ctx.Done():
@@ -1328,11 +1332,11 @@ func TestGetSubscriptionsRPC(t *testing.T) {
13281332
}
13291333
}
13301334
}
1335+
log.Debug("All node streams counted", "realCount", realCount)
13311336
}
1332-
// every node is mutually subscribed to each other, so the actual count is half of it
13331337
emc := expectedMsgCount.count()
1334-
if realCount/2 != emc {
1335-
return fmt.Errorf("Real subscriptions and expected amount don't match; real: %d, expected: %d", realCount/2, emc)
1338+
if realCount != emc {
1339+
return fmt.Errorf("Real subscriptions and expected amount don't match; real: %d, expected: %d", realCount, emc)
13361340
}
13371341
return nil
13381342
})

‎swarm/network/stream/syncer_test.go‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,6 @@ func testSyncBetweenNodes(t *testing.T, nodes, chunkCount int, skipCheck bool, p
173173
}
174174
}
175175
// here we distribute chunks of a random file into stores 1...nodes
176-
if _, err := sim.WaitTillHealthy(ctx); err != nil {
177-
return err
178-
}
179-
180176
// collect hashes in po 1 bin for each node
181177
hashes := make([][]storage.Address, nodes)
182178
totalHashes := 0

0 commit comments

Comments
 (0)