This is an automated email from the ASF dual-hosted git repository.

awasum pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new 4e1d87f  fix broken docker-compose set up (re. FINERACT-773)
     new 7420545  Merge pull request #690 from 
vorburger/FINERACT-773_fix-docker-compose
4e1d87f is described below

commit 4e1d87f20a0042ad8b7208f55e1ef29af5cdb91e
Author: Michael Vorburger <[email protected]>
AuthorDate: Sun Jan 12 20:44:22 2020 +0100

    fix broken docker-compose set up (re. FINERACT-773)
    
    This fixed bugs introduced in edc9e030e10b9f7f6c394ab35c307c7fa28939a0
    (in https://github.com/apache/fineract/pull/648) which for FINERACT-773
    actually broke things more instead of adding the intended feature, cauz:
    
    1. FINERACT_DEFAULT_TENANTDB_HOSTNAME and FINERACT_DEFAULT_TENANTDB_PORT
       were meant to be OS Environment Variables, not Java System properties
       and so need to be read via System.getenv() not System.getProperty(),
       duh!
    
    2. The Travis CI test which was meant to ensure non-regression for this
       broke in that same change, because the "|| docker logs" introduced at
       the same time would always pass (EITHER because "http" passed OR
       if not then "docker logs" would return 0), duh again!
    
    Both were dumb, not sure what I was thinking when I had hacked this.. ;)
---
 .travis.yml                                        |  3 +--
 .../core/service/TenantDatabaseUpgradeService.java | 26 +++++++++++++++++-----
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index ced6823..3a0f0a1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -61,6 +61,5 @@ script:
 # using "&&" instead of several "-" means that integrationTest does not run if 
test fails,
 # and Docker test does not run if integration test fails, which makes PR 
failure easier to understand.
 # @see 
https://docs.travis-ci.com/user/job-lifecycle/#customizing-the-build-phase
-  - ./gradlew --console=plain licenseMain licenseTest licenseIntegrationTest 
check  &&  ./gradlew --console=plain integrationTest  &&  sudo service mysql 
stop  &&  docker-compose build  &&  docker-compose up -d  &&  sleep 30s  &&  
http --verify=no --timeout 240 --check-status get 
https://localhost:8443/fineract-provider/actuator/health || docker logs 
fineract_fineract-server_1
+  - ./gradlew --console=plain licenseMain licenseTest licenseIntegrationTest 
check  &&  ./gradlew --console=plain integrationTest  &&  sudo service mysql 
stop  &&  docker-compose build  &&  docker-compose up -d  &&  sleep 30s  &&  
http --verify=no --timeout 240 --check-status get 
https://localhost:8443/fineract-provider/actuator/health
 # We stop the mysql system service when running the Docker test to avoid port 
3306 conflicts (unless we run the mysql in docker-compose on another port; req. 
FINERACT-773)
-# The || docker logs lets use see the root cause in case of failures
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/TenantDatabaseUpgradeService.java
 
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/TenantDatabaseUpgradeService.java
index 0a1c91b..c831945 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/TenantDatabaseUpgradeService.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/TenantDatabaseUpgradeService.java
@@ -28,6 +28,8 @@ import 
org.apache.fineract.infrastructure.core.boot.db.TenantDataSourcePortFixSe
 import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
 import 
org.apache.fineract.infrastructure.core.domain.FineractPlatformTenantConnection;
 import 
org.apache.fineract.infrastructure.security.service.TenantDetailsService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
@@ -45,12 +47,14 @@ import 
com.googlecode.flyway.core.util.jdbc.DriverDataSource;
 @Service
 public class TenantDatabaseUpgradeService {
 
+       private final static Logger LOG = 
LoggerFactory.getLogger(TenantDatabaseUpgradeService.class);
+
     private final TenantDetailsService tenantDetailsService;
     protected final DataSource tenantDataSource;
     protected final TenantDataSourcePortFixService 
tenantDataSourcePortFixService;
-    
-    @Autowired private JDBCDriverConfig driverConfig ;
-    
+
+    @Autowired private JDBCDriverConfig driverConfig;
+
     @Autowired
     public TenantDatabaseUpgradeService(final TenantDetailsService 
detailsService,
             @Qualifier("tenantDataSourceJndi") final DataSource dataSource, 
TenantDataSourcePortFixService tenantDataSourcePortFixService) {
@@ -88,15 +92,27 @@ public class TenantDatabaseUpgradeService {
      * itself.
      */
     private void upgradeTenantDB() {
+       String dbHostname = getEnvVar("FINERACT_DEFAULT_TENANTDB_HOSTNAME", 
"localhost");
+       String dbPort = getEnvVar("FINERACT_DEFAULT_TENANTDB_PORT", "3306");
+       LOG.info("upgradeTenantDB: FINERACT_DEFAULT_TENANTDB_HOSTNAME = {}, 
FINERACT_DEFAULT_TENANTDB_PORT = {}", dbHostname, dbPort);
+
         final Flyway flyway = new Flyway();
         flyway.setDataSource(tenantDataSource);
         flyway.setLocations("sql/migrations/list_db");
         flyway.setOutOfOrder(true);
         flyway.setPlaceholders(ImmutableMap.of( // FINERACT-773
-            "fineract_default_tenantdb_hostname", 
System.getProperty("FINERACT_DEFAULT_TENANTDB_HOSTNAME", "localhost"),
-            "fineract_default_tenantdb_port",     
System.getProperty("FINERACT_DEFAULT_TENANTDB_PORT", "3306")));
+            "fineract_default_tenantdb_hostname", dbHostname,
+            "fineract_default_tenantdb_port",     dbPort));
         flyway.migrate();
 
         tenantDataSourcePortFixService.fixUpTenantsSchemaServerPort();
     }
+
+       private String getEnvVar(String name, String defaultValue) {
+               String value = System.getenv(name);
+               if (value == null) {
+                       return defaultValue;
+               }
+               return value;
+       }
 }

Reply via email to