Skip to content

Commit

Permalink
Merge pull request apache#690 from vorburger/FINERACT-773_fix-docker-…
Browse files Browse the repository at this point in the history
…compose

fix broken docker-compose set up (re. FINERACT-773)
  • Loading branch information
awasum committed Jan 12, 2020
2 parents 89b996c + 4e1d87f commit 7420545
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
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;
Expand All @@ -45,12 +47,14 @@
@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) {
Expand Down Expand Up @@ -88,15 +92,27 @@ public void upgradeAllTenants() {
* 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;
}
}

0 comments on commit 7420545

Please sign in to comment.