-
Notifications
You must be signed in to change notification settings - Fork 0
fix(graph-rag): fan telemetry to every sink and pin adapter auto-configuration #132
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d703602
fix(graph-rag): fan telemetry out to every event sink
kl3inIT fd495d0
test(graph-rag): prove the storage adapters still auto-configure
kl3inIT 4748961
docs: reconcile secure-graph-rag with the observability wiring change
kl3inIT 86ae6bc
fix(graph-rag): keep composite fan-out safe when sinks share a failure
kl3inIT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
124 changes: 124 additions & 0 deletions
124
...neo4j/src/test/java/com/orgmemory/graphrag/neo4j/Neo4jGraphRagAutoConfigurationTests.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| package com.orgmemory.graphrag.neo4j; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertInstanceOf; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
| import static org.mockito.Mockito.mock; | ||
|
|
||
| import com.orgmemory.graphrag.storage.GraphStore; | ||
| import com.orgmemory.graphrag.storage.ProjectionPublicationStore; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.neo4j.driver.Driver; | ||
| import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
| import org.springframework.boot.autoconfigure.AutoConfigurations; | ||
| import org.springframework.boot.context.annotation.ImportCandidates; | ||
| import org.springframework.boot.test.context.runner.ApplicationContextRunner; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
|
|
||
| /** | ||
| * Neo4j takes the graph port away from whichever adapter would otherwise hold | ||
| * it, so the same two questions matter as for OpenSearch: it must stay inert | ||
| * until an operator enables it, and enabling it must actually produce the | ||
| * store rather than fail somewhere Spring reports as a missing bean. | ||
| */ | ||
| class Neo4jGraphRagAutoConfigurationTests { | ||
|
|
||
| private final ApplicationContextRunner runner = new ApplicationContextRunner() | ||
| .withConfiguration(AutoConfigurations.of(Neo4jGraphRagAutoConfiguration.class)) | ||
| .withUserConfiguration(CollaboratorConfiguration.class); | ||
|
|
||
| @Test | ||
| void staysDiscoverableWithoutAnApplicationNamingIt() { | ||
| assertTrue( | ||
| registeredAutoConfigurations() | ||
| .contains(Neo4jGraphRagAutoConfiguration.class.getName()), | ||
| "META-INF/spring/…AutoConfiguration.imports no longer names this class, " | ||
| + "so enabling the property would silently do nothing"); | ||
| } | ||
|
|
||
| @Test | ||
| void claimsNoGraphPortUntilAnOperatorAsksForIt() { | ||
| runner.run(context -> assertTrue( | ||
| context.getBeansOfType(GraphStore.class).isEmpty(), | ||
| "classpath presence must not displace the canonical graph store")); | ||
| } | ||
|
|
||
| @Test | ||
| void contributesTheGraphStoreOnceEnabled() { | ||
| runner.withPropertyValues( | ||
| "orgmemory.graph-rag.neo4j.enabled=true", | ||
| "orgmemory.graph-rag.neo4j.password=test-password") | ||
| .run(context -> assertInstanceOf( | ||
| Neo4jGraphStore.class, context.getBean(GraphStore.class))); | ||
| } | ||
|
|
||
| @Test | ||
| void refusesToStartRatherThanReachNeo4jUnauthenticated() { | ||
| new ApplicationContextRunner() | ||
| .withConfiguration(AutoConfigurations.of(Neo4jGraphRagAutoConfiguration.class)) | ||
| .withUserConfiguration(PublicationConfiguration.class) | ||
| .withPropertyValues("orgmemory.graph-rag.neo4j.enabled=true") | ||
| .run(context -> { | ||
| Throwable cause = rootCause(context.getStartupFailure()); | ||
| assertInstanceOf( | ||
| IllegalArgumentException.class, | ||
| cause, | ||
| "an enabled adapter without a password must fail startup"); | ||
| assertEquals( | ||
| "Neo4j password must be configured when the adapter is enabled", | ||
| cause.getMessage(), | ||
| "the password branch must be what fails, not another " | ||
| + "validation rule"); | ||
| }); | ||
| } | ||
|
|
||
| private static Throwable rootCause(Throwable failure) { | ||
| Throwable cause = failure; | ||
| while (cause != null && cause.getCause() != null) { | ||
| cause = cause.getCause(); | ||
| } | ||
| return cause; | ||
| } | ||
|
|
||
| private static List<String> registeredAutoConfigurations() { | ||
| var names = new ArrayList<String>(); | ||
| ImportCandidates.load( | ||
| AutoConfiguration.class, | ||
| Neo4jGraphRagAutoConfigurationTests.class.getClassLoader()) | ||
| .forEach(names::add); | ||
| return names; | ||
| } | ||
|
|
||
| /** | ||
| * The collaborators an application already owns before this adapter loads. | ||
| * Supplying the driver and {@link Neo4jOperations} keeps a live Neo4j out of | ||
| * a unit test; the adapter backs off both because they are conditional on a | ||
| * missing bean. | ||
| */ | ||
| @Configuration(proxyBeanMethods = false) | ||
| static class CollaboratorConfiguration extends PublicationConfiguration { | ||
|
|
||
| @Bean | ||
| Driver neo4jDriver() { | ||
| return mock(Driver.class); | ||
| } | ||
|
|
||
| @Bean | ||
| Neo4jOperations neo4jOperations() { | ||
| return mock(Neo4jOperations.class); | ||
| } | ||
| } | ||
|
|
||
| /** Only the port the adapter expects an application to already provide. */ | ||
| @Configuration(proxyBeanMethods = false) | ||
| static class PublicationConfiguration { | ||
|
|
||
| @Bean | ||
| ProjectionPublicationStore projectionPublicationStore() { | ||
| return mock(ProjectionPublicationStore.class); | ||
| } | ||
| } | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.