jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.54k stars 4.02k forks source link

Failing Integration tests in reactive application with MSSQL Server database #19337

Closed aneri90 closed 2 years ago

aneri90 commented 2 years ago
Overview of the issue

All integration tests in a generated reactive application that uses MSSql Server are failing.

Failed to obtain R2DBC Connection; nested exception is java.net.UnknownHostException: Failed to resolve 'localhost:50494;encrypt=false'
Motivation for or Use Case

Restore integration tests in reactive application that uses MSSqlServer

Reproduce the error
  1. Generate a gateway type application with MS SQL Server as dev/prod database (or with attacched .yo-rc)
  2. Start integration tests: ./mvnw verify
Related issues

Related to #19327

Suggest a Fix

The main reason causing this issue is in class TestContainersSpringContextCustomizerFactory.createContextCustomizer() where we build spring.r2dbc.url from the result of devTestContainer.getTestContainer().getJdbcUrl()

In testcontainer-mssql that jdbc connection url now include the parameter that disable the SSL encryption: ";encrypt=false" (source).

That change breaks mssql R2DBC url for 2 reasons:

  1. r2dbc mssql url does not support ";" separeted parameters
  2. jdbc "encrypt" parameter is replaced by a parameter called "ssl" in r2dbc

Given that for MSSQL R2DBC it is not necessary to turn off SSL encryption (for now), I would suggest to manually remove that param with this statament: devTestContainer.getTestContainer().getJdbcUrl().replace(";encrypt=false", "")

JHipster Version(s)
app@0.0.0 /home/jhipster/app
ā””ā”€ā”€ generator-jhipster@7.9.2
JHipster configuration
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "gateway",
    "authenticationType": "jwt",
    "baseName": "app",
    "blueprints": [],
    "buildTool": "maven",
    "cacheProvider": "no",
    "clientFramework": "no",
    "clientPackageManager": "npm",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "creationTimestamp": 1659624406408,
    "databaseType": "sql",
    "devDatabaseType": "mssql",
    "dtoSuffix": "DTO",
    "enableGradleEnterprise": false,
    "enableHibernateCache": false,
    "enableSwaggerCodegen": false,
    "enableTranslation": false,
    "entitySuffix": "",
    "jhiPrefix": "jhi",
    "jhipsterVersion": "7.9.2",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "languages": ["en", "fr"],
    "messageBroker": false,
    "microfrontend": false,
    "microfrontends": [],
    "nativeLanguage": "en",
    "otherModules": [],
    "packageName": "com.mycompany.myapp",
    "pages": [],
    "prodDatabaseType": "mssql",
    "reactive": true,
    "searchEngine": false,
    "serverPort": "8080",
    "serverSideOptions": [],
    "serviceDiscoveryType": "no",
    "skipCheckLengthOfIdentifier": false,
    "skipClient": true,
    "skipFakeData": false,
    "skipUserManagement": false,
    "testFrameworks": [],
    "websocket": false,
    "withAdminUi": true
  }
}

Environment and Tools

openjdk version "11.0.16" 2022-07-19 OpenJDK Runtime Environment Temurin-11.0.16+8 (build 11.0.16+8) OpenJDK 64-Bit Server VM Temurin-11.0.16+8 (build 11.0.16+8, mixed mode)

git version 2.25.1

node: v16.16.0

npm: 7.24.2

Browsers and Operating System
aneri90 commented 2 years ago

Solving the r2dc url issue brings to light another problem with a blocking call detected by BlockHound inside mssql reactive client.

I can work on this issues and provide a PR by the end of this weekend.