251 lines
10 KiB
Gherkin
251 lines
10 KiB
Gherkin
Feature: Route Bridge Module Coverage
|
|
As a developer
|
|
I want to test all functionality in the route bridge module
|
|
So that we achieve 90%+ code coverage for the route_bridge.py file
|
|
|
|
Background:
|
|
Given I have a clean test environment for route bridge
|
|
|
|
Scenario: Test RouteBridge initialization
|
|
Given I have a stream router and agents
|
|
When I create a RouteBridge instance
|
|
Then the route bridge should be initialized correctly
|
|
And the logger should be set up
|
|
And active conversions should be empty
|
|
|
|
Scenario: Test RouteBridge initialization with scheduler
|
|
Given I have a stream router and agents
|
|
And I have an AsyncIO scheduler
|
|
When I create a RouteBridge instance with scheduler
|
|
Then the route bridge should be initialized with scheduler
|
|
And the scheduler should be stored correctly
|
|
|
|
Scenario: Test check_upgrade_conditions - no bridge config
|
|
Given I have a RouteBridge instance
|
|
And I have a route config without bridge configuration
|
|
And I have a stream message
|
|
When I check upgrade conditions
|
|
Then the result should be False
|
|
|
|
Scenario: Test check_upgrade_conditions - wrong route type
|
|
Given I have a RouteBridge instance
|
|
And I have a graph route config with bridge configuration
|
|
And I have a stream message
|
|
When I check upgrade conditions
|
|
Then the result should be False
|
|
|
|
Scenario: Test check_upgrade_conditions - needs_state condition
|
|
Given I have a RouteBridge instance
|
|
And I have a stream route config with needs_state upgrade condition
|
|
And I have a stream message with requires_state metadata
|
|
When I check upgrade conditions
|
|
Then the result should be True
|
|
|
|
Scenario: Test check_upgrade_conditions - message_count condition
|
|
Given I have a RouteBridge instance
|
|
And I have a stream route config with message_count upgrade condition
|
|
And I have processed enough messages to trigger upgrade
|
|
When I check upgrade conditions
|
|
Then the result should be True
|
|
|
|
Scenario: Test check_upgrade_conditions - complexity_threshold condition
|
|
Given I have a RouteBridge instance
|
|
And I have a stream route config with complexity_threshold upgrade condition
|
|
And I have a complex route configuration
|
|
When I check upgrade conditions
|
|
Then the result should be True
|
|
|
|
Scenario: Test check_upgrade_conditions - custom_predicate condition
|
|
Given I have a RouteBridge instance
|
|
And I have a stream route config with custom_predicate upgrade condition
|
|
And I have a custom predicate that returns True
|
|
When I check upgrade conditions
|
|
Then the result should be True
|
|
|
|
Scenario: Test check_upgrade_conditions - custom_predicate false
|
|
Given I have a RouteBridge instance
|
|
And I have a stream route config with custom_predicate upgrade condition
|
|
And I have a custom predicate that returns False
|
|
When I check upgrade conditions
|
|
Then the result should be False
|
|
|
|
Scenario: Test check_upgrade_conditions - non-callable predicate
|
|
Given I have a RouteBridge instance
|
|
And I have a stream route config with non-callable custom_predicate
|
|
And I have a stream message
|
|
When I check upgrade conditions
|
|
Then the result should be False
|
|
|
|
Scenario: Test check_downgrade_conditions - no bridge config
|
|
Given I have a RouteBridge instance
|
|
And I have a route config without bridge configuration
|
|
And I have a graph state
|
|
When I check downgrade conditions
|
|
Then the result should be False
|
|
|
|
Scenario: Test check_downgrade_conditions - wrong route type
|
|
Given I have a RouteBridge instance
|
|
And I have a stream route config with bridge configuration
|
|
And I have a graph state
|
|
When I check downgrade conditions
|
|
Then the result should be False
|
|
|
|
Scenario: Test check_downgrade_conditions - idle_time condition
|
|
Given I have a RouteBridge instance
|
|
And I have a graph route config with idle_time downgrade condition
|
|
And I have a graph state that has been idle too long
|
|
When I check downgrade conditions
|
|
Then the result should be True
|
|
|
|
Scenario: Test check_downgrade_conditions - state_size condition
|
|
Given I have a RouteBridge instance
|
|
And I have a graph route config with state_size downgrade condition
|
|
And I have a graph state with minimal messages
|
|
When I check downgrade conditions
|
|
Then the result should be True
|
|
|
|
Scenario: Test check_downgrade_conditions - no_conditionals_used condition
|
|
Given I have a RouteBridge instance
|
|
And I have a graph route config with no_conditionals_used downgrade condition
|
|
And I have a graph state with no conditional edges used
|
|
When I check downgrade conditions
|
|
Then the result should be True
|
|
|
|
Scenario: Test upgrade_stream_to_graph - basic functionality
|
|
Given I have a RouteBridge instance
|
|
And I have a stream route config for upgrade
|
|
And I have a stream message
|
|
When I upgrade stream to graph
|
|
Then a LangGraph should be created
|
|
And the graph should be configured correctly
|
|
And active conversions should be updated
|
|
|
|
Scenario: Test upgrade_stream_to_graph - with state extractor
|
|
Given I have a RouteBridge instance
|
|
And I have a stream route config with state extractor
|
|
And I have a stream message
|
|
When I upgrade stream to graph
|
|
Then a LangGraph should be created with initial state
|
|
And the state should be extracted correctly
|
|
|
|
Scenario: Test upgrade_stream_to_graph - with preserve subscriptions
|
|
Given I have a RouteBridge instance
|
|
And I have a stream route config with preserve subscriptions
|
|
And I have a stream message
|
|
When I upgrade stream to graph
|
|
Then a LangGraph should be created
|
|
And subscriptions should be preserved
|
|
|
|
Scenario: Test downgrade_graph_to_stream - basic functionality
|
|
Given I have a RouteBridge instance
|
|
And I have a graph route config for downgrade
|
|
And I have a LangGraph instance
|
|
When I downgrade graph to stream
|
|
Then a StreamConfig should be created
|
|
And the stream should be configured correctly
|
|
And active conversions should be updated
|
|
|
|
Scenario: Test downgrade_graph_to_stream - with state flattener
|
|
Given I have a RouteBridge instance
|
|
And I have a graph route config with state flattener
|
|
And I have a LangGraph instance with state
|
|
When I downgrade graph to stream
|
|
Then a StreamConfig should be created
|
|
And the state should be flattened correctly
|
|
|
|
Scenario: Test downgrade_graph_to_stream - with preserve checkpointing
|
|
Given I have a RouteBridge instance
|
|
And I have a graph route config with preserve checkpointing
|
|
And I have a LangGraph instance with checkpoint directory
|
|
When I downgrade graph to stream
|
|
Then a StreamConfig should be created
|
|
And checkpointing should be preserved
|
|
|
|
Scenario: Test _create_graph_from_stream - basic operators
|
|
Given I have a RouteBridge instance
|
|
And I have a stream route config with basic operators
|
|
When I create graph from stream
|
|
Then a GraphConfig should be created
|
|
And nodes should be created from operators
|
|
And edges should connect the nodes properly
|
|
|
|
Scenario: Test _create_graph_from_stream - agent operators
|
|
Given I have a RouteBridge instance
|
|
And I have a stream route config with agent operators
|
|
When I create graph from stream
|
|
Then a GraphConfig should be created with agent nodes
|
|
And agent nodes should be configured correctly
|
|
|
|
Scenario: Test _create_graph_from_stream - mixed operators
|
|
Given I have a RouteBridge instance
|
|
And I have a stream route config with mixed operators
|
|
When I create graph from stream
|
|
Then a GraphConfig should be created with mixed node types
|
|
And all operators should be converted to nodes
|
|
|
|
Scenario: Test _create_stream_from_graph - basic functionality
|
|
Given I have a RouteBridge instance
|
|
And I have a graph route config
|
|
And I have a LangGraph with nodes
|
|
When I create stream from graph
|
|
Then a StreamConfig should be created
|
|
And operators should be extracted from nodes
|
|
And the stream should be configured properly
|
|
|
|
Scenario: Test _create_stream_from_graph - with agent nodes
|
|
Given I have a RouteBridge instance
|
|
And I have a graph route config
|
|
And I have a LangGraph with agent nodes
|
|
When I create stream from graph
|
|
Then a StreamConfig should be created with agent operators
|
|
And agents should be extracted correctly
|
|
|
|
Scenario: Test _create_stream_from_graph - with function nodes
|
|
Given I have a RouteBridge instance
|
|
And I have a graph route config
|
|
And I have a LangGraph with function nodes
|
|
When I create stream from graph
|
|
Then a StreamConfig should be created with function operators
|
|
And function operators should be restored correctly
|
|
|
|
Scenario: Test _get_message_count functionality
|
|
Given I have a RouteBridge instance
|
|
When I get message count for a route
|
|
Then the message count should be returned
|
|
And the result should be a valid integer
|
|
|
|
Scenario: Test get_active_conversion - existing conversion
|
|
Given I have a RouteBridge instance
|
|
And I have an active conversion registered
|
|
When I get active conversion info
|
|
Then the conversion info should be returned
|
|
And the info should contain the correct details
|
|
|
|
Scenario: Test get_active_conversion - non-existing conversion
|
|
Given I have a RouteBridge instance
|
|
When I get active conversion info for non-existing route
|
|
Then None should be returned for route bridge
|
|
|
|
Scenario: Test error handling in upgrade_stream_to_graph
|
|
Given I have a RouteBridge instance
|
|
And I have an invalid stream route config
|
|
And I have a stream message
|
|
When I attempt to upgrade stream to graph
|
|
Then appropriate error handling should occur
|
|
And the system should remain stable
|
|
|
|
Scenario: Test error handling in downgrade_graph_to_stream
|
|
Given I have a RouteBridge instance
|
|
And I have an invalid graph route config
|
|
And I have a corrupted LangGraph instance
|
|
When I attempt to downgrade graph to stream
|
|
Then appropriate error handling should occur
|
|
And the system should remain stable
|
|
|
|
Scenario: Test complex upgrade downgrade cycle
|
|
Given I have a RouteBridge instance
|
|
And I have a route config that supports both upgrade and downgrade
|
|
When I perform an upgrade and then downgrade cycle
|
|
Then the cycle should complete successfully
|
|
And the final configuration should be consistent
|
|
And active conversions should be tracked correctly |