New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include Testcontainers in the main generator #11544
Comments
I'm not totally in favor of using testcontainer for SQL database integration tests, as I see some issues:
Currently, we use testcontainer for Kafka, Redis, Cassandra because we don't have any other choice, if I remember well. So let's discuss. I'm waiting other opinions. |
I have a completely different experience from you Pascal, I started to work from home 2 weeks ago on a Windows PC and I'm glad we chose testcontainers for postgresql. Due to this, our tests benefit from specific features like JSONB columns and enum type. It would have been impossible with H2. |
Could you please provide more info on this one? There are no known issues with running testcontainers inside a container. Even more - we run in-container scenario as part of our CI and would not be able to do a release if it does not pass :)
Testcontainers does not create any networks by default. Are we talking about the same project? :D |
@bsideup : thanks for answering here About CI/CD:
About Docker Network: Here my Docker Network before launching my integration tests which use testcontainers:
Then, I launch the integration tests, see my Docker Network:
Once the build is finished, the Network is deleted:
But for my customer, I need to use a VPN.
So for my project, when I launch integration tests:
The problem here comes from:
So no worry, no issue directly from testcontainers @bsideup :-) |
Thanks for your detailed answer!
That's one way of doing it, yes. You may also consider the "Docker wormhole" pattern which is much easier (and faster!):
We usually say "Testcontainers works everywhere, as long as you have a Docker daemon running and accessible from your environment" (aka "if docker cli works, then Testcontainers should work too")
Ah, okay, yes, some modules use networks. FYI Kafka does create a network by default (for backward compatibility) but does not require it - you can use JDBC modules (like PostgreSQL, MySQL and others) do not create any network by default. Also, the Couchbase module is being reworked, will remove the need for Socat and will be much more stable: |
If I understand well, Testcontainers is used only if the profile is set. So since the user has the choice to use Testcontainers or not, I'm all for integrating this. |
I also agree, if user have possibility to choose is ok for me too. |
@bsideup : thanks for your suggestion, it works well ! just submitted #11547 :) After reading closely this ticket, I change my mind and agree with your proposal, @ecostanzi : it won't have any impact for our users as it's just a new profile. And be sure, I'll use it for my projects ! |
A little late to the discussion, but I can only support having testcontainers also for sql. We have started similar with wanting to test psql json support and testcontainers helped us e.g. to test existing apis before doing any changes to the database. When it comes to ci we have used dedicated jenkins runner for that and gitlab ci with dind and both work very well. So 👍 to integrate testcontainers for sql too! |
Good thank you all, I'll start working on this soon. |
I'm adding a bounty on this, although the job is done, because it was a lot of work, and a very great feature for our next release. plz claim it @ecostanzi |
bounty claimed: https://opencollective.com/generator-jhipster/expenses/17667/ thank you very much @pascalgrimaud ! |
Overview of the feature request
I just released a new version of this module: https://github.com/intesys/generator-jhipster-testcontainers. It allows to run integration tests on sql databases with testcontainers. It's very simple (it basically adds a properties file in test resources) and it doesn't impact the existing code. A user can keep running integration tests on H2 or switching to testcontainers simply add the
testcontainers
profile when running tests.What about including this in the main generator?
Motivation for or Use Case
We've been using testcontainers for a while and I think it is really helpful. Jhipster already uses this library to run test with other databases. Adding this also for sql database would be a plus for developers.
Related issues or PR
#10958
The text was updated successfully, but these errors were encountered: