feat(test): add LLM test support abstraction for graceful skipping - #26
Merged
Conversation
Add a new test support package with utilities for handling LLM-dependent tests: - @RequiresLlm annotation: marks tests that need LLM configuration - Supports chat and embedding requirements independently - Tests are skipped (not failed) when LLM is not configured - Works at class or method level - LlmAvailabilityCondition: JUnit 5 ExecutionCondition - Checks DEEPSQL_CHAT_* and DEEPSQL_EMBEDDING_* environment variables - Uses the same resolution logic as production LlmConfigResolver - LlmTestSupport: Spring component for integration tests - Uses actual LlmConfigResolver to check both env vars and DB config - Provides requireChat(), requireEmbedding() methods for test assertions - Includes diagnostic describeConfiguration() method Updated BaseIntegrationTest: - Autowires LlmTestSupport for integration tests - Adds convenience methods: isChatLlmAvailable(), requireChatLlm(), etc. Updated ChatPromptIntegrationTest: - Added @RequiresLlm(chat = true) annotation - All 23 tests now skip gracefully when LLM is not configured - Improved Javadoc documentation This allows the test suite to run cleanly in environments without LLM credentials, while still validating LLM-dependent functionality when credentials are available. Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
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
This PR introduces a test support abstraction for LLM-dependent tests, allowing them to skip gracefully when LLM credentials are not configured instead of failing with cryptic errors.
Problem
Previously, integration tests that required LLM configuration (like
ChatPromptIntegrationTest) would fail with "agent runtime hit an internal execution failure" when LLM credentials weren't set. This made it impossible to get a clean test run without full LLM configuration.Solution
Added a new
com.dbaagent.supporttest package with three components:1.
@RequiresLlmAnnotationchatandembeddingrequirements2.
LlmAvailabilityConditionJUnit 5
ExecutionConditionthat checksDEEPSQL_CHAT_*andDEEPSQL_EMBEDDING_*environment variables using the same resolution logic as productionLlmConfigResolver.3.
LlmTestSupportSpring component for use within integration tests that need more control:
Changes
New files:
backend/src/test/java/com/dbaagent/support/RequiresLlm.javabackend/src/test/java/com/dbaagent/support/LlmAvailabilityCondition.javabackend/src/test/java/com/dbaagent/support/LlmTestSupport.javabackend/src/test/java/com/dbaagent/support/LlmAvailabilityConditionTest.javaUpdated files:
backend/src/test/java/com/dbaagent/integration/BaseIntegrationTest.java- Added LlmTestSupport integration and convenience methodsbackend/src/test/java/com/dbaagent/integration/ChatPromptIntegrationTest.java- Added@RequiresLlmannotationTest Results
Before this change,
ChatPromptIntegrationTesthad 20+ failures when LLM wasn't configured.After this change:
All tests skip cleanly with a clear message about the missing configuration.
How to Use
For new tests requiring LLM:
For tests requiring both chat and embedding:
For programmatic checks: