Skip to content

Commit 034b6f3

Browse files
upgrade testcontainers for Apple Silicon
1 parent 8c95e85 commit 034b6f3

File tree

6 files changed

+34
-20
lines changed

6 files changed

+34
-20
lines changed

ktorm-support-mysql/ktorm-support-mysql.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ dependencies {
1010
api(project(":ktorm-core"))
1111
testImplementation(project(":ktorm-core", configuration = "testOutput"))
1212
testImplementation(project(":ktorm-jackson"))
13-
testImplementation("org.testcontainers:mysql:1.15.1")
13+
testImplementation("org.testcontainers:mysql:1.19.7")
1414
testImplementation("mysql:mysql-connector-java:8.0.23")
1515
}

ktorm-support-oracle/ktorm-support-oracle.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ plugins {
99
dependencies {
1010
api(project(":ktorm-core"))
1111
testImplementation(project(":ktorm-core", configuration = "testOutput"))
12-
testImplementation("org.testcontainers:oracle-xe:1.15.1")
12+
testImplementation("org.testcontainers:oracle-xe:1.19.7")
1313
testImplementation(files("lib/ojdbc6-11.2.0.3.jar"))
1414
}
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,47 @@
11
package org.ktorm.support.oracle
22

3-
import org.junit.ClassRule
43
import org.ktorm.BaseTest
54
import org.ktorm.database.Database
65
import org.testcontainers.containers.OracleContainer
6+
import kotlin.concurrent.thread
77

88
abstract class BaseOracleTest : BaseTest() {
99

1010
override fun init() {
11-
database = Database.connect(
12-
url = container.jdbcUrl,
13-
driver = container.driverClassName,
14-
user = container.username,
15-
password = container.password,
16-
alwaysQuoteIdentifiers = true
17-
)
18-
11+
database = Database.connect(jdbcUrl, driverClassName, username, password, alwaysQuoteIdentifiers = true)
1912
execSqlScript("init-oracle-data.sql")
2013
}
2114

2215
override fun destroy() {
2316
execSqlScript("drop-oracle-data.sql")
2417
}
2518

26-
companion object {
27-
@JvmField
28-
@ClassRule
29-
val container = OracleContainer("zerda/oracle-database:11.2.0.2-xe")
30-
// At least 1 GB memory is required by Oracle.
31-
.withCreateContainerCmdModifier { cmd -> cmd.hostConfig?.withShmSize((1 * 1024 * 1024 * 1024).toLong()) }
19+
/**
20+
* Unfortunately Oracle databases aren’t compatible with the new Apple Silicon CPU architecture,
21+
* so if you are using a brand-new MacBook, you need to install colima.
22+
*
23+
* 1. Installation: https://github.com/abiosoft/colima#installation
24+
* 2. Run Colima with the command: `colima start --arch x86_64 --cpu 2 --memory 4 --disk 16 --network-address`
25+
* 3. Set env vars like below:
26+
*
27+
* ```sh
28+
* export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock
29+
* export TESTCONTAINERS_HOST_OVERRIDE=$(colima ls -j | jq -r '.address')
30+
* export DOCKER_HOST="unix://${HOME}/.colima/default/docker.sock"
31+
* ```
32+
*
33+
* See https://java.testcontainers.org/supported_docker_environment/#colima
34+
*/
35+
companion object : OracleContainer("gvenzl/oracle-xe:11.2.0.2") {
36+
init {
37+
// Configure the container.
38+
usingSid()
39+
withCreateContainerCmdModifier { cmd -> cmd.hostConfig?.withShmSize((1 * 1024 * 1024 * 1024).toLong()) }
40+
41+
// Start the container when it's first used.
42+
start()
43+
// Stop the container when the process exits.
44+
Runtime.getRuntime().addShutdownHook(thread(start = false) { stop() })
45+
}
3246
}
3347
}

ktorm-support-oracle/src/test/kotlin/org/ktorm/support/oracle/CommonTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class CommonTest : BaseOracleTest() {
106106

107107
@Test
108108
fun testSchema() {
109-
val t = object : Table<Department>("t_department", schema = container.username.uppercase()) {
109+
val t = object : Table<Department>("t_department", schema = username.uppercase()) {
110110
val id = int("id").primaryKey().bindTo { it.id }
111111
val name = varchar("name").bindTo { it.name }
112112
}

ktorm-support-postgresql/ktorm-support-postgresql.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies {
1010
api(project(":ktorm-core"))
1111
testImplementation(project(":ktorm-core", configuration = "testOutput"))
1212
testImplementation(project(":ktorm-jackson"))
13-
testImplementation("org.testcontainers:postgresql:1.15.1")
13+
testImplementation("org.testcontainers:postgresql:1.19.7")
1414
testImplementation("org.postgresql:postgresql:42.2.5")
1515
testImplementation("com.zaxxer:HikariCP:4.0.3")
1616
testImplementation("com.mchange:c3p0:0.9.5.5")

ktorm-support-sqlserver/ktorm-support-sqlserver.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ plugins {
99
dependencies {
1010
api(project(":ktorm-core"))
1111
testImplementation(project(":ktorm-core", configuration = "testOutput"))
12-
testImplementation("org.testcontainers:mssqlserver:1.15.1")
12+
testImplementation("org.testcontainers:mssqlserver:1.19.7")
1313
testImplementation("com.microsoft.sqlserver:mssql-jdbc:7.2.2.jre8")
1414
}

0 commit comments

Comments
 (0)