Skip to content

Commit 7960b3f

Browse files
committed
cmd/workload: fixed filter workload test request error handling
1 parent c4f0450 commit 7960b3f

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

cmd/workload/filtertest.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ func (s *filterTestSuite) filterFullRange(t *utesting.T) {
109109

110110
func (s *filterTestSuite) queryAndCheck(t *utesting.T, query *filterQuery) {
111111
query.run(s.cfg.client, s.cfg.historyPruneBlock)
112+
if query.Err == errPrunedHistory {
113+
return
114+
}
112115
if query.Err != nil {
113116
t.Errorf("Filter query failed (fromBlock: %d toBlock: %d addresses: %v topics: %v error: %v)", query.FromBlock, query.ToBlock, query.Address, query.Topics, query.Err)
114117
return
@@ -126,6 +129,9 @@ func (s *filterTestSuite) fullRangeQueryAndCheck(t *utesting.T, query *filterQue
126129
Topics: query.Topics,
127130
}
128131
frQuery.run(s.cfg.client, s.cfg.historyPruneBlock)
132+
if frQuery.Err == errPrunedHistory {
133+
return
134+
}
129135
if frQuery.Err != nil {
130136
t.Errorf("Full range filter query failed (addresses: %v topics: %v error: %v)", frQuery.Address, frQuery.Topics, frQuery.Err)
131137
return
@@ -206,14 +212,10 @@ func (fq *filterQuery) run(client *client, historyPruneBlock *uint64) {
206212
Addresses: fq.Address,
207213
Topics: fq.Topics,
208214
})
209-
if err != nil {
210-
if err = validateHistoryPruneErr(fq.Err, uint64(fq.FromBlock), historyPruneBlock); err == errPrunedHistory {
211-
return
212-
} else if err != nil {
213-
fmt.Printf("Filter query failed: fromBlock: %d toBlock: %d addresses: %v topics: %v error: %v\n",
214-
fq.FromBlock, fq.ToBlock, fq.Address, fq.Topics, err)
215-
}
216-
fq.Err = err
217-
}
218215
fq.results = logs
216+
fq.Err = validateHistoryPruneErr(err, uint64(fq.FromBlock), historyPruneBlock)
217+
if fq.Err != nil && fq.Err != errPrunedHistory {
218+
fmt.Printf("Filter query failed: fromBlock: %d toBlock: %d addresses: %v topics: %v error: %v\n",
219+
fq.FromBlock, fq.ToBlock, fq.Address, fq.Topics, err)
220+
}
219221
}

cmd/workload/filtertestgen.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ func filterGenCmd(ctx *cli.Context) error {
7171
f.updateFinalizedBlock()
7272
query := f.newQuery()
7373
query.run(f.client, nil)
74+
if query.Err == errPrunedHistory {
75+
continue
76+
}
7477
if query.Err != nil {
7578
f.errors = append(f.errors, query)
7679
continue
@@ -82,6 +85,9 @@ func filterGenCmd(ctx *cli.Context) error {
8285
break
8386
}
8487
extQuery.run(f.client, nil)
88+
if extQuery.Err == errPrunedHistory {
89+
break
90+
}
8591
if extQuery.Err == nil && len(extQuery.results) < len(query.results) {
8692
extQuery.Err = fmt.Errorf("invalid result length; old range %d %d; old length %d; new range %d %d; new length %d; address %v; Topics %v",
8793
query.FromBlock, query.ToBlock, len(query.results),

cmd/workload/filtertestperf.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var (
4141
}
4242
)
4343

44-
const passCount = 1
44+
const passCount = 3
4545

4646
func filterPerfCmd(ctx *cli.Context) error {
4747
cfg := testConfigFromCLI(ctx)
@@ -61,7 +61,7 @@ func filterPerfCmd(ctx *cli.Context) error {
6161
}
6262

6363
// Run test queries.
64-
var failed, mismatch int
64+
var failed, pruned, mismatch int
6565
for i := 1; i <= passCount; i++ {
6666
fmt.Println("Performance test pass", i, "/", passCount)
6767
for len(queries) > 0 {
@@ -71,6 +71,10 @@ func filterPerfCmd(ctx *cli.Context) error {
7171
queries = queries[:len(queries)-1]
7272
start := time.Now()
7373
qt.query.run(cfg.client, cfg.historyPruneBlock)
74+
if qt.query.Err == errPrunedHistory {
75+
pruned++
76+
continue
77+
}
7478
qt.runtime = append(qt.runtime, time.Since(start))
7579
slices.Sort(qt.runtime)
7680
qt.medianTime = qt.runtime[len(qt.runtime)/2]
@@ -80,18 +84,19 @@ func filterPerfCmd(ctx *cli.Context) error {
8084
}
8185
if rhash := qt.query.calculateHash(); *qt.query.ResultHash != rhash {
8286
fmt.Printf("Filter query result mismatch: fromBlock: %d toBlock: %d addresses: %v topics: %v expected hash: %064x calculated hash: %064x\n", qt.query.FromBlock, qt.query.ToBlock, qt.query.Address, qt.query.Topics, *qt.query.ResultHash, rhash)
87+
mismatch++
8388
continue
8489
}
8590
processed = append(processed, qt)
8691
if len(processed)%50 == 0 {
87-
fmt.Println(" processed:", len(processed), "remaining", len(queries), "failed:", failed, "result mismatch:", mismatch)
92+
fmt.Println(" processed:", len(processed), "remaining", len(queries), "failed:", failed, "pruned:", pruned, "result mismatch:", mismatch)
8893
}
8994
}
9095
queries, processed = processed, nil
9196
}
9297

9398
// Show results and stats.
94-
fmt.Println("Performance test finished; processed:", len(queries), "failed:", failed, "result mismatch:", mismatch)
99+
fmt.Println("Performance test finished; processed:", len(queries), "failed:", failed, "pruned:", pruned, "result mismatch:", mismatch)
95100
stats := make([]bucketStats, len(f.queries))
96101
var wildcardStats bucketStats
97102
for _, qt := range queries {

0 commit comments

Comments
 (0)