Skip to content

Instantly share code, notes, and snippets.

View FRosner's full-sized avatar

Frank Rosner FRosner

View GitHub Profile
<dependency>
<groupId>com.formkiq</groupId>
<artifactId>lambda-runtime-graalvm</artifactId>
<version>${lambdaRuntime.version}</version>
</dependency>
public class LambdaHandler implements RequestHandler<APIGatewayV2HTTPEvent, LambdaResponse> {
private static final Gson mapper = new Gson();
private static final AstraClient astraClient = newAstraClientFromEnv();
private static AstraClient newAstraClientFromEnv() {
String astraUrl = System.getenv("ASTRA_URL");
String astraToken = System.getenv("ASTRA_TOKEN");
String astraNamespace = System.getenv("ASTRA_NAMESPACE");
import com.amazonaws.auth.AWSCredentialsProvider
import com.amazonaws.auth.AWSSessionCredentials
import com.amazonaws.auth.BasicAWSCredentials
import com.amazonaws.auth.profile.internal.AllProfiles
import com.amazonaws.auth.profile.internal.AwsProfileNameLoader
import com.amazonaws.auth.profile.internal.BasicProfile
import com.amazonaws.auth.profile.internal.BasicProfileConfigLoader
import com.amazonaws.auth.profile.internal.ProfileAssumeRoleCredentialsProvider
import com.amazonaws.auth.profile.internal.ProfileStaticCredentialsProvider
import com.amazonaws.auth.profile.internal.securitytoken.STSProfileCredentialsServiceLoader
fun testAfterMigration(postgresContainer: PostgresContainer, testFunction: suspend (PgClient) -> Unit) {
migrate(postgresContainer.connectionDetails)
val pgClient = createPgClient(postgresContainer.connectionDetails)
runBlocking {
testFunction(pgClient)
}
}
@Testcontainers
class DatabaseMigrationsTest {
@Container
val postgresContainer = PostgresContainer("postgres:10.6")
.withDatabaseName("db")
.withUsername("user")
.withPassword("password")
@Test
val (host, port, dbName, username, password) = getConnectionDetails()
val jdbcUrl = "jdbc:postgresql://$host:$port/$dbName"
Flyway.configure()
.dataSource(jdbcUrl, username, password)
.load()
.migrate()
-- V1.0.1__Customer_id_index.sql
create unique index customer_id
on customers (id)
-- V1.0.0__Customer_table.sql
create table customers (
id int,
last_name varchar(255),
first_name varchar(255)
);
.
└── src
└── main
└── resources
└── db_migrations
├── V1.0.0__Customer_table.sql
├── V1.0.1__Customer_id_index.sql
└── V2.0.0__Product_table.sql
1 /sbin/init
|
+ ...
|
+-- 506 /usr/local/zeppelin
1 /usr/local/zeppelin
+-- 2 interpreter.sh
+-- 3 interpreter.sh
+-- 511 /usr/local/zeppelin
1 /usr/local/zeppelin