FINERACT-1571: Allow Liquibase data migration for write instances only
This commit is contained in:
committed by
Arnold Gálovics
parent
e3e4dbeb8a
commit
56d14a1d69
@@ -103,7 +103,7 @@ public class TestConfiguration {
|
||||
@Bean
|
||||
public TenantDatabaseStateVerifier tenantDatabaseStateVerifier(DatabaseIndependentQueryService databaseIndependentQueryService,
|
||||
LiquibaseProperties liquibaseProperties, FineractProperties fineractProperties) {
|
||||
return new TenantDatabaseStateVerifier(liquibaseProperties, databaseIndependentQueryService);
|
||||
return new TenantDatabaseStateVerifier(liquibaseProperties, databaseIndependentQueryService, fineractProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.core;
|
||||
|
||||
import io.cucumber.java8.En;
|
||||
import org.apache.fineract.infrastructure.core.config.FineractProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class InstanceTypeStepDefinitions implements En {
|
||||
|
||||
@Autowired
|
||||
private FineractProperties fineractProperties;
|
||||
|
||||
public InstanceTypeStepDefinitions() {
|
||||
Given("Set every Fineract instance type to false", () -> {
|
||||
fineractProperties.getMode().setWriteEnabled(false);
|
||||
fineractProperties.getMode().setReadEnabled(false);
|
||||
fineractProperties.getMode().setBatchEnabled(false);
|
||||
});
|
||||
Given("Fineract instance is a write instance", () -> {
|
||||
fineractProperties.getMode().setWriteEnabled(true);
|
||||
});
|
||||
Given("Fineract instance is a read instance", () -> {
|
||||
fineractProperties.getMode().setReadEnabled(true);
|
||||
});
|
||||
Given("Fineract instance is a batch instance", () -> {
|
||||
fineractProperties.getMode().setBatchEnabled(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
+9
-4
@@ -40,12 +40,14 @@ import org.apache.fineract.infrastructure.core.service.migration.TenantDataSourc
|
||||
import org.apache.fineract.infrastructure.core.service.migration.TenantDatabaseStateVerifier;
|
||||
import org.apache.fineract.infrastructure.core.service.migration.TenantDatabaseUpgradeService;
|
||||
import org.apache.fineract.infrastructure.security.service.TenantDetailsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class LiquibaseStepDefinitions implements En {
|
||||
|
||||
private TenantDataSourceFactory tenantDataSourceFactory;
|
||||
private TenantDetailsService tenantDetailsService;
|
||||
private TenantDatabaseStateVerifier databaseStateVerifier;
|
||||
@Autowired
|
||||
private FineractProperties fineractProperties;
|
||||
private ExtendedSpringLiquibaseFactory liquibaseFactory;
|
||||
private ExtendedSpringLiquibase initialTenantStoreLiquibase;
|
||||
@@ -100,8 +102,13 @@ public class LiquibaseStepDefinitions implements En {
|
||||
Then("The database migration did not do anything", () -> {
|
||||
verify(databaseStateVerifier).isLiquibaseDisabled();
|
||||
verifyNoMoreInteractions(databaseStateVerifier);
|
||||
verifyNoInteractions(tenantDetailsService, tenantStoreDataSource, fineractProperties, liquibaseFactory,
|
||||
tenantDataSourceFactory);
|
||||
verifyNoInteractions(tenantDetailsService, tenantStoreDataSource, liquibaseFactory, tenantDataSourceFactory);
|
||||
});
|
||||
|
||||
Then("The database migration did not do anything, because it is not a write instance", () -> {
|
||||
verify(databaseStateVerifier).isLiquibaseDisabled();
|
||||
verifyNoMoreInteractions(databaseStateVerifier);
|
||||
verifyNoInteractions(tenantDetailsService, tenantStoreDataSource, liquibaseFactory, tenantDataSourceFactory);
|
||||
});
|
||||
|
||||
Then("The tenant store upgrade fails with a schema upgrade needed", () -> {
|
||||
@@ -140,7 +147,6 @@ public class LiquibaseStepDefinitions implements En {
|
||||
tenantDataSourceFactory = mock(TenantDataSourceFactory.class);
|
||||
tenantDetailsService = mock(TenantDetailsService.class);
|
||||
databaseStateVerifier = mock(TenantDatabaseStateVerifier.class);
|
||||
fineractProperties = mock(FineractProperties.class);
|
||||
|
||||
liquibaseFactory = mock(ExtendedSpringLiquibaseFactory.class);
|
||||
|
||||
@@ -158,7 +164,6 @@ public class LiquibaseStepDefinitions implements En {
|
||||
defaultTenantDataSource = mock(DataSource.class);
|
||||
|
||||
given(databaseStateVerifier.isLiquibaseDisabled()).willReturn(!liquibaseEnabled);
|
||||
given(fineractProperties.getTenant()).willReturn(new FineractProperties.FineractTenantProperties());
|
||||
given(liquibaseFactory.create(tenantStoreDataSource, "tenant_store_db", "initial_switch")).willReturn(initialTenantStoreLiquibase);
|
||||
given(liquibaseFactory.create(tenantStoreDataSource, "tenant_store_db")).willReturn(tenantStoreLiquibase);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user