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

Mock streams trigger #14078

Closed
wants to merge 5 commits into from
Closed

Mock streams trigger #14078

wants to merge 5 commits into from

Conversation

archseer
Copy link
Contributor

@archseer archseer commented Aug 8, 2024

Makes it easier to develop and test workflows by providing a data source compatible with streams trigger, but mocked. It also stubs out the local capability registry if an external one isn't defined, this allows us to test workflows without having to have a capability registry up and running.

@archseer archseer requested review from bolekk and ettec August 8, 2024 12:31
@archseer archseer requested a review from a team as a code owner August 8, 2024 12:31
Copy link
Contributor

github-actions bot commented Aug 8, 2024

I see you updated files related to core. Please run pnpm changeset in the root directory to add a changeset as well as in the text include at least one of the following tags:

  • #added For any new functionality added.
  • #breaking_change For any functionality that requires manual action for the node to boot.
  • #bugfix For bug fixes.
  • #changed For any change to the existing functionality.
  • #db_update For any feature that introduces updates to database schema.
  • #deprecation_notice For any upcoming deprecation functionality.
  • #internal For changesets that need to be excluded from the final changelog.
  • #nops For any feature that is NOP facing and needs to be in the official Release Notes for the release.
  • #removed For any functionality/config that is removed.
  • #updated For any functionality that is updated.
  • #wip For any change that is not ready yet and external communication about it should be held off till it is feature complete.

🎖️ No JIRA issue number found in: PR title, commit message, or branch name. Please include the issue ID in one of these.

@@ -206,6 +207,13 @@ func NewApplication(opts ApplicationOpts) (Application, error) {
opts.CapabilitiesRegistry = capabilities.NewRegistry(globalLogger)
}

// Use a recurring trigger with mock data for testing purposes
// TODO: proper component shutdown via srvcs()
_, err := capStreams.RegisterMockTrigger(globalLogger, opts.CapabilitiesRegistry)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@archseer Really not wild about this: can we package up the mock as a standard capability instead? That way there won't be any code hanging around the core node to support this

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, trigger capabilities should provide a mocked version of themselves (same output types, different implementation).

@@ -258,6 +266,9 @@ func NewApplication(opts ApplicationOpts) (Application, error) {

srvcs = append(srvcs, wfLauncher, registrySyncer)
}
} else {
// If registry syncer is not set up we use a dummy local registry so that local capabilities can still be used
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@archseer this shouldn't be fallback behaviour: this should only be set explicitly if a specific config flag is set (eg. if the registryAddress == "MOCK_REGISTRY_ADDRESS" or similar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not though? If no registry is set the node is in a broken state where local capabilities won't work. By providing a mock we're at least able to use workflows

func NewMockDataProducer(trigger *MockTriggerService, meta datastreams.SignersMetadata, signers []*ecdsa.PrivateKey, feedIDs []string, lggr logger.Logger) *mockDataProducer {
return &mockDataProducer{
trigger: trigger,
closeCh: make(chan struct{}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

closeCh doesn't seem used

}

// Only start the producer once a workflow is registered
o.producer = NewMockDataProducer(o, o.meta, o.signers, config.FeedIDs, o.lggr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we close the old producer before starting a new one, or just start it once on first registration?

@archseer
Copy link
Contributor Author

Closing for now, refactoring this

@archseer archseer closed this Aug 23, 2024
@archseer archseer deleted the mock-streams-trigger branch August 23, 2024 07:36
@archseer archseer restored the mock-streams-trigger branch August 23, 2024 07:36
@archseer archseer deleted the mock-streams-trigger branch August 23, 2024 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants