Some checks failed
CI / cleanup-branch (push) Has been skipped
CI / build (push) Failing after 2m29s
CI / docker (push) Has been skipped
CI / deploy (push) Has been skipped
CI / deploy-feature (push) Has been skipped
CI / cleanup-branch (pull_request) Has been skipped
CI / build (pull_request) Failing after 2m28s
CI / docker (pull_request) Has been skipped
CI / deploy (pull_request) Has been skipped
CI / deploy-feature (pull_request) Has been skipped
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
60 lines
2.6 KiB
Java
60 lines
2.6 KiB
Java
package com.cameleer3.server.app;
|
|
|
|
import org.opensearch.testcontainers.OpensearchContainer;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.test.context.ActiveProfiles;
|
|
import org.springframework.test.context.DynamicPropertyRegistry;
|
|
import org.springframework.test.context.DynamicPropertySource;
|
|
import org.testcontainers.clickhouse.ClickHouseContainer;
|
|
import org.testcontainers.containers.PostgreSQLContainer;
|
|
import org.testcontainers.utility.DockerImageName;
|
|
|
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
|
@ActiveProfiles("test")
|
|
public abstract class AbstractPostgresIT {
|
|
|
|
private static final DockerImageName TIMESCALEDB_IMAGE =
|
|
DockerImageName.parse("timescale/timescaledb-ha:pg16")
|
|
.asCompatibleSubstituteFor("postgres");
|
|
|
|
static final PostgreSQLContainer<?> postgres;
|
|
static final OpensearchContainer<?> opensearch;
|
|
static final ClickHouseContainer clickhouse;
|
|
|
|
static {
|
|
postgres = new PostgreSQLContainer<>(TIMESCALEDB_IMAGE)
|
|
.withDatabaseName("cameleer3")
|
|
.withUsername("cameleer")
|
|
.withPassword("test");
|
|
postgres.start();
|
|
|
|
opensearch = new OpensearchContainer<>("opensearchproject/opensearch:2.19.0");
|
|
opensearch.start();
|
|
|
|
clickhouse = new ClickHouseContainer("clickhouse/clickhouse-server:24.12");
|
|
clickhouse.start();
|
|
}
|
|
|
|
@Autowired
|
|
protected JdbcTemplate jdbcTemplate;
|
|
|
|
@DynamicPropertySource
|
|
static void configureProperties(DynamicPropertyRegistry registry) {
|
|
registry.add("spring.datasource.url", postgres::getJdbcUrl);
|
|
registry.add("spring.datasource.username", postgres::getUsername);
|
|
registry.add("spring.datasource.password", postgres::getPassword);
|
|
registry.add("spring.datasource.driver-class-name", () -> "org.postgresql.Driver");
|
|
registry.add("spring.flyway.enabled", () -> "true");
|
|
registry.add("spring.flyway.url", postgres::getJdbcUrl);
|
|
registry.add("spring.flyway.user", postgres::getUsername);
|
|
registry.add("spring.flyway.password", postgres::getPassword);
|
|
registry.add("opensearch.url", opensearch::getHttpHostAddress);
|
|
registry.add("clickhouse.enabled", () -> "true");
|
|
registry.add("clickhouse.url", clickhouse::getJdbcUrl);
|
|
registry.add("clickhouse.username", clickhouse::getUsername);
|
|
registry.add("clickhouse.password", clickhouse::getPassword);
|
|
}
|
|
}
|