Skip to Content
6 days ago

How to connect Hana DB with API tests?

272 Views Last edit 6 days ago 3 rev

Hello colleagues,

I'm developing a multitenancy application in nodeJS and I want to run my integration tests against a real hana database instead of a in-memory (current configuration).

I saw in this blog how to fetch the hana credentials for a specific tenant which I aim to connect to run the tests. Also I'm able to test the connection against the HANA SQL console and I can to query in the DB

.But whenever I set the configuration in the `.cdsrc.json` the application fails with the following error messages:

[hana] - Could not establish connection for tenant "anonymous". Existing pool will be drained.[hana] - Error: Could not establish connection for tenant "anonymous" due to error: Could not connect to any host: [ - unable to get local issuer certificate ]<br>[...]<br>TimeoutError: Acquiring client from pool timed out. Please review your system setup, transaction handling, and pool configuration.

I saw that this tenant issue could be related to my mocked users not having it set properly, so I did the following (without success)

{ "admin": { "password": "xxxxxxx", "tenant": "my-tenant" }}
Regarding the `unable to get local issuer certificate` I tried with both sslValidateCertificate false and true but the issue kept the same

In my `.cdsrc.json` I have the following configuration:

"dbtesthana": {<br>        "kind": "hana",<br>        "schema": "xxxx",<br>        "credentials": {<br>          "host": "xxxx",<br>          "port": 443,<br>          "user": "xxx", <br>          "password": "xxxx",<br>          "initializationTimeout": "60000",<br>          "sslValidateCertificate": false,<br>          "certificate": "-----BEGIN CERTIFICATE-----xxxxxx----END CERTIFICATE-----"<br>        }      <br>}<br>}

Am I missing something?Changing the configuration to `default-env.json` always results in malformated authentication error.

Thanks a ton for your help!

[Edit1]: formatting issues

[Edit 2]: Hana is already configured to accept all incoming requests as described in SAP Hana Cloud Central: