Skip to content

Commit

Permalink
Track emitted
Browse files Browse the repository at this point in the history
  • Loading branch information
ferglor committed Jul 17, 2024
1 parent b469689 commit 3b43302
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions integration-tests/load/automationv2_1/automationv2_1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ Load Config:
batchSize = endBlock - startBlock
}

blockWindowCounts := map[int]map[uint64]int{}
blockWindowCountsPerformed := map[int]map[uint64]int{}

for i, consumerContract := range consumerContracts {
var (
Expand All @@ -579,7 +579,7 @@ Load Config:
timeout = 5 * time.Second
)

upkeepMap, ok := blockWindowCounts[i]
upkeepMap, ok := blockWindowCountsPerformed[i]
if !ok {
upkeepMap = make(map[uint64]int)
}
Expand Down Expand Up @@ -650,16 +650,24 @@ Load Config:
}

if len(upkeepMap) > 0 {
blockWindowCounts[i] = upkeepMap
blockWindowCountsPerformed[i] = upkeepMap
}
}

for _, triggerContract := range triggerContracts {
blockWindowCountsEmitted := map[int]map[uint64]int{}

for i, triggerContract := range triggerContracts {
var (
logs []types.Log
address = triggerContract.Address()
timeout = 5 * time.Second
)

upkeepMap, ok := blockWindowCountsEmitted[i]
if !ok {
upkeepMap = make(map[uint64]int)
}

for fromBlock := startBlock; fromBlock < endBlock; fromBlock += batchSize + 1 {
filterQuery := geth.FilterQuery{
Addresses: []common.Address{address},
Expand All @@ -674,6 +682,7 @@ Load Config:
)
ctx2, cancel := context.WithTimeout(ctx, timeout)
logsInBatch, err = chainClient.Client.FilterLogs(ctx2, filterQuery)

cancel()
if err != nil {
l.Error().Err(err).
Expand All @@ -693,20 +702,33 @@ Load Config:
logs = append(logs, logsInBatch...)
}
}

numberOfEventsEmitted = numberOfEventsEmitted + int64(len(logs))

for _, log := range logs {
if blockCount, ok := upkeepMap[log.BlockNumber]; !ok {
upkeepMap[log.BlockNumber] = 1
} else {
upkeepMap[log.BlockNumber] = blockCount + 1
}
}
if len(upkeepMap) > 0 {
blockWindowCountsEmitted[i] = upkeepMap
}
}

numUpkeepsWithSomeLogsPerformed := len(blockWindowCounts)
numUpkeepsWithSomeLogsPerformed := len(blockWindowCountsPerformed)

blockWindowCountsJSON, _ := json.Marshal(blockWindowCounts)
blockWindowCountsPerformedJSON, _ := json.Marshal(blockWindowCountsPerformed)
blockWindowCountsEmittedJSON, _ := json.Marshal(blockWindowCountsEmitted)

minDequeue := map[int]int{}

logLimit := conf.PluginConfig.LogProviderConfig.LogLimit

blocks := 0

for upkeepID, blockCounts := range blockWindowCounts {
for upkeepID, blockCounts := range blockWindowCountsPerformed {

blocks += len(blockCounts)

Expand All @@ -724,8 +746,8 @@ Load Config:
minDequeueJSON, _ := json.Marshal(minDequeue)

avgBlocks := float64(0)
if len(blockWindowCounts) > 0 {
avgBlocks = float64(blocks) / float64(len(blockWindowCounts))
if len(blockWindowCountsPerformed) > 0 {
avgBlocks = float64(blocks) / float64(len(blockWindowCountsPerformed))
}

numUpkeepsWithSomeMinDequeue := len(minDequeue)
Expand Down Expand Up @@ -774,7 +796,8 @@ Load Config:
Int("Log Limit", int(*logLimit)).
Int("Num upkeeps with one or more logs performed", numUpkeepsWithSomeLogsPerformed).
Int("Num upkeeps with one or more min dequeue blocks", numUpkeepsWithSomeMinDequeue).
Str("Block window counts per upkeep JSON", string(blockWindowCountsJSON)).
Str("Block window counts emitted per upkeep JSON", string(blockWindowCountsEmittedJSON)).
Str("Block window counts performed per upkeep JSON", string(blockWindowCountsPerformedJSON)).
Str("Min dequeue JSON", string(minDequeueJSON)).
Msg("Test completed")

Expand Down

0 comments on commit 3b43302

Please sign in to comment.