fix(test): enable template support in test command#358
Open
Phantal wants to merge 1 commit intoredpanda-data:mainfrom
Open
fix(test): enable template support in test command#358Phantal wants to merge 1 commit intoredpanda-data:mainfrom
Phantal wants to merge 1 commit intoredpanda-data:mainfrom
Conversation
Templates loaded via the -t flag were not available during test execution because the manager defaulted to bundle.GlobalEnvironment instead of using the environment where templates were registered. This fix explicitly passes the environment to the manager, matching the pattern used by the run command (internal/cli/common/manager.go:107). The issue only affects RPK, which uses a cloned environment rather than bundle.GlobalEnvironment directly. Standalone Benthos is unaffected. Changes: - Add manager.OptSetEnvironment(p.env) in processors_provider.go - Add integration test verifying templates work with ProcessorsProvider
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enable template support in
rpk connect testby explicitly passing the environment to the manager.Problem
Templates loaded via the
-tflag were not recognized during test execution (see benthos issue 287):Root Cause
RPK creates a cloned environment at startup via
service.NewEnvironment(). When templates are registered, they're added to this cloned environment, notbundle.GlobalEnvironment. The test command's manager was created without explicitly passing the environment, causing it to default tobundle.GlobalEnvironment(which doesn't have templates).Execution flow:
schema.Environment()(has built-in processors)schema.Environment()(now has templates too)schema.Environment()(parsing works ✓)bundle.GlobalEnvironment(no templates ✗)Solution
Pass the environment explicitly when creating the manager, matching the pattern used by the
runcommand (internal/cli/common/manager.go:107).Files changed:
internal/cli/test/processors_provider.go- Addmanager.OptSetEnvironment(p.env)internal/cli/test/processors_provider_test.go- Add integration testTesting
benthos test -t template.yaml test.yamlsucceedsNotes
bundle.GlobalEnvironmentdirectly)