From 9689c0e8dc3c856093f2c9f83adb118190c3189f Mon Sep 17 00:00:00 2001 From: jruaux Date: Mon, 17 Jun 2024 15:06:26 -0700 Subject: [PATCH] cicd: Added early-access and release workflows --- .../com/redis/riot/PostgresDeltaTests.java | 39 +++++++++++++++++++ .../src/test/resources/db/postgres-delta.sql | 7 ++++ 2 files changed, 46 insertions(+) create mode 100644 plugins/riot/src/test/java/com/redis/riot/PostgresDeltaTests.java create mode 100644 plugins/riot/src/test/resources/db/postgres-delta.sql diff --git a/plugins/riot/src/test/java/com/redis/riot/PostgresDeltaTests.java b/plugins/riot/src/test/java/com/redis/riot/PostgresDeltaTests.java new file mode 100644 index 000000000..5c6b81273 --- /dev/null +++ b/plugins/riot/src/test/java/com/redis/riot/PostgresDeltaTests.java @@ -0,0 +1,39 @@ +package com.redis.riot; + +import java.io.IOException; +import java.sql.SQLException; +import java.sql.Statement; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.testcontainers.containers.JdbcDatabaseContainer; +import org.testcontainers.containers.PostgreSQLContainer; +import org.testcontainers.utility.DockerImageName; + +class PostgresDeltaTests extends DbTests { + + private static final DockerImageName postgresImage = DockerImageName.parse(PostgreSQLContainer.IMAGE) + .withTag(PostgreSQLContainer.DEFAULT_TAG); + private static final PostgreSQLContainer postgres = new PostgreSQLContainer<>(postgresImage); + + @Override + protected JdbcDatabaseContainer getJdbcDatabaseContainer() { + return postgres; + } + + @BeforeAll + void setupPostgres() throws SQLException, IOException { + executeScript("db/postgres-delta.sql"); + } + + @Test + void importDelta(TestInfo info) throws Exception { + try (Statement statement = dbConnection.createStatement()) { + for (int index = 0; index < 10; index++) { + statement.execute("INSERT INTO orders (order_date) VALUES (CURRENT_TIMESTAMP - INTERVAL '5 seconds')"); + } + } + } + +} diff --git a/plugins/riot/src/test/resources/db/postgres-delta.sql b/plugins/riot/src/test/resources/db/postgres-delta.sql new file mode 100644 index 000000000..23f103ab8 --- /dev/null +++ b/plugins/riot/src/test/resources/db/postgres-delta.sql @@ -0,0 +1,7 @@ +DROP TABLE IF EXISTS orders; + +CREATE TABLE orders ( + order_id SERIAL PRIMARY KEY, + order_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); +