Commit Graph

194 Commits

Author SHA1 Message Date
Scott Frederick 533f6c3bb1 Refactor TestcontainersPropertySource to use MapPropertySource
Closes gh-39330
2024-02-09 10:23:55 -06:00
Scott Frederick 8c91b094ee Merge branch '3.2.x'
Closes gh-39450
2024-02-07 16:49:49 -06:00
Scott Frederick 6b453cedf6 Merge branch '3.1.x' into 3.2.x
Closes gh-39449
2024-02-07 16:49:29 -06:00
Amrit 67ba829d9e Fix typo in TestcontainersPropertySource assertion
See gh-39440
2024-02-07 16:45:39 -06:00
Eddú Meléndez f3e7325064 Add service connection for Docker Compose and Testcontainers ActiveMQ
See gh-39363
2024-02-02 09:05:37 +01:00
Eddú Meléndez f15cd93a35 Add service connection for Docker Compose and Testcontainers Artemis
See gh-39311
2024-01-31 08:37:03 +01:00
Andy Wilkinson f4cd903410 Merge branch '3.2.x'
Closes gh-39346
2024-01-30 16:48:43 +00:00
Andy Wilkinson 61ca87f7a4 Polish "Prevent double registration of event publisher registrar"
See gh-39297
2024-01-30 16:02:38 +00:00
tish 50c44e301a Prevent double registration of event publisher registrar
See gh-39297
2024-01-30 15:59:05 +00:00
Scott Frederick bee6fe899c Polish "Add Docker Compose service connection support for OpenLDAP"
See gh-39258
2024-01-22 16:51:45 -06:00
PhilKes eb940c3907 Add Docker Compose service connection support for OpenLDAP
See gh-39258
2024-01-22 16:51:45 -06:00
Phillip Webb cff8cb98c7 Merge branch '3.1.x' into 3.2.x 2024-01-22 12:20:24 -08:00
Phillip Webb 88a8550609 Make OTEL tstcontainers integration test more resilient
Tweak awaitility assertions to fix timing error that often occurs on
local builds.
2024-01-16 10:49:25 -08:00
Phillip Webb 89874d351a Ensure containers are started before binding datasource properties
Update `TestcontainersLifecycleBeanPostProcessor` so that containers
are now initialized either on the first `postProcessAfterInitialization`
call with a frozen configuration or just before a test container
property is supplied.

Prior to this commit, it was assumed that the first post-process call
after the configuration was frozen was suitably early to initialize
the containers. This turns out to not be no always the case.

Specifically, in the `finishBeanFactoryInitialization` method of
`AbstractApplicationContext` we see that `LoadTimeWeaverAware` beans
are obtained before the configuration is frozen. One such bean is
`DefaultPersistenceUnitManager` which is likely to need datasource
properties that will require a started container.

To fix the problem, the `TestcontainersPropertySource` now publishes
a `BeforeTestcontainersPropertySuppliedEvent` to the ApplicationContext
just before any value is supplied. By listening for this event, we can
ensure that containers are initialized and started before any dynamic
property is read.

Fixes gh-38913
2024-01-16 10:36:54 -08:00
Andy Wilkinson 7087897507 Merge branch '3.1.x' into 3.2.x
Closes gh-39091
2024-01-11 10:33:57 +00:00
Phillip Webb 5354ad15b3 Merge branch '3.1.x'
Closes gh-38877
2023-12-19 22:51:48 -08:00
Yanming Zhou d3a51e56b7 Remove unnecessary `static` modifiers
See gh-38739
2023-12-19 22:38:08 -08:00
Phillip Webb 561c7f749b Don't start containers imported via @ImportTestcontainers
Remove early start of containers imported via `@ImportTestcontainers`
so that parallel startup can happen.

Fixes gh-38831
2023-12-17 15:22:28 -08:00
Phillip Webb 6ae113c18a Fix parallel startup of testcontainers
Update `TestcontainersLifecycleBeanPostProcessor` so that containers
can actually be started in parallel.

Prior to this commit, `initializeStartables` would collect beans
and in the process trigger the `postProcessAfterInitialization` method
on each bean. This would see that  `startablesInitialized` was `true`
and call `startableBean.start` directly. The result of this was that
beans were actually started sequentially and when the `start` method
was finally called it had nothing to do.

The updated code uses an enum rather than a boolean so that the
`postProcessAfterInitialization` method no longer attempts to start
beans unless `initializeStartables` has finished.

Fixes gh-38831
2023-12-16 21:57:16 -08:00
Phillip Webb 6c3dec42e0 Add container support for Oracle Free which replaces Oracle XE
Update Docker Compose and Testcontainers support to work with
`gvenzl/oracle-free` which replaces `gvenzl/oracle-xe`.

Closes gh-38476
2023-11-21 11:51:59 -08:00
Phillip Webb 3a32e4e913 Merge branch '3.1.x'
Closes gh-38405
2023-11-20 16:27:46 -08:00
Phillip Webb f68df82b30 Support lenient ContainerConnectionDetailsFactory hint registration
Update `ContainerConnectionDetailsFactory` hint registration logic
so that types are optional on the classpath.

See gh-36606
Fixes gh-38392
2023-11-20 16:26:22 -08:00
Phillip Webb 663243e60c Fix open telemetry container lifecycle issues
Mark test as `@DirtiesContext` so that the context is closed before
the container.

Closes gh-38176
2023-11-01 18:16:38 -07:00
Phillip Webb 0c66db7b18 Refine container initialization and parallel startup logic
Update `TestcontainersLifecycleBeanPostProcessor` to restore early
container initialization logic and refine startup logic. Initial bean
access now again triggers the creation all container beans. In addition
the first access of a `Startable` bean now attempts to find and start
all other `Startable` beans.

Fixes gh-37989
2023-10-25 11:58:22 -07:00
Moritz Halbritter ddf6b3f23b Merge branch '3.1.x'
Closes gh-38014
2023-10-25 10:26:02 +02:00
Moritz Halbritter 73685d1d02 Register required class names for reflection in Testcontainer factory
Closes gh-36606
2023-10-25 10:25:42 +02:00
Phillip Webb 343046d30c Polish 2023-10-19 10:55:26 +01:00
Phillip Webb fcb75b6a1e Search implemented interfaces on superclass for @ServiceConnection
Refine original fix to also search interfaces on the superclass.

Fixes gh-37671
2023-10-19 10:52:19 +01:00
Moritz Halbritter 55dc2963ef Rename Testcontainers bean startup property
Old name: spring.testcontainers.startup
New name: spring.testcontainers.beans.startup

Closes gh-37073
2023-10-19 09:22:27 +02:00
Phillip Webb 4c3a0f09d7 Support parallel initialization of Testcontainers
Add support for a `spring.testcontainers.startup` property that can
be set to "sequential" or "parallel" to change how containers are
started.

Closes gh-37073
2023-10-14 23:58:25 -07:00
Phillip Webb efd9aa9b64 Polish 2023-10-14 19:51:42 -07:00
Phillip Webb e01e4f1912 Search implemented interfaces on superclass for @ServiceConnection
Refine original fix to also search interfaces on the superclass.

Fixes gh-37671
2023-10-14 19:43:41 -07:00
Johnny Lim 446677375e Polish gh-35082
See gh-37831
2023-10-12 14:17:02 +02:00
Scott Frederick bd6606fa39 Merge branch '3.1.x'
Closes gh-37799
2023-10-09 15:42:32 -05:00
Scott Frederick 86216fb4e9 Search implemented interfaces for @ServiceConnection fields
Fixes gh-37671
2023-10-09 15:37:42 -05:00
Phillip Webb 052757c2d8 Polish 2023-09-27 20:58:09 -07:00
Moritz Halbritter 3dd6372602 Polish "Add service connection from OpenTelemetry Collector"
See gh-35082
2023-09-14 11:10:19 +02:00
Moritz Halbritter c387c87fda Polish "Add service connection from OpenTelemetry Collector"
See gh-35082
2023-09-14 10:50:36 +02:00
Eddú Meléndez 6997277f75 Add service connection from OpenTelemetry Collector
See gh-35082
2023-09-14 09:44:20 +02:00
Phillip Webb 750c597225 Polish 'Add Pulsar ConnectionDetails support'
See gh-37197
2023-09-06 12:18:09 -07:00
Chris Bono 089fef0392 Add Pulsar ConnectionDetails support
Add `ConnectionDetails` support for Apache Pulsar and provide adapters
for Docker Compose and Testcontainers.

See gh-37197
2023-09-06 12:12:25 -07:00
Moritz Halbritter 313627934e Merge branch '3.1.x'
Closes gh-37194
2023-09-05 13:41:38 +02:00
Moritz Halbritter d310fb6fce Prevent docker access when running AOT processing on tests
Closes gh-37097
2023-09-05 13:37:36 +02:00
Moritz Halbritter 1a2919bb0e Polish 2023-09-05 13:37:36 +02:00
Stephane Nicoll 311fa6272d Polish "Add service connection for Testcontainers ActiveMQ"
This also adds support for Docker Compose.

See gh-35080
2023-07-20 13:03:41 +02:00
Eddú Meléndez 63121dd08a Add service connection for Testcontainers ActiveMQ
See gh-35080
2023-07-20 13:03:41 +02:00
Christoph Dreis 8321887d6a Fix typos
See gh-36306
2023-07-17 09:40:16 +02:00
Johnny Lim 06157837e5
Polish
See gh-35872
2023-06-16 12:39:03 -07:00
Moritz Halbritter ebbb4d319d Polish 2023-06-07 10:53:03 +02:00
Andy Wilkinson bd2fff1fd1 Fix `@ServiceConnection` in native tests
Using `@ServiceConnection` results in the definition of one or more
connection details beans. These bean definitions use an instance
supplier which is not supported by AOT. This results in a failure during
AOT processing.

This commit introduces a BeanRegistrationExcludeFilter to exclude from
AOT processing the beans created from a `@ServiceConnection`. They are
not needed as the registrar will run again in the native image and
define the beans at which point the use of an instance supplier is
supported again.

Fixes gh-35663
2023-06-06 12:05:00 +01:00
kitbolourchi 1ac6e9ebe1 Upgrade Kafka image used in integration tests
See gh-35625
2023-05-24 16:12:08 -05:00
Moritz Halbritter ad108952c8 Fix JavaDoc in ServiceConnection
Closes gh-35594
2023-05-23 09:10:51 +02:00
Stephane Nicoll 7a9bb55fdf Merge branch '3.0.x'
Closes gh-35589
2023-05-22 16:24:56 +02:00
Moritz Halbritter 441ed30ee4 Polish "Replace Mockito argument captors with assertArg"
Co-authored-by: Andy Wilkinson <wilkinsona@vmware.com>

See gh-35015
2023-05-05 15:41:31 +02:00
Phillip Webb 56af1569d3 Refine @ImportTestcontainers support
Refine logic so that bean names are no longer generated based on their
type and containers are started early.

See gh-35245
2023-05-04 15:40:12 -07:00
Andy Wilkinson c78cc4408a Disable more s-b-testcontainers tests when Docker is unavailable
See gh-35245
2023-05-04 16:58:46 +01:00
Andy Wilkinson 10fd7517a8 Disable ImportTestcontainersTests when Docker is unavailable
See gh-35245
2023-05-04 15:40:27 +01:00
Moritz Halbritter 9b5a2643cc Polish "Add service connection from Testcontainers Zipkin"
See gh-35107
2023-05-03 13:09:50 +02:00
Eddú Meléndez ad4f6ffeb7 Add service connection from Testcontainers Zipkin
See gh-35107
2023-05-03 13:09:49 +02:00
Phillip Webb 8427e813af Support import of idomatic testcontainer declaration classes
Add an `@ImportTestcontainers` annotation which can be used to import
idomatic testcontainer declaration classes.

Closes gh-35245
2023-05-03 00:28:36 -07:00
Phillip Webb 26566d4a30 Allow testcontainer beans to also contribute properties
Allow `Container` bean definitions to inject a `DynamicPropertyRegistry`
so that they can contribute environment properties.

Closes gh-35201
2023-05-03 00:27:13 -07:00
Phillip Webb e9578fe745 Swallow BeanCurrentlyInCreationException exceptions
Update `TestcontainersLifecycleBeanPostProcessor` to that initialization
doesn't fail if a `BeanCurrentlyInCreationException` is thrown.

Prior to this commit, if the first bean being post-processed was a
configuration class declaring a bean that the `Container` depended on
all initialization would fail.

See gh-35223
2023-05-03 00:24:30 -07:00
Phillip Webb 3997771f6c Polish 2023-05-02 23:40:30 -07:00
Moritz Halbritter 2586150eaf Disable ARM incompatible integration tests 2023-05-02 14:59:49 +02:00
Andy Wilkinson b1d0433d74 Handle Kafka servers as strings and rely on Kafka's parsing
Closes gh-34770
2023-05-02 08:38:40 +01:00
Phillip Webb dc4efaf276 Initialize containers first and destroy them last
Update `TestcontainersLifecycleBeanPostProcessor` so that on
initialization of the first bean all `Container` instances are started.

With this update all `Container` beans will be started first in the
`preInstantiateSingletons` phase and destroyed last.

Closes gh-35223
2023-05-01 23:59:22 -07:00
Phillip Webb 14bc354f7f Apply initializer automatically for context tests
Update `ServiceConnectionContextCustomizer` so that is applies the
`TestcontainersLifecycleApplicationContextInitializer` to all
application contexts.

Closes gh-35222
2023-05-01 23:59:22 -07:00
Phillip Webb 632c5d7ea5 Implement ServiceConnectionContextCustomizer equals and hashcode for key
Update `ServiceConnectionContextCustomizer` with `equals` and `hashcode`
methods so that it works correctly when part of a context cache key.

Closes gh-35216
2023-05-01 23:59:22 -07:00
Phillip Webb 25e3291d86 Broaden exceptions that include ServiceConnection name hint
See gh-35168
2023-05-01 22:13:50 -07:00
Phillip Webb b4cd2572d5 Prevent early initialization of Container beans
Update testcontainers auto-configuration so that `Container` bean
instances are no longer needed when registering `ConnectionDetails`
beans. Registration now occurs based on the bean type and the `name`
attribute of `@ServiceConnection`.

Fixes gh-35168
2023-05-01 00:21:47 -07:00
Phillip Webb c21cf31853 Switch order of ContainerConnectionDetailsFactory generics
Switch `ContainerConnectionDetailsFactory` so that `Container`
is before `ConnectionDetails`.
2023-05-01 00:00:43 -07:00
Phillip Webb fc5339f81c Polish 2023-04-30 23:27:06 -07:00
Phillip Webb c13041201d Don't call close methods for reusable testcontainers
Refine `TestcontainersLifecycleApplicationContextInitializer` so that
the `close()` method is not called for reusable containers.

Closes gh-35210
2023-04-30 06:07:05 -07:00
Phillip Webb e7357ba805 Increase timeout in OracleR2dbcContainerConnectionDetailsFactoryTests 2023-04-29 21:10:19 -07:00
Phillip Webb d1084ee6db Refactor ContainerConnectionDetailsFactory classes
Update `ContainerConnectionDetailsFactory` so that they consistently
extend `ContainerConnectionDetails`. The container is also no longer
accessible from the `ContainerConnectionSource` and is never used
during the construction of `ConnectionDetails` instances.

See gh-35168
2023-04-29 21:10:14 -07:00
Phillip Webb 403481ff96 Add 'required' parameter to ConnectionDetailsFactories
Update `ConnectionDetailsFactories` so that callers can now declare if
a result is required or not and improve exception hierarchy.

See gh-35168
2023-04-29 21:10:07 -07:00
Andy Wilkinson cec159110d Do not block indefinitely when querying SQL database 2023-04-28 09:52:27 +01:00
Andy Wilkinson d7da77bda8 Remove support for service connections to InfluxDB
Closes gh-35189
2023-04-28 09:49:39 +01:00
Andy Wilkinson 5e73047164 Align SQL Server-related class names with existing precedents
Closes gh-35181
2023-04-27 10:33:25 +01:00
Yanming Zhou b615aef810 Fix dependency management for spring-boot-testcontainers
This commit adds org.testcontainers:testcontainers as an api dependency
of spring-boot-testcontainers so that GenericContainer can be used
without an additional dependency

See gh-35119
2023-04-25 10:04:52 +02:00
Stephane Nicoll facf48e423 Polish "Prevent container to be closed twice"
See gh-35120
2023-04-25 09:59:52 +02:00
Yanming Zhou 5df6913f18 Prevent container to be closed twice
See gh-35120
2023-04-25 09:59:52 +02:00
Andy Wilkinson e61adc6cbf Allow even more time for Redpanda to start 2023-04-20 17:41:40 +01:00
Andy Wilkinson 5ec03d2b34 Wait longer for Redpanda to start 2023-04-18 21:43:25 +01:00
Andy Wilkinson 0da209db08 Polish "Add support for Oracle R2DBC Service Connection"
See gh-34852
2023-04-18 13:47:46 +01:00
Eddu Melendez 6d893b2fe2 Add support for Oracle R2DBC Service Connection
See gh-34852
2023-04-18 12:53:05 +01:00
Eddu Melendez f4bcf99d30 Add service connection from Testcontainers Redpanda
Redpanda (https://redpanda.com/) is Kafka-compatible and
Testcontainers provides a module. This commit adds support for
creating KafkaConnectionDetails from a
@ServiceConnection-annotated RedpandaContainer.

See gh-34780
2023-04-18 12:49:25 +01:00
Andy Wilkinson 7b3e3deb58 Remove unused generic from ContainerConnectionSource
See gh-35017
2023-04-17 17:11:08 +01:00
Stephane Nicoll 7cf28680c9 Polish 2023-04-17 14:28:35 +02:00
Stephane Nicoll 95f07484a8 Add missing check on Docker availability 2023-04-17 14:28:11 +02:00
Phillip Webb 5ac48f5f15 Add testcontainers service connection auto-configuration
Add auto-configuration for `Container` beans that are also
annotated with `@ServiceConnection`. This commit allow
testcontainers to be used at development time and a new section
has been added to the documentation to describe the feature.

Closes gh-35022
2023-04-17 00:49:43 -07:00
Phillip Webb 3b92173a66 Add Testcontainer bean lifecycle support
Add `TestcontainersLifecycleApplicationContextInitializer` and
`TestcontainersLifecycleBeanPostProcessor` to take care of starting and
stopping `Container` beans.

Closes gh-35021
2023-04-17 00:48:20 -07:00
Phillip Webb 81a972af8d Refactor testcontainers service connections
Update restcontainers service connections support so that
technology specific `@ServiceConnector` annotations are not longer
required.

A single `@ServiceConnector` annotation can now be used to create
all `ConnectionDetail` beans.

Closes gh-35017
2023-04-17 00:45:39 -07:00
Phillip Webb 11dac5b5b7 Create dedicated spring-boot-testcontainers module
Create a dedicated testcontainers module containing the service
connectors code.

Closes gh-34757
2023-04-17 00:42:31 -07:00