From 1fd65b01744d61f422209638f165ca25eaa92953 Mon Sep 17 00:00:00 2001 From: Ivan Vakhrushev Date: Sat, 30 Sep 2023 10:45:50 +0400 Subject: [PATCH] Added support for PostgreSQL 16 (#288) * Migrated to PostgreSQL 16 as default version * Switched to Bitnami PostgreSQL 16 image * Updated sql queries * Fixed CI --- .github/workflows/tests.yml | 8 ++++---- CONTRIBUTING.md | 2 +- README.md | 6 +++--- .../mfvanek/pg/testing/PostgreSqlContainerWrapper.java | 2 +- .../github/mfvanek/pg/testing/PostgresVersionHolder.java | 6 +++--- .../pg/testing/PostgreSqlContainerWrapperTest.java | 2 +- .../mfvanek/pg/testing/PostgresVersionHolderTest.java | 8 ++++---- pg-index-health/src/main/resources | 2 +- .../io/github/mfvanek/pg/utils/PostgresVersionTest.java | 2 +- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ac872773..05c4fb47 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ jobs: build: strategy: matrix: - pg_version: [ "11.20-alpine", "12.15", "13.11", "14.8", "15.3" ] + pg_version: [ "12.16", "13.12", "14.9", "15.4", "16.0" ] env: TEST_PG_VERSION: ${{ matrix.pg_version }} runs-on: ubuntu-latest @@ -42,16 +42,16 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - name: Build with Gradle and analyze - if: matrix.pg_version == '14.8' + if: matrix.pg_version == '14.9' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: ./gradlew build sonarqube --info - name: Build with Gradle - if: matrix.pg_version != '14.8' + if: matrix.pg_version != '14.9' run: ./gradlew build - name: Upload coverage to Codecov - if: matrix.pg_version == '14.8' + if: matrix.pg_version == '14.9' uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b0c29ae9..0f147089 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,7 +13,7 @@ Java >= 11 is required. This will build the project and run tests. -By default, [PostgreSQL 15.3 from Testcontainers](https://www.testcontainers.org/) is used to run tests. +By default, [PostgreSQL 16.0 from Testcontainers](https://www.testcontainers.org/) is used to run tests. Set `TEST_PG_VERSION` environment variable to use any of other available PostgreSQL version: ``` TEST_PG_VERSION=11.20-alpine diff --git a/README.md b/README.md index 5076f8b3..9cd611e3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # ![pg-index-health](https://github.com/mfvanek/pg-index-health/blob/master/logo.png "pg-index-health") -**pg-index-health** is a Java library for analyzing and maintaining indexes health in [PostgreSQL](https://www.postgresql.org/) databases. +**pg-index-health** is a Java library for analyzing and maintaining indexes and tables health in [PostgreSQL](https://www.postgresql.org/) databases. [![Java CI](https://github.com/mfvanek/pg-index-health/actions/workflows/tests.yml/badge.svg)](https://github.com/mfvanek/pg-index-health/actions/workflows/tests.yml "Java CI") [![Maven Central](https://img.shields.io/maven-central/v/io.github.mfvanek/pg-index-health.svg)](https://search.maven.org/artifact/io.github.mfvanek/pg-index-health/ "Maven Central") @@ -17,14 +17,14 @@ [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=mfvanek_pg-index-health&metric=coverage)](https://sonarcloud.io/summary/new_code?id=mfvanek_pg-index-health) ## Supported PostgreSQL versions -[![PostgreSQL 11](https://img.shields.io/badge/PostgreSQL-11-green.svg)](https://www.postgresql.org/about/news/1894/ "PostgreSQL 11") [![PostgreSQL 12](https://img.shields.io/badge/PostgreSQL-12-green.svg)](https://www.postgresql.org/about/news/1976/ "PostgreSQL 12") [![PostgreSQL 13](https://img.shields.io/badge/PostgreSQL-13-green.svg)](https://www.postgresql.org/about/news/postgresql-13-released-2077/ "PostgreSQL 13") [![PostgreSQL 14](https://img.shields.io/badge/PostgreSQL-14-green.svg)](https://www.postgresql.org/about/news/postgresql-14-released-2318/ "PostgreSQL 14") [![PostgreSQL 15](https://img.shields.io/badge/PostgreSQL-15-green.svg)](https://www.postgresql.org/about/news/postgresql-15-released-2526/ "PostgreSQL 15") +[![PostgreSQL 16](https://img.shields.io/badge/PostgreSQL-16-green.svg)](https://www.postgresql.org/about/news/postgresql-16-released-2715/ "PostgreSQL 16") ### Support for previous versions of PostgreSQL -Compatibility with PostgreSQL versions **9.6** and **10** is no longer guaranteed, but it is very likely. +Compatibility with PostgreSQL versions **9.6**, **10** and **11** is no longer guaranteed, but it is very likely. We focus only on the currently maintained versions of PostgreSQL. For more information please see [PostgreSQL Versioning Policy](https://www.postgresql.org/support/versioning/). diff --git a/pg-index-health-testing/src/main/java/io/github/mfvanek/pg/testing/PostgreSqlContainerWrapper.java b/pg-index-health-testing/src/main/java/io/github/mfvanek/pg/testing/PostgreSqlContainerWrapper.java index edf48962..bcf6f334 100644 --- a/pg-index-health-testing/src/main/java/io/github/mfvanek/pg/testing/PostgreSqlContainerWrapper.java +++ b/pg-index-health-testing/src/main/java/io/github/mfvanek/pg/testing/PostgreSqlContainerWrapper.java @@ -128,7 +128,7 @@ public boolean isOutParametersInProcedureSupported() { /** * Creates {@code PostgreSqlContainerWrapper} with default PostgreSQL version. * The default version is taken from the environment variable {@code TEST_PG_VERSION} if it is set, - * otherwise the default version {@code 15.3} is used. + * otherwise the default version {@code 16.0} is used. * * @return {@code PostgreSqlContainerWrapper} */ diff --git a/pg-index-health-testing/src/main/java/io/github/mfvanek/pg/testing/PostgresVersionHolder.java b/pg-index-health-testing/src/main/java/io/github/mfvanek/pg/testing/PostgresVersionHolder.java index 3a150e87..50e94fa7 100644 --- a/pg-index-health-testing/src/main/java/io/github/mfvanek/pg/testing/PostgresVersionHolder.java +++ b/pg-index-health-testing/src/main/java/io/github/mfvanek/pg/testing/PostgresVersionHolder.java @@ -76,7 +76,7 @@ private static String preparePostgresVersion() { if (pgVersion != null) { return pgVersion; } - return "15.3"; + return "16.0"; } @Nonnull @@ -90,7 +90,7 @@ static String toBitnamiVersion(@Nonnull final String pgVersion) { /** * Creates {@code PostgresVersionHolder} for Bitnami cluster installation. * The version is taken from the environment variable {@code TEST_PG_VERSION} if it is set, - * otherwise the default version {@code 15.3.0} is used. + * otherwise the default version {@code 15.4.0} is used. * * @return {@code PostgresVersionHolder} */ @@ -114,7 +114,7 @@ static PostgresVersionHolder forCluster(@Nonnull final String pgVersion) { /** * Creates {@code PostgresVersionHolder} for single node installation. * The version is taken from the environment variable {@code TEST_PG_VERSION} if it is set, - * otherwise the default version {@code 15.3} is used. + * otherwise the default version {@code 16.0} is used. * * @return {@code PostgresVersionHolder} */ diff --git a/pg-index-health-testing/src/test/java/io/github/mfvanek/pg/testing/PostgreSqlContainerWrapperTest.java b/pg-index-health-testing/src/test/java/io/github/mfvanek/pg/testing/PostgreSqlContainerWrapperTest.java index f1ab3f65..5e281342 100644 --- a/pg-index-health-testing/src/test/java/io/github/mfvanek/pg/testing/PostgreSqlContainerWrapperTest.java +++ b/pg-index-health-testing/src/test/java/io/github/mfvanek/pg/testing/PostgreSqlContainerWrapperTest.java @@ -41,7 +41,7 @@ void withDefaultVersionShouldWork() { @Test void withVersionShouldWork() { - try (PostgreSqlContainerWrapper container = PostgreSqlContainerWrapper.withVersion("15.3")) { + try (PostgreSqlContainerWrapper container = PostgreSqlContainerWrapper.withVersion("16.0")) { assertThat(container) .isNotNull() .satisfies(c -> { diff --git a/pg-index-health-testing/src/test/java/io/github/mfvanek/pg/testing/PostgresVersionHolderTest.java b/pg-index-health-testing/src/test/java/io/github/mfvanek/pg/testing/PostgresVersionHolderTest.java index 35c6296b..4e52bc9f 100644 --- a/pg-index-health-testing/src/test/java/io/github/mfvanek/pg/testing/PostgresVersionHolderTest.java +++ b/pg-index-health-testing/src/test/java/io/github/mfvanek/pg/testing/PostgresVersionHolderTest.java @@ -80,7 +80,7 @@ void forClusterShouldBeBitnamiAware() { .isEqualTo(System.getenv("TEST_PG_VERSION").split("-")[0] + ".0"); } else { assertThat(versionHolder.getVersion()) - .isEqualTo("15.3.0"); + .isEqualTo("16.0.0"); } } @@ -110,7 +110,7 @@ void forSingleNodeShouldBeEnvAware() { .isEqualTo(System.getenv("TEST_PG_VERSION")); } else { assertThat(versionHolder.getVersion()) - .isEqualTo("15.3"); + .isEqualTo("16.0"); } } @@ -125,8 +125,8 @@ void forSingleNodeShouldBeAbleToForceVersion() { @Test void toBitnamiVersionShouldSkipSuffix() { - assertThat(PostgresVersionHolder.toBitnamiVersion("15.3")) - .isEqualTo("15.3.0"); + assertThat(PostgresVersionHolder.toBitnamiVersion("15.4")) + .isEqualTo("15.4.0"); assertThat(PostgresVersionHolder.toBitnamiVersion("14.5-alpine3.17")) .isEqualTo("14.5.0"); } diff --git a/pg-index-health/src/main/resources b/pg-index-health/src/main/resources index 13b5c071..8aeeb733 160000 --- a/pg-index-health/src/main/resources +++ b/pg-index-health/src/main/resources @@ -1 +1 @@ -Subproject commit 13b5c071f076f6aaab1ea95ebbd4c3749b194ae6 +Subproject commit 8aeeb733f946f7067e67459adaf4298f4209d2a9 diff --git a/pg-index-health/src/test/java/io/github/mfvanek/pg/utils/PostgresVersionTest.java b/pg-index-health/src/test/java/io/github/mfvanek/pg/utils/PostgresVersionTest.java index 7e3f87cd..1a97fcfd 100644 --- a/pg-index-health/src/test/java/io/github/mfvanek/pg/utils/PostgresVersionTest.java +++ b/pg-index-health/src/test/java/io/github/mfvanek/pg/utils/PostgresVersionTest.java @@ -25,7 +25,7 @@ final class PostgresVersionTest extends DatabaseAwareTestBase { @Test void checkPgVersion() { final String pgVersionFromEnv = System.getenv(PG_VERSION_ENVIRONMENT_VARIABLE); - final String requiredPgVersionString = (pgVersionFromEnv == null) ? "15.3 (Debian 15.3-" : pgVersionFromEnv.split("-")[0]; + final String requiredPgVersionString = (pgVersionFromEnv == null) ? "16.0 (Debian 16.0-" : pgVersionFromEnv.split("-")[0]; final String actualPgVersionString = PostgresVersionReader.readVersion(getDataSource()); assertThat(actualPgVersionString) .startsWith(requiredPgVersionString);