I test concurency behaviors and I want to validate code when computation is long. I need to configure PostgreSQL timeout.
Locally, in my docker-compose I have the following configuration :
services:
postgres:
image: postgres:14.8
command: [ "postgres", "-c", "log_statement=all", "-c", "log_destination=stderr", "-c", "lock_timeout=3s" ]
ports:
- "5432:5432"
The following test passes :
@SpringBootTest(classes = PostgreSQLConfigurationTest.GenericConfiguration.class)
public class PostgreSQLConfigurationTest {
@Autowired
private JdbcTemplate jdbcTemplate;
@Test
void shouldLockTimeoutSetTo3s() {
String sql = "SHOW lock_timeout";
String lockTimeout = jdbcTemplate.queryForObject(sql, String.class);
assertEquals("3s", lockTimeout, "lock_timeout attendu valant " + lockTimeout);
}
@SpringBootApplication
public static class GenericConfiguration {
}
}
In the CI configuration file, I don't know how to the same :
check:
services:
- name: postgres:14.3
alias: postgresql
This can be done with the service.entryoint
or service.command
keyword (see docs). Actually, you should be pretty much be able to copy your information from the compose file.