Skip to content

Instantly share code, notes, and snippets.

View eddumelendez's full-sized avatar
🇲🇽

Eddú Meléndez Gonzales eddumelendez

🇲🇽
View GitHub Profile
public class ConsumerApplicationTests {
public static void main(String[] args) {
SpringApplication.from(ConsumerApplication::main)
.with(ContainerConfiguration.class)
.run(args);
}
@TestConfiguration
static class ContainerConfiguration {
public class ConsumerApplicationTests {
public static void main(String[] args) {
SpringApplication.from(ConsumerApplication::main)
.with(ContainerConfiguration.class)
.run(args);
}
@TestConfiguration
static class ContainerConfiguration {
@Testcontainers
@JdbcTest
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
class PostgresTest {
@Container
private static final PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:15-alpine");
@DynamicPropertySource
static void registerProperties(DynamicPropertyRegistry registry) {
@Testcontainers
@JdbcTest
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
class PostgresTest {
@Container
@ServiceConnection
private static final PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:15-alpine");
@Autowired
@DataJdbcTest(properties = { "spring.datasource.url=jdbc:tc:postgresql:15-alpine:///" })
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
class PostgresHostLessTest {
@Autowired
private JdbcTemplate jdbcTemplate;
@Test
void test() {
var records = this.jdbcTemplate.queryForList("select count(*) from profile");
Waiting for all LocalStack services to be ready
2022-06-20 03:11:24,487 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message.
2022-06-20 03:11:24,489 INFO supervisord started with pid 14
2022-06-20 03:11:25,508 INFO spawned: 'infra' with pid 19
2022-06-20 03:11:26,505 INFO success: infra entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
LocalStack version: 0.14.3.1
LocalStack build date: 2022-05-25
LocalStack build git hash: 496e6015
@eddumelendez
eddumelendez / LocalstackTest.java
Last active May 31, 2022 21:26
Testcontainers and localstack
@Testcontainers
class LocalstackTest {
@Container
private final LocalStackContainer localstack =
new LocalStackContainer(DockerImageName.parse("localstack/localstack").withTag("0.14.2"))
.withCopyFileToContainer(MountableFile.forClasspathResource("/localstack"), "/docker-entrypoint-initaws.d")
.withServices(Service.S3)
.waitingFor(Wait.forLogMessage(".*s3 bucket created\\.\n", 1));
▶ waypoint up -vv
2020-10-18T12:41:12.623-0500 [INFO] waypoint: waypoint version: full_string="Waypoint v0.1.2 (edf37a09)" version=v0.1.2 prerelease= metadata= revision=edf37a09
2020-10-18T12:41:12.623-0500 [DEBUG] waypoint: home configuration directory: path=/Users/eddumelendez/Library/Preferences/waypoint
2020-10-18T12:41:12.624-0500 [INFO] waypoint.server: attempting to source credentials and connect
2020-10-18T12:41:12.642-0500 [DEBUG] waypoint.server: connection established with sourced credentials
2020-10-18T12:41:12.645-0500 [INFO] waypoint: server version info: version=v0.1.2 api_min=1 api_current=1 entrypoint_min=1 entrypoint_current=1
2020-10-18T12:41:12.645-0500 [INFO] waypoint: negotiated api version: version=1
2020-10-18T12:41:12.645-0500 [DEBUG] waypoint: will operate on app: name=hello-world-pedestal-11
2020-10-18T12:41:12.645-0500 [INFO] waypoint: local mode, starting local runner
2020-10-18T12:41:12.645-0500 [DEBUG] waypoint.runner: registering runner
{:name "Eddú Meléndez"
:from "Perú"
:title "Software Engineer"
:languages #{:clojure :java}
:networks [{:type :github
:account "eddumelendez"}
{:type :twitter
:account "eddumelendez"}]
:hobbies [:reading :coding]}