From 8523b0d460685463fa114558b90431cbdd17d885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Andr=C3=A9n?= Date: Fri, 23 Feb 2024 17:40:50 +0100 Subject: [PATCH] Test coverage for H2, H2-in-file and Postgres added, rudimentary doc page --- .github/workflows/native-image-tests.yml | 20 ++++++++++++++++++- docs/src/main/paradox/index.md | 1 + docs/src/main/paradox/native-image.md | 11 ++++++++++ .../main/resources/application-h2-file.conf | 9 +++++++++ .../main/resources/application-postgres.conf | 5 +++++ 5 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 docs/src/main/paradox/native-image.md create mode 100644 native-image-tests/src/main/resources/application-h2-file.conf create mode 100644 native-image-tests/src/main/resources/application-postgres.conf diff --git a/.github/workflows/native-image-tests.yml b/.github/workflows/native-image-tests.yml index bf1588cb..c9f22b75 100644 --- a/.github/workflows/native-image-tests.yml +++ b/.github/workflows/native-image-tests.yml @@ -51,9 +51,27 @@ jobs: run: |- cd native-image-tests/ sbt nativeImage -Dakka.r2dbc.version=`cat ~/.version` - # run the binary + + - name: Akka Persistence native image H2 inmem + run: |- + cd native-image-tests/ target/native-image/native-image-tests + - name: Akka Persistence native image H2 file + run: |- + cd native-image-tests/ + target/native-image/native-image-tests -Dconfig.resource=application-h2-file.conf + + - name: Start Postgres DB + run: |- + docker compose -f docker/docker-compose-postgres.yml up --wait + docker exec -i postgres-db psql -U postgres -t < ddl-scripts/create_tables_postgres.sql + + - name: Akka Persistence native image H2 + run: |- + cd native-image-tests/ + target/native-image/native-image-tests -Dconfig.resource=application-postgres.conf + - name: Email on failure if: ${{ failure() }} uses: dawidd6/action-send-mail@6063705cefe50cb915fc53bb06d4049cae2953b2 diff --git a/docs/src/main/paradox/index.md b/docs/src/main/paradox/index.md index 76aa2128..a5f52b1c 100644 --- a/docs/src/main/paradox/index.md +++ b/docs/src/main/paradox/index.md @@ -19,6 +19,7 @@ The Akka Persistence R2DBC plugin allows for using SQL database with R2DBC as a * [Cleanup tool](cleanup.md) * [Migration tool](migration.md) * [Migration Guide](migration-guide.md) +* [Native Image](native-image.md) * [Contributing](contributing.md) @@@ diff --git a/docs/src/main/paradox/native-image.md b/docs/src/main/paradox/native-image.md new file mode 100644 index 00000000..b5ea31e6 --- /dev/null +++ b/docs/src/main/paradox/native-image.md @@ -0,0 +1,11 @@ +# Building Native Images + +Building native images with Akka HTTP is supported out of the box for the event sourced journal, snapshot store and +durable state store and databases: + +* H2 (inmem and file) +* Postgres + +Other databases can likely be used but will require figuring out and adding additional native-image metadata. + +For details about building native images with Akka in general, see the @extref[Akka Documentation](akka:additional/native-image.html). \ No newline at end of file diff --git a/native-image-tests/src/main/resources/application-h2-file.conf b/native-image-tests/src/main/resources/application-h2-file.conf new file mode 100644 index 00000000..3d7bd0c8 --- /dev/null +++ b/native-image-tests/src/main/resources/application-h2-file.conf @@ -0,0 +1,9 @@ +akka.persistence.journal.plugin = "akka.persistence.r2dbc.journal" +akka.persistence.snapshot-store.plugin = "akka.persistence.r2dbc.snapshot" +akka.persistence.state.plugin = "akka.persistence.r2dbc.state" + +akka.persistence.r2dbc.connection-factory = ${akka.persistence.r2dbc.h2} +akka.persistence.r2dbc.connection-factory = { + protocol = "file" + database = "/tmp/test-h2-database" +} \ No newline at end of file diff --git a/native-image-tests/src/main/resources/application-postgres.conf b/native-image-tests/src/main/resources/application-postgres.conf new file mode 100644 index 00000000..9987ed55 --- /dev/null +++ b/native-image-tests/src/main/resources/application-postgres.conf @@ -0,0 +1,5 @@ +akka.persistence.journal.plugin = "akka.persistence.r2dbc.journal" +akka.persistence.snapshot-store.plugin = "akka.persistence.r2dbc.snapshot" +akka.persistence.state.plugin = "akka.persistence.r2dbc.state" + +akka.persistence.r2dbc.connection-factory = ${akka.persistence.r2dbc.postgres} \ No newline at end of file