1
1
package org.ktorm.support.oracle
2
2
3
- import org.junit.ClassRule
4
3
import org.ktorm.BaseTest
5
4
import org.ktorm.database.Database
6
5
import org.testcontainers.containers.OracleContainer
6
+ import kotlin.concurrent.thread
7
7
8
8
abstract class BaseOracleTest : BaseTest () {
9
9
10
10
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 )
19
12
execSqlScript(" init-oracle-data.sql" )
20
13
}
21
14
22
15
override fun destroy () {
23
16
execSqlScript(" drop-oracle-data.sql" )
24
17
}
25
18
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
+ }
32
46
}
33
47
}
0 commit comments