HA2: Matchmaker configuration

+3 votes
asked Nov 5, 2019 in SWSV by bezo97 (29 points)  

In HA2 Issue "Define Test Scenarios" the following test objective is given:

We would like to ensure that the intra cloud dynamic orchestration process works as specified when default matchmaking is used.

Our problem is that the Orchestrator uses the RandomIntraCloudProviderMatchmaker by default instead of the DefaultIntraCloudProviderMatchmaker. We are not supposed to modify the core code but our integration tests fail otherwise. My question is if there's a way to configure the Orchestrator to use the specified matchmaker or is this expected behavior?

Thanks for the answer in advance.

1 Answer

+1 vote
answered Nov 8, 2019 by micskeiz (2,873 points)  
selected Nov 9, 2019 by bezo97
 
Best answer

You should override the default bean that is providing the MatchMaker algorithm:

@Bean(CommonConstants.INTRA_CLOUD_PROVIDER_MATCHMAKER)

You can to this by defining a new configuration class in the test directory.

See https://stackoverflow.com/questions/35742920/overriding-beans-in-integration-tests for some details.

commented Nov 9, 2019 by OMMHOA (25 points)  
Could you give us more info on this? The stackoverflow answers don't seem to be helping.
We added to application.properties in test resources:
spring.main.allow-bean-definition-overriding=true

Then defined a Helper configuration class next to OrchestratorIntegrationTest.java:
@Configuration
public class Helper {

    @Bean(CommonConstants.INTRA_CLOUD_PROVIDER_MATCHMAKER)
    @Primary
    public IntraCloudProviderMatchmakingAlgorithm getIntraCloudProviderMatchmaker() {
        return new DefaultIntraCloudProviderMatchmaker();
    }
}

Then we imported the configuration in the test:
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@Import(Helper.class)
public class OrchestratorIntegrationTest {


But still the orchestrator.log in debug mode would show that it's using the RandomIntraCloudProviderMatchmaker:
... c.o.m.RandomIntraCloudProviderMatchmaker : RandomIntraCloudProviderMatchmaker.doMatchmaking started...
... c.o.m.RandomIntraCloudProviderMatchmaker : No preferred provider is specified, a random one in the SR list is selected.

We tried to do other things too but none of the solutions actually worked.
...