Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .testcontainers.properties.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Testcontainers reuse configuration
# ------------------------------------
# Place this file at: ~/.testcontainers.properties
# (i.e., in your home directory, NOT the project directory)
#
# With reuse enabled, Testcontainers will leave containers running between
# test runs rather than stopping and removing them when the JVM exits.
# On the next run it detects that a matching container already exists and
# connects to it instead of starting a new one.
#
# Effect on local dev:
# - Integration test startup drops from ~15-30 s (container start + Spring init)
# to ~2-3 s (Spring context only) after the first run.
# - MongoDB and ActiveMQ data persists between runs; run a clean start
# (`./gradlew integrationTest --rerun`) when you want a truly fresh state.
#
# This setting has NO effect in CI (containers always start fresh there because
# the host is ephemeral). To explicitly disable reuse in CI, set the env var:
# TESTCONTAINERS_REUSE_ENABLE=false
#
# IMPORTANT: This file must also be created on each developer's machine.
# Commit this template to the repo (e.g., as .testcontainers.properties.template)
# so new developers know to copy it to ~/

testcontainers.reuse.enable=true

3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
* Updated logging configuration to route application logs through async appender settings for improved runtime logging performance.
* The service Docker image now uses JVM percentage-based heap sizing (`-XX:MaxRAMPercentage=75.0`, `-XX:InitialRAMPercentage=50.0`)
* instead of a fixed `-Xmx` value, so the heap adapts automatically when the container memory limit is changed without requiring an image rebuild.
* Enabled G1GC explicitly (`-XX:+UseG1GC`) in the service container entrypoint for consistent garbage collection behaviour across deployments.

## [3.0.0] - 2025-11-06

Expand Down
11 changes: 10 additions & 1 deletion docker/service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,14 @@ COPY --from=package /home/gradle/service/build/libs/gp2gp-fhir-send-adaptor.jar

USER 65534

ENTRYPOINT ["java", "-XX:+PrintCommandLineFlags", "-cp", "/app/gp2gp-fhir-send-adaptor.jar", "-Dloader.main=uk.nhs.adaptors.gp2gp.Gp2gpApplication", "org.springframework.boot.loader.launch.PropertiesLauncher"]
ENTRYPOINT ["java", \
"-XX:MaxRAMPercentage=75.0", \
"-XX:InitialRAMPercentage=50.0", \
"-XX:+UseG1GC", \
"-XX:+PrintCommandLineFlags", \
"-cp", "/app/gp2gp-fhir-send-adaptor.jar", \
"-Dloader.main=uk.nhs.adaptors.gp2gp.Gp2gpApplication", \
"org.springframework.boot.loader.launch.PropertiesLauncher"]



22 changes: 22 additions & 0 deletions nhs-england-developer-information.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@
* JDK 21 — we develop the adaptor in Java with Spring Boot
* Docker — we release the adaptor using Docker images on [Dockerhub](https://hub.docker.com/repository/docker/nhsdev/nia-gp2gp-adaptor)

## One-time local dev setup

### Enable Testcontainers container reuse (saves ~15–30 s per integration test run)

Copy the template to your home directory:

**macOS / Linux:**
```bash
cp .testcontainers.properties.template ~/.testcontainers.properties
```

This keeps MongoDB and ActiveMQ containers alive between runs so subsequent `./gradlew integrationTest`
invocations skip the container start-up overhead.
The property has no effect in CI (ephemeral hosts never have the file).

To verify the setup is correct:

**macOS / Linux:**
```bash
grep 'testcontainers.reuse.enable' ~/.testcontainers.properties
```

## How to operate the adaptor

The following sections describe how to run the adaptor for development and testing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ public final class ActiveMqContainer extends GenericContainer<ActiveMqContainer>
private ActiveMqContainer() {
super("docker-activemq:latest");
addExposedPort(ACTIVEMQ_PORT);
// withReuse(true) keeps the container alive after the JVM exits so the next
// test run can reconnect to it instead of starting a new one (~15 s saving).
// Reuse is only activated when testcontainers.reuse.enable=true in
// ~/.testcontainers.properties (see .testcontainers.properties.template).
// In CI that property is absent so containers always start fresh.
withReuse(true);
}

public static ActiveMqContainer getInstance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ public final class MongoDbContainer extends GenericContainer<MongoDbContainer> {
private MongoDbContainer() {
super(DEFAULT_IMAGE_AND_TAG);
addExposedPort(MONGODB_PORT);
// withReuse(true) keeps the container alive after the JVM exits so the next
// test run can reconnect to it instead of starting a new one (~15 s saving).
// Reuse is only activated when testcontainers.reuse.enable=true in
// ~/.testcontainers.properties (see .testcontainers.properties.template).
// In CI that property is absent so containers always start fresh.
withReuse(true);
}

public static MongoDbContainer getInstance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class S3StorageConnectorTest {
private static S3StorageConnector s3StorageConnector;

@Container
private static final S3MockContainer S3_MOCK = new S3MockContainer("4.7.0");
private static final S3MockContainer S3_MOCK = new S3MockContainer("4.7.0").withReuse(true);

private static S3Client s3Client;

Expand Down
Loading