Files
cleveragents-core/features/plugin_executing_state.feature
HAL9000 552dcb15b0
CI / lint (pull_request) Successful in 43s
CI / helm (pull_request) Successful in 45s
CI / build (pull_request) Successful in 53s
CI / quality (pull_request) Successful in 56s
CI / push-validation (pull_request) Successful in 55s
CI / typecheck (pull_request) Successful in 1m18s
CI / security (pull_request) Successful in 1m21s
CI / unit_tests (pull_request) Successful in 6m29s
CI / integration_tests (pull_request) Successful in 9m16s
CI / docker (pull_request) Successful in 1m41s
CI / coverage (pull_request) Successful in 12m27s
CI / status-check (pull_request) Successful in 3s
fix(plugins): remove duplicate step definitions and fix keyword context in feature
AmbiguousStep error caused all 8 features to error: plugin_executing_state_steps.py
re-defined 6 steps already present in plugin_architecture_steps.py:
- @then("a PluginError should be raised")
- @then("a PluginNotFoundError should be raised")
- @then('the plugin error message should contain "{text}"')
- @when('I attempt to deactivate the plugin "{name}"')
- @given("the PluginState enum is available")
- @then('it should have values ...')

Remove all duplicates, keeping only the 6 new steps unique to this feature.

Also fix the last scenario where `And I attempt to execute method on unknown plugin`
followed a `Given` step (so behave treated it as `given` context, not matching
the `@when` definition). Changed `And` to `When`.

ISSUES CLOSED: #5691
2026-06-04 20:36:52 -04:00

100 lines
5.2 KiB
Gherkin

@mock_only
Feature: PluginState.EXECUTING lifecycle state
The PluginManager must set the EXECUTING state when a plugin method is
being invoked, completing the plugin lifecycle state machine as defined
in the specification.
Based on issue #5691.
# -----------------------------------------------------------------------
# Happy path: execute_plugin transitions ACTIVATED -> EXECUTING -> ACTIVATED
# -----------------------------------------------------------------------
Scenario: execute_plugin transitions plugin to ACTIVATED after successful execution
Given a fresh PluginManager instance
And a PluginDescriptor for "exec-plugin" with module "cleveragents.domain.models.acms.stubs" and class "InMemoryTextBackend"
When I register the plugin descriptor
And I activate the plugin "exec-plugin"
And I execute method "search" on plugin "exec-plugin" with valid args
Then the plugin "exec-plugin" state should be "activated"
Scenario: execute_plugin returns the method result
Given a fresh PluginManager instance
And a PluginDescriptor for "exec-plugin" with module "cleveragents.domain.models.acms.stubs" and class "InMemoryTextBackend"
When I register the plugin descriptor
And I activate the plugin "exec-plugin"
And I execute method "search" on plugin "exec-plugin" with valid args
Then the execution result should be an empty list
# -----------------------------------------------------------------------
# Error path: execute_plugin transitions ACTIVATED -> EXECUTING -> ERRORED
# -----------------------------------------------------------------------
Scenario: execute_plugin transitions plugin to ERRORED on method exception
Given a fresh PluginManager instance
And a PluginDescriptor for "exec-plugin" with module "cleveragents.domain.models.acms.stubs" and class "InMemoryTextBackend"
When I register the plugin descriptor
And I activate the plugin "exec-plugin"
And I attempt to execute a failing method on plugin "exec-plugin"
Then the plugin "exec-plugin" state should be "errored"
And a PluginError should be raised
Scenario: execute_plugin wraps method exceptions in PluginError
Given a fresh PluginManager instance
And a PluginDescriptor for "exec-plugin" with module "cleveragents.domain.models.acms.stubs" and class "InMemoryTextBackend"
When I register the plugin descriptor
And I activate the plugin "exec-plugin"
And I attempt to execute a failing method on plugin "exec-plugin"
Then a PluginError should be raised
And the plugin error message should contain "execution failed"
# -----------------------------------------------------------------------
# Guard: execute_plugin requires ACTIVATED state
# -----------------------------------------------------------------------
Scenario: execute_plugin raises PluginError if plugin is not activated
Given a fresh PluginManager instance
And a PluginDescriptor for "exec-plugin" with module "cleveragents.domain.models.acms.stubs" and class "InMemoryTextBackend"
When I register the plugin descriptor
And I attempt to execute method on non-activated plugin "exec-plugin"
Then a PluginError should be raised
Scenario: execute_plugin raises PluginError if plugin is in ERRORED state
Given a fresh PluginManager instance
And a PluginDescriptor for "exec-plugin" with module "cleveragents.domain.models.acms.stubs" and class "InMemoryTextBackend"
When I register the plugin descriptor
And I activate the plugin "exec-plugin"
And I attempt to execute a failing method on plugin "exec-plugin"
And I attempt to execute method on non-activated plugin "exec-plugin"
Then a PluginError should be raised
# -----------------------------------------------------------------------
# Thread safety: EXECUTING state prevents concurrent deactivation
# -----------------------------------------------------------------------
Scenario: Cannot deactivate a plugin that is in EXECUTING state
Given a fresh PluginManager instance
And a PluginDescriptor for "exec-plugin" with module "cleveragents.domain.models.acms.stubs" and class "InMemoryTextBackend"
When I register the plugin descriptor
And I activate the plugin "exec-plugin"
And I manually set plugin "exec-plugin" state to "executing"
And I attempt to deactivate the plugin "exec-plugin"
Then a PluginError should be raised
# -----------------------------------------------------------------------
# PluginState enum includes EXECUTING
# -----------------------------------------------------------------------
Scenario: PluginState enum includes the EXECUTING value
Given the PluginState enum is available
Then it should have values "discovered", "activated", "executing", "deactivated", "errored"
# -----------------------------------------------------------------------
# execute_plugin raises PluginNotFoundError for unknown plugin
# -----------------------------------------------------------------------
Scenario: execute_plugin raises PluginNotFoundError for unknown plugin
Given a fresh PluginManager instance
When I attempt to execute method on unknown plugin "nonexistent-plugin"
Then a PluginNotFoundError should be raised