-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BCF-2854 Jfpc pipeline cache (#12094)
* Add rough implementation for data source caching * Add JuelsPerFeeCoinCacheDuration validation * Make sonar happy * Set EATelemetry for dataSource in observe to reuse executeRun for cache * Fix races in inMemoryDataSourceCache * Fix JuelsPerFeeCoinCacheDuration validation * Shorten NewInMemoryDataSourceCache signature * Infer juels fee per coin caching from non-zero duration instead of bool * Change how jfpc cache handles cache updater cron errors * Change jfpc cache duration validation * Set default jfpc data source expiry duration to 5minutes if not set * Improve jfpc updateCache err handling to account for result errors * Make juels fee per coin get cached by default, and add cache tests * Make jfpc cache updater run on start * Increase jfpc data source timeout * Change log priority in cache updater * Fix test flakiness * Change log severity in jfpc cache updater * Add cfg option to disable jfpc caching * Remove ptr from inMemoryDataSourceCache mutex * Fix JuelsPerFeeCoinCacheDuration encoding type to use models.Interval * Add tests for validating juels per fee coin data source cache config * Add changelog * Fix typo in test * Fix log
- Loading branch information
Showing
8 changed files
with
242 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,55 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/smartcontractkit/chainlink/v2/core/store/models" | ||
) | ||
|
||
func TestValidatePluginConfig(t *testing.T) { | ||
for _, s := range []struct { | ||
name string | ||
pipeline string | ||
}{ | ||
{"empty", ""}, | ||
{"blank", " "}, | ||
{"foo", "foo"}, | ||
} { | ||
t.Run(s.name, func(t *testing.T) { | ||
assert.Error(t, ValidatePluginConfig(PluginConfig{JuelsPerFeeCoinPipeline: s.pipeline})) | ||
}) | ||
type testCase struct { | ||
name string | ||
pipeline string | ||
cacheDuration models.Interval | ||
expectedError error | ||
} | ||
|
||
t.Run("pipeline validation", func(t *testing.T) { | ||
for _, tc := range []testCase{ | ||
{"empty pipeline", "", models.Interval(time.Minute), fmt.Errorf("invalid juelsPerFeeCoinSource pipeline: empty pipeline")}, | ||
{"blank pipeline", " ", models.Interval(time.Minute), fmt.Errorf("invalid juelsPerFeeCoinSource pipeline: empty pipeline")}, | ||
{"foo pipeline", "foo", models.Interval(time.Minute), fmt.Errorf("invalid juelsPerFeeCoinSource pipeline: UnmarshalTaskFromMap: unknown task type: \"\"")}, | ||
} { | ||
t.Run(tc.name, func(t *testing.T) { | ||
assert.EqualError(t, ValidatePluginConfig(PluginConfig{JuelsPerFeeCoinPipeline: tc.pipeline}), tc.expectedError.Error()) | ||
}) | ||
} | ||
}) | ||
|
||
t.Run("cache duration validation", func(t *testing.T) { | ||
for _, tc := range []testCase{ | ||
{"cache duration below minimum", `ds1 [type=bridge name=voter_turnout];`, models.Interval(time.Second * 29), fmt.Errorf("juelsPerFeeCoinSource cache duration: 29s is below 30 second minimum")}, | ||
{"cache duration above maximum", `ds1 [type=bridge name=voter_turnout];`, models.Interval(time.Minute*20 + time.Second), fmt.Errorf("juelsPerFeeCoinSource cache duration: 20m1s is above 20 minute maximum")}, | ||
} { | ||
t.Run(tc.name, func(t *testing.T) { | ||
assert.EqualError(t, ValidatePluginConfig(PluginConfig{JuelsPerFeeCoinPipeline: tc.pipeline, JuelsPerFeeCoinCacheDuration: tc.cacheDuration}), tc.expectedError.Error()) | ||
}) | ||
} | ||
}) | ||
|
||
t.Run("valid values", func(t *testing.T) { | ||
for _, s := range []testCase{ | ||
{"valid 0 cache duration and valid pipeline", `ds1 [type=bridge name=voter_turnout];`, 0, nil}, | ||
{"valid duration and valid pipeline", `ds1 [type=bridge name=voter_turnout];`, models.Interval(time.Second * 30), nil}, | ||
{"valid duration and valid pipeline", `ds1 [type=bridge name=voter_turnout];`, models.Interval(time.Minute * 20), nil}, | ||
} { | ||
t.Run(s.name, func(t *testing.T) { | ||
assert.Nil(t, ValidatePluginConfig(PluginConfig{JuelsPerFeeCoinPipeline: s.pipeline})) | ||
}) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.