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
2 changes: 1 addition & 1 deletion common-internal-bom/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies {
api(platform("org.assertj:assertj-bom:3.26.3"))
api(platform("org.testcontainers:testcontainers-bom:1.20.3"))
api(platform("org.junit:junit-bom:5.11.3"))
api(platform("io.github.mfvanek:pg-index-health-bom:0.13.1"))
api(platform("io.github.mfvanek:pg-index-health-bom:0.13.2"))

constraints {
api("org.liquibase:liquibase-core:4.29.2")
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ services:

postgres:
container_name: postgres
image: postgres:16.4
image: postgres:17.0
shm_size: "2gb"
environment:
POSTGRES_DB: "otel_demo_db"
Expand Down
3 changes: 2 additions & 1 deletion spring-boot-2-demo-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ dependencies {

implementation("org.springframework.kafka:spring-kafka")
implementation("io.opentelemetry:opentelemetry-exporter-otlp")
implementation("org.springframework.cloud:spring-cloud-starter-sleuth") {
implementation("org.springframework.cloud:spring-cloud-starter-sleuth:3.1.11") {
because("The version is higher than in BOM")
exclude(group = "org.springframework.cloud", module = "spring-cloud-sleuth-brave")
}
implementation("org.springframework.cloud:spring-cloud-sleuth-otel-autoconfigure")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
import io.github.mfvanek.pg.common.maintenance.DatabaseCheckOnHost;
import io.github.mfvanek.pg.common.maintenance.Diagnostic;
import io.github.mfvanek.pg.model.DbObject;
import io.github.mfvanek.pg.model.column.Column;
import io.github.mfvanek.pg.model.table.Table;
import io.github.mfvanek.pg.model.PgContext;
import io.github.mfvanek.pg.model.table.TableNameAware;
import io.github.mfvanek.spring.boot2.test.support.TestBase;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.function.Predicate;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.InstanceOfAssertFactories.list;

class IndexesMaintenanceTest extends TestBase {

Expand All @@ -25,33 +25,27 @@ class IndexesMaintenanceTest extends TestBase {
void checkPostgresVersion() {
final String pgVersion = jdbcTemplate.queryForObject("select version();", String.class);
assertThat(pgVersion)
.startsWith("PostgreSQL 16.4");
.startsWith("PostgreSQL 17.0");
}

@Test
void databaseStructureCheckForPublicSchema() {
assertThat(checks)
.hasSameSizeAs(Diagnostic.values());

checks.forEach(check -> {
switch (check.getDiagnostic()) {
case TABLES_WITHOUT_PRIMARY_KEY, TABLES_WITHOUT_DESCRIPTION -> assertThat(check.check())
.asInstanceOf(list(Table.class))
.hasSize(1)
.containsExactly(Table.of("databasechangelog", 0L));

case COLUMNS_WITHOUT_DESCRIPTION -> assertThat(check.check())
.asInstanceOf(list(Column.class))
.hasSize(14)
.allSatisfy(column -> assertThat(column.getTableName()).isEqualTo("databasechangelog"));

case TABLES_WITH_MISSING_INDEXES -> assertThat(check.check())
.hasSizeLessThanOrEqualTo(1); // TODO skip runtime checks after https://github.com/mfvanek/pg-index-health/issues/456

default -> assertThat(check.check())
checks.stream()
.filter(DatabaseCheckOnHost::isStatic)
.forEach(check -> {
final Predicate<DbObject> skipLiquibaseTables = dbObject -> {
if (dbObject instanceof TableNameAware t) {
return !t.getTableName().equalsIgnoreCase("databasechangelog");
}
return true;
};
final List<? extends DbObject> objects = check.check(PgContext.ofPublic(), skipLiquibaseTables);
assertThat(objects)
.as(check.getDiagnostic().name())
.isEmpty();
}
});
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class PostgresInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {

private static final DockerImageName IMAGE = DockerImageName.parse("postgres:16.4");
private static final DockerImageName IMAGE = DockerImageName.parse("postgres:17.0");
private static final Network NETWORK = Network.newNetwork();
private static final PostgreSQLContainer<?> CONTAINER = new PostgreSQLContainer<>(IMAGE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
import io.github.mfvanek.pg.common.maintenance.DatabaseCheckOnHost;
import io.github.mfvanek.pg.common.maintenance.Diagnostic;
import io.github.mfvanek.pg.model.DbObject;
import io.github.mfvanek.pg.model.column.Column;
import io.github.mfvanek.pg.model.table.Table;
import io.github.mfvanek.pg.model.PgContext;
import io.github.mfvanek.pg.model.table.TableNameAware;
import io.github.mfvanek.spring.boot3.test.support.TestBase;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.function.Predicate;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.InstanceOfAssertFactories.list;

class IndexesMaintenanceTest extends TestBase {

Expand All @@ -25,33 +25,27 @@ class IndexesMaintenanceTest extends TestBase {
void checkPostgresVersion() {
final String pgVersion = jdbcTemplate.queryForObject("select version();", String.class);
assertThat(pgVersion)
.startsWith("PostgreSQL 16.4");
.startsWith("PostgreSQL 17.0");
}

@Test
void databaseStructureCheckForPublicSchema() {
assertThat(checks)
.hasSameSizeAs(Diagnostic.values());

checks.forEach(check -> {
switch (check.getDiagnostic()) {
case TABLES_WITHOUT_PRIMARY_KEY, TABLES_WITHOUT_DESCRIPTION -> assertThat(check.check())
.asInstanceOf(list(Table.class))
.hasSize(1)
.containsExactly(Table.of("databasechangelog", 0L));

case COLUMNS_WITHOUT_DESCRIPTION -> assertThat(check.check())
.asInstanceOf(list(Column.class))
.hasSize(14)
.allSatisfy(column -> assertThat(column.getTableName()).isEqualTo("databasechangelog"));

case TABLES_WITH_MISSING_INDEXES -> assertThat(check.check())
.hasSizeLessThanOrEqualTo(1); // TODO skip runtime checks after https://github.com/mfvanek/pg-index-health/issues/456

default -> assertThat(check.check())
checks.stream()
.filter(DatabaseCheckOnHost::isStatic)
.forEach(check -> {
final Predicate<DbObject> skipLiquibaseTables = dbObject -> {
if (dbObject instanceof TableNameAware t) {
return !t.getTableName().equalsIgnoreCase("databasechangelog");
}
return true;
};
final List<? extends DbObject> objects = check.check(PgContext.ofPublic(), skipLiquibaseTables);
assertThat(objects)
.as(check.getDiagnostic().name())
.isEmpty();
}
});
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class PostgresInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {

private static final DockerImageName IMAGE = DockerImageName.parse("postgres:16.4");
private static final DockerImageName IMAGE = DockerImageName.parse("postgres:17.0");
private static final Network NETWORK = Network.newNetwork();
private static final PostgreSQLContainer<?> CONTAINER = new PostgreSQLContainer<>(IMAGE);

Expand Down