Skip to content
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

[Keystone] Disable remote calls to RegisterToWorkflow #15352

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions core/capabilities/remote/executable/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,40 +140,10 @@ func (c *client) Info(ctx context.Context) (commoncap.CapabilityInfo, error) {
}

func (c *client) RegisterToWorkflow(ctx context.Context, registerRequest commoncap.RegisterToWorkflowRequest) error {
req, err := request.NewClientRegisterToWorkflowRequest(ctx, c.lggr, registerRequest, c.remoteCapabilityInfo, c.localDONInfo, c.dispatcher,
c.requestTimeout)

if err != nil {
return fmt.Errorf("failed to create client request: %w", err)
}

if err = c.sendRequest(req); err != nil {
return fmt.Errorf("failed to send request: %w", err)
}

resp := <-req.ResponseChan()
if resp.Err != nil {
return fmt.Errorf("error executing request: %w", resp.Err)
}
return nil
}

func (c *client) UnregisterFromWorkflow(ctx context.Context, unregisterRequest commoncap.UnregisterFromWorkflowRequest) error {
req, err := request.NewClientUnregisterFromWorkflowRequest(ctx, c.lggr, unregisterRequest, c.remoteCapabilityInfo,
c.localDONInfo, c.dispatcher, c.requestTimeout)

if err != nil {
return fmt.Errorf("failed to create client request: %w", err)
}

if err = c.sendRequest(req); err != nil {
return fmt.Errorf("failed to send request: %w", err)
}

resp := <-req.ResponseChan()
if resp.Err != nil {
return fmt.Errorf("error executing request: %w", resp.Err)
}
return nil
}

Expand Down
102 changes: 0 additions & 102 deletions core/capabilities/remote/executable/endtoend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,84 +26,6 @@ import (
p2ptypes "github.com/smartcontractkit/chainlink/v2/core/services/p2p/types"
)

func Test_RemoteExecutableCapability_InsufficientCapabilityResponses(t *testing.T) {
ctx := testutils.Context(t)

responseTest := func(t *testing.T, responseCh commoncap.CapabilityResponse, responseError error) {
assert.NotNil(t, responseError)
}

capability := &TestCapability{}

transmissionSchedule, err := values.NewMap(map[string]any{
"schedule": transmission.Schedule_AllAtOnce,
"deltaStage": "10ms",
})
require.NoError(t, err)

var methods []func(ctx context.Context, caller commoncap.ExecutableCapability)

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
executeCapability(ctx, t, caller, transmissionSchedule, responseTest)
})

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
registerWorkflow(ctx, t, caller, transmissionSchedule, func(t *testing.T, responseError error) {
require.Error(t, responseError)
})
})

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
unregisterWorkflow(ctx, t, caller, transmissionSchedule, func(t *testing.T, responseError error) {
require.Error(t, responseError)
})
})

for _, method := range methods {
testRemoteExecutableCapability(ctx, t, capability, 10, 9, 10*time.Millisecond, 10, 10, 10*time.Minute, method)
}
}

func Test_RemoteExecutableCapability_InsufficientWorkflowRequests(t *testing.T) {
ctx := testutils.Context(t)

responseTest := func(t *testing.T, responseCh commoncap.CapabilityResponse, responseError error) {
assert.NotNil(t, responseError)
}

timeOut := 10 * time.Minute

capability := &TestCapability{}

transmissionSchedule, err := values.NewMap(map[string]any{
"schedule": transmission.Schedule_AllAtOnce,
"deltaStage": "10ms",
})
require.NoError(t, err)

var methods []func(ctx context.Context, caller commoncap.ExecutableCapability)

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
executeCapability(ctx, t, caller, transmissionSchedule, responseTest)
})

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
registerWorkflow(ctx, t, caller, transmissionSchedule, func(t *testing.T, responseError error) {
require.Error(t, responseError)
})
})

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
unregisterWorkflow(ctx, t, caller, transmissionSchedule, func(t *testing.T, responseError error) {
require.Error(t, responseError)
})
})

for _, method := range methods {
testRemoteExecutableCapability(ctx, t, capability, 10, 10, 10*time.Millisecond, 10, 9, timeOut, method)
}
}

func Test_RemoteExecutableCapability_TransmissionSchedules(t *testing.T) {
ctx := testutils.Context(t)

Expand Down Expand Up @@ -214,18 +136,6 @@ func Test_RemoteExecutionCapability_CapabilityError(t *testing.T) {
})
})

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
registerWorkflow(ctx, t, caller, transmissionSchedule, func(t *testing.T, responseError error) {
assert.Equal(t, "error executing request: failed to register to workflow: an error", responseError.Error())
})
})

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
unregisterWorkflow(ctx, t, caller, transmissionSchedule, func(t *testing.T, responseError error) {
assert.Equal(t, "error executing request: failed to unregister from workflow: an error", responseError.Error())
})
})

for _, method := range methods {
testRemoteExecutableCapability(ctx, t, capability, 10, 9, 10*time.Minute, 10, 9, 10*time.Minute, method)
}
Expand All @@ -250,18 +160,6 @@ func Test_RemoteExecutableCapability_RandomCapabilityError(t *testing.T) {
})
})

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
registerWorkflow(ctx, t, caller, transmissionSchedule, func(t *testing.T, responseError error) {
assert.Equal(t, "error executing request: request expired", responseError.Error())
})
})

methods = append(methods, func(ctx context.Context, caller commoncap.ExecutableCapability) {
unregisterWorkflow(ctx, t, caller, transmissionSchedule, func(t *testing.T, responseError error) {
assert.Equal(t, "error executing request: request expired", responseError.Error())
})
})

for _, method := range methods {
testRemoteExecutableCapability(ctx, t, capability, 10, 9, 10*time.Millisecond, 10, 9, 10*time.Minute,
method)
Expand Down
Loading