-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto 4601/add log retry integration test #10355
Auto 4601/add log retry integration test #10355
Conversation
I see that you haven't updated any CHANGELOG files. Would it make sense to do so? |
I see that you haven't updated any README files. Would it make sense to do so? |
91cbaaa
to
96390f0
Compare
@@ -66,6 +66,17 @@ func (p *abiPacker) UnpackCheckResult(payload ocr2keepers.UpkeepPayload, raw str | |||
return result, nil | |||
} | |||
|
|||
func (p *abiPacker) UnpackGetUpkeepPrivilegeConfig(resp []byte) ([]byte, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add test
@@ -217,10 +217,37 @@ func (r *EvmRegistry) allowedToUseMercury(opts *bind.CallOpts, upkeepId *big.Int | |||
return encoding.NoPipelineError, encoding.UpkeepFailureReasonNone, false, allowed.(bool), nil | |||
} | |||
|
|||
cfg, err := r.registry.GetUpkeepPrivilegeConfig(opts, upkeepId) | |||
payload, err := r.abi.Pack("getUpkeepPrivilegeConfig", upkeepId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract to packer.PackGetUpkeepPrivilegeConfig
9261892
to
8f0d764
Compare
// pack error, no retryable | ||
r.lggr.Warnf("failed to pack getUpkeepPrivilegeConfig data for upkeepId %s: %s", upkeepId, err) | ||
|
||
return encoding.RpcFlakyFailure, encoding.UpkeepFailureReasonNone, true, false, fmt.Errorf("failed to pack upkeepId: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will need to fix this error instead of RpcFlakyFailure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can create a new error type that makes more sense in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might fit in here but best to confirm with felix https://github.com/smartcontractkit/chainlink/blob/develop/core/services/ocr2/plugins/ocr2keeper/evm21/encoding/interface.go#L39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree that this should be PackUnpackDecodeFailed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this should be not retryable
return encoding.RpcFlakyFailure, encoding.UpkeepFailureReasonNone, true, false, fmt.Errorf("failed to get upkeep privilege config: %v", err) | ||
} | ||
|
||
cfg, err := r.packer.UnpackGetUpkeepPrivilegeConfig(b) | ||
if err != nil { | ||
return encoding.RpcFlakyFailure, encoding.UpkeepFailureReasonNone, true, false, fmt.Errorf("failed to get upkeep privilege config: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@@ -217,21 +217,43 @@ func (r *EvmRegistry) allowedToUseMercury(opts *bind.CallOpts, upkeepId *big.Int | |||
return encoding.NoPipelineError, encoding.UpkeepFailureReasonNone, false, allowed.(bool), nil | |||
} | |||
|
|||
cfg, err := r.registry.GetUpkeepPrivilegeConfig(opts, upkeepId) | |||
payload, err := r.packer.PackGetUpkeepPrivilegeConfig(upkeepId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's ensure we get Felix's review on this file if we go ahead with this approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll ping him on it
return encoding.RpcFlakyFailure, encoding.UpkeepFailureReasonNone, true, false, fmt.Errorf("failed to get upkeep privilege config: %v", err) | ||
} | ||
|
||
cfg, err := r.packer.UnpackGetUpkeepPrivilegeConfig(b) | ||
if err != nil { | ||
return encoding.RpcFlakyFailure, encoding.UpkeepFailureReasonNone, true, false, fmt.Errorf("failed to get upkeep privilege config: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unpack error should be not retryable
255f4b2
to
9b02e7d
Compare
Running downstream job at https://github.com/smartcontractkit/operator-ui/actions/runs/6113328010 |
9b02e7d
to
6ab372d
Compare
Running downstream job at https://github.com/smartcontractkit/operator-ui/actions/runs/6123461550 |
6174617
to
13c47c7
Compare
Running downstream job at https://github.com/smartcontractkit/operator-ui/actions/runs/6160657318 |
Running downstream job at https://github.com/smartcontractkit/operator-ui/actions/runs/6161345141 |
Running downstream job at https://github.com/smartcontractkit/operator-ui/actions/runs/6161752423 |
Running downstream job at https://github.com/smartcontractkit/operator-ui/actions/runs/6161752820 |
// the actual struct to unmarshal into is not available to this | ||
// package so basic json encoding is the limit of the following test | ||
var data map[string]interface{} | ||
err = json.Unmarshal(b, &data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it make sense to compare the output bytes of unpack() and our expected bytes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add a test that b
adheres to the correct json structure in byte form. It's a little brittle but it should work.
return encoding.PackUnpackDecodeFailed, encoding.UpkeepFailureReasonNone, false, false, fmt.Errorf("failed to pack upkeepId: %w", err) | ||
} | ||
|
||
var b hexutil.Bytes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nit, i would recommend a more meaningful name, e.g. result or resultBytes.
if len(cfg) == 0 { | ||
r.mercury.allowListCache.Set(upkeepId.String(), false, cache.DefaultExpiration) | ||
return encoding.NoPipelineError, encoding.UpkeepFailureReasonMercuryAccessNotAllowed, false, false, fmt.Errorf("upkeep privilege config is empty") | ||
} | ||
|
||
var a UpkeepPrivilegeConfig | ||
err = json.Unmarshal(cfg, &a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, how about something like privilegeConfig?
// the simulation here should force the streams lookup process to return | ||
// retryable 2 times. | ||
// the total count of failures should be (upkeepCount * 3 * tryCount) | ||
if count <= mercuryFailCount { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i didnt get this math. mercury, by default, retries 3 times before returning a retryable, so for 1 upkeep, we should hit the mercury server 5 times(1st is regular query, 2,3,4 are retries, and then the 5th will return a retryable) in order to get 1 retryable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For each call to CheckUpkeeps
, mercury is tried 3 times in total for each upkeep. The expectation is that for each upkeep, 2 calls to CheckUpkeeps
should result in a Retryable
result and one should succeed. So for each upkeep that should be 3 'tries' * 2 'retries' for the failure condition and one more 'try' for the success condition. I think it's right?
|
||
// using sleep here is not the right way to go, but it currently work on | ||
// a local machine. this does have issues in CI | ||
time.Sleep(10 * time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious, what is the issue in CI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's avoid the sleep as it might be flaky, can't we wait for something to happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I'll try removing this. Amir did some updates where this timer wasn't needed.
|
||
func (c *feedLookupUpkeepController) RegisterAndFund( | ||
t *testing.T, | ||
f registerAndFundFunc, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to move the type registerAndFundFunc
and the function definition in core/services/ocr2/plugins/ocr2keeper/integration_21_test.go
to here? So we can remove the additional layer?
This commit offers a proposal for completing an integration test that runs log trigger upkeeps, a full check pipeline, fails mercury server calls, and allows the application to retry the upkeeps. Additions include: - mock mercury server that can have a custom handler per test - upkeep setup helpers for creating/registering log triggered upkeeps - integration test for log event retry flow
32b60c5
to
b99cb4a
Compare
SonarQube Quality Gate |
This PR offers a proposal for completing an integration test that runs log
trigger upkeeps, a full check pipeline, fails mercury server calls, and allows
the application to retry the upkeeps.
Additions include: