Skip to content
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

TestContainer: properties precedence over ServerConnection #3022

Open
oleborne opened this issue May 13, 2024 · 2 comments
Open

TestContainer: properties precedence over ServerConnection #3022

oleborne opened this issue May 13, 2024 · 2 comments
Labels
Type: Bug Use to signal issues that describe a bug within the system.

Comments

@oleborne
Copy link

oleborne commented May 13, 2024

Basic information

Steps to reproduce

  1. write a test using Axon Server test container
    • annotate test class with @TestContainers
    • instantiate a AxonServerContainer as a field of the test class, annotated with @Container and @ServiceConnection
  2. Set the axon.axonserver.servers property in a property file with unknownhost, which is an unresolvable host.

Expected behaviour

The @ServiceConnection annotation has precedence over property based configuration and the Axon Server test container can be accessed by the test.

Actual behaviour

The property axon.axonserver.servers set to unknownhost overrides the configuration generated thanks to the @ServiceConnection annotation.


By looking at JDBC implementation, this precedence is properly handled by having the connection details object (JdbcConnectionDetails) being an interface distinct from the properties object (DataSourceProperties), allowing for a property based implementation of the connection details and a test container based implementation of the same connection details interface.
In Axon Framework, AxonServerConfiguration is both bound to a ConfigurationProperties and created by a connection detail factory when using test containers.

@oleborne oleborne added the Type: Bug Use to signal issues that describe a bug within the system. label May 13, 2024
@gklijs
Copy link
Member

gklijs commented May 13, 2024

Thanks for reporting this. I would expect the configuration:

@ConditionalOnBean(type = "org.axonframework.springboot.service.connection.AxonServerConnectionDetails")
@Bean
public AxonServerConfiguration axonServerConfigurationWithConnectionDetails(AxonServerConnectionDetails connectionDetails) {
    AxonServerConfiguration configuration = new AxonServerConfiguration();
    configuration.setComponentName(clientName(applicationContext.getId()));
    configuration.setServers(connectionDetails.routingServers());
    return configuration;
}

Would make sure the servers from the AxonServerConnectionDetails is taken before creating the AxonServerConnectionManager. But apparently that doesn't work all the time.

@oleborne
Copy link
Author

When debugging, the instance is properly created by this axonServerConfigurationWithConnectionDetails @Bean but it is then later modified by the ConfigurationPropertiesBindingPostProcessor.

From the javadoc for ConfigurationPropertiesBindingPostProcessor:

BeanPostProcessor to bind PropertySources to beans annotated with ConfigurationProperties.

So this does not sound like a ordering issue but tied to the fact that this Bean is annotated with ConfigurationProperties so will always be bound to properties after being instantiated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Use to signal issues that describe a bug within the system.
Projects
None yet
Development

No branches or pull requests

2 participants