Skip to content

Commit fe4c970

Browse files
committed
FINERACT-2389: Fix for starting up in Liquibase only mode and pipeline to verify this to prevent breaking
1 parent 9a83ca7 commit fe4c970

File tree

2 files changed

+85
-2
lines changed

2 files changed

+85
-2
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Fineract Liquibase Only mode - PostgreSQL
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-22.04
11+
timeout-minutes: 60
12+
13+
services:
14+
postgresql:
15+
image: postgres:17.4
16+
ports:
17+
- 5432:5432
18+
env:
19+
POSTGRES_USER: root
20+
POSTGRES_PASSWORD: postgres
21+
options: --health-cmd="pg_isready -q -d postgres -U root" --health-interval=5s --health-timeout=2s --health-retries=3
22+
23+
env:
24+
TZ: Asia/Kolkata
25+
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
30+
with:
31+
fetch-depth: 0
32+
fetch-tags: true
33+
34+
- name: Set up JDK 21
35+
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5
36+
with:
37+
java-version: '21'
38+
distribution: 'zulu'
39+
40+
- name: Cache Gradle dependencies
41+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
42+
with:
43+
path: |
44+
~/.gradle/caches
45+
~/.gradle/wrapper
46+
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
47+
48+
- name: Setup Gradle and Validate Wrapper
49+
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
50+
with:
51+
validate-wrappers: true
52+
53+
- name: Verify PostgreSQL connection
54+
run: |
55+
while ! pg_isready -d postgres -U root -h 127.0.0.1 -p 5432 ; do
56+
sleep 1
57+
done
58+
59+
- name: Initialise databases
60+
run: |
61+
./gradlew --no-daemon -q createPGDB -PdbName=fineract_tenants
62+
./gradlew --no-daemon -q createPGDB -PdbName=fineract_default
63+
64+
- name: Run Fineract in Liquibase only mode
65+
env:
66+
FINERACT_DEFAULT_TENANTDB_CONN_PARAMS: ""
67+
FINERACT_DEFAULT_TENANTDB_DESCRIPTION: "Default Demo Tenant"
68+
FINERACT_DEFAULT_TENANTDB_HOSTNAME: "localhost"
69+
FINERACT_DEFAULT_TENANTDB_IDENTIFIER: "default"
70+
FINERACT_DEFAULT_TENANTDB_NAME: "fineract_default"
71+
FINERACT_DEFAULT_TENANTDB_PORT: "5432"
72+
FINERACT_DEFAULT_TENANTDB_PWD: "postgres"
73+
FINERACT_DEFAULT_TENANTDB_TIMEZONE: "Asia/Kolkata"
74+
FINERACT_DEFAULT_TENANTDB_UID: "root"
75+
FINERACT_HIKARI_DRIVER_SOURCE_CLASS_NAME: "org.postgresql.Driver"
76+
FINERACT_HIKARI_JDBC_URL: "jdbc:postgresql://localhost:5432/fineract_tenants"
77+
FINERACT_HIKARI_PASSWORD: "postgres"
78+
FINERACT_HIKARI_USERNAME: "root"
79+
SPRING_PROFILES_ACTIVE: "liquibase-only"
80+
run:
81+
./gradlew fineract-provider:bootRun

fineract-core/src/main/java/org/apache/fineract/infrastructure/core/service/database/TomcatJdbcDataSourcePerTenantService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenantConnection;
3434
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
3535
import org.apache.fineract.infrastructure.core.service.tenant.TenantDetailsService;
36+
import org.springframework.beans.factory.annotation.Autowired;
3637
import org.springframework.beans.factory.annotation.Qualifier;
3738
import org.springframework.context.ApplicationListener;
3839
import org.springframework.context.event.ContextRefreshedEvent;
@@ -56,8 +57,9 @@ public class TomcatJdbcDataSourcePerTenantService implements RoutingDataSourceSe
5657

5758
private final DataSourcePerTenantServiceFactory dataSourcePerTenantServiceFactory;
5859

59-
private final MoneyHelperInitializationService moneyHelperInitializationService;
6060
private final Set<Long> tenantMoneyInitializingSet = Sets.newConcurrentHashSet();
61+
@Autowired(required = false)
62+
private MoneyHelperInitializationService moneyHelperInitializationService;
6163

6264
@Override
6365
public DataSource retrieveDataSource() {
@@ -77,7 +79,7 @@ public DataSource retrieveDataSource() {
7779
// TODO: This is definitely not the optimal place to initialize the rounding modes
7880
// Preferably nothing should use a statically referenced context and the initialization
7981
// should happen within the rounding mode retrieval
80-
if (tenant != null) {
82+
if (moneyHelperInitializationService != null && tenant != null) {
8183
Long connectionId = tenant.getConnection().getConnectionId();
8284
if (!tenantMoneyInitializingSet.contains(connectionId) && !moneyHelperInitializationService.isTenantInitialized(tenant)) {
8385
// Double check to prevent visibility and race-condition issues

0 commit comments

Comments
 (0)