Skip to content

Commit fcb1c4b

Browse files
authored
Remove OrackeJDK from TravisCI builds (#76)
* Remove OrackeJDK from TravisCI builds * Use docker for database test
1 parent 185ceb9 commit fcb1c4b

File tree

3 files changed

+44
-57
lines changed

3 files changed

+44
-57
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
language: scala
22
sudo: true
33
jdk:
4-
- oraclejdk8
5-
- oraclejdk11
64
- openjdk8
75
- openjdk11
86
script:

build.sbt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ version := "1.8.1"
44
scalaVersion := "2.12.8"
55
gitbucketVersion := "4.31.0"
66
libraryDependencies ++= Seq(
7-
"org.fusesource.jansi" % "jansi" % "1.16",
8-
"org.scalatest" %% "scalatest" % "3.0.5" % "test",
9-
"com.wix" % "wix-embedded-mysql" % "3.0.0" % "test",
10-
"ru.yandex.qatools.embed" % "postgresql-embedded" % "2.6" % "test"
7+
"org.fusesource.jansi" % "jansi" % "1.16",
8+
"org.scalatest" %% "scalatest" % "3.0.5" % "test",
9+
"com.dimafeng" %% "testcontainers-scala" % "0.27.0" % "test",
10+
"org.testcontainers" % "mysql" % "1.11.3" % "test",
11+
"org.testcontainers" % "postgresql" % "1.11.3" % "test"
1112
)
1213

src/test/scala/io/github/gitbucket/ci/MigrationSpec.scala

Lines changed: 39 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,18 @@ package io.github.gitbucket.ci
22

33
import java.sql.DriverManager
44

5+
import com.dimafeng.testcontainers.{MySQLContainer, PostgreSQLContainer}
56
import io.github.gitbucket.solidbase.Solidbase
67
import io.github.gitbucket.solidbase.model.Module
78
import liquibase.database.core.{H2Database, MySQLDatabase, PostgresDatabase}
9+
import org.junit.runner.Description
810
import org.scalatest.{FunSuite, Tag}
9-
1011
import scala.collection.JavaConverters._
11-
import com.wix.mysql.EmbeddedMysql._
12-
import com.wix.mysql.config.Charset
13-
import com.wix.mysql.config.MysqldConfig._
14-
import com.wix.mysql.distribution.Version._
15-
import ru.yandex.qatools.embed.postgresql.PostgresStarter
16-
import ru.yandex.qatools.embed.postgresql.config.AbstractPostgresConfig.{Credentials, Net, Storage, Timeout}
17-
import ru.yandex.qatools.embed.postgresql.config.PostgresConfig
18-
import ru.yandex.qatools.embed.postgresql.distribution.Version.Main.PRODUCTION
1912

2013
object ExternalDBTest extends Tag("ExternalDBTest")
2114

2215
class MigrationSpec extends FunSuite {
16+
2317
val plugin = Class.forName("Plugin").newInstance().asInstanceOf[gitbucket.core.plugin.Plugin]
2418

2519
test("Migration H2") {
@@ -31,53 +25,47 @@ class MigrationSpec extends FunSuite {
3125
)
3226
}
3327

34-
test("Migration MySQL", ExternalDBTest) {
35-
val config = aMysqldConfig(v5_7_latest)
36-
.withPort(3306)
37-
.withUser("sa", "sa")
38-
.withCharset(Charset.UTF8)
39-
.withServerVariable("log_syslog", 0)
40-
.withServerVariable("bind-address", "127.0.0.1")
41-
.build()
42-
43-
val mysqld = anEmbeddedMysql(config)
44-
.addSchema("gitbucket")
45-
.start()
28+
implicit private val suiteDescription = Description.createSuiteDescription(getClass)
4629

47-
try {
48-
new Solidbase().migrate(
49-
DriverManager.getConnection("jdbc:mysql://localhost:3306/gitbucket?useSSL=false", "sa", "sa"),
50-
Thread.currentThread().getContextClassLoader(),
51-
new MySQLDatabase(),
52-
new Module(plugin.pluginId, plugin.versions.asJava)
53-
)
54-
} finally {
55-
mysqld.stop()
30+
Seq("8.0", "5.7").foreach { tag =>
31+
test(s"Migration MySQL $tag", ExternalDBTest) {
32+
val container = new MySQLContainer() {
33+
override val container = new org.testcontainers.containers.MySQLContainer(s"mysql:$tag") {
34+
override def getDriverClassName = "org.mariadb.jdbc.Driver"
35+
}
36+
// TODO https://github.com/testcontainers/testcontainers-java/issues/736
37+
container.withCommand("mysqld --default-authentication-plugin=mysql_native_password")
38+
}
39+
container.starting()
40+
try {
41+
new Solidbase().migrate(
42+
DriverManager.getConnection(s"${container.jdbcUrl}?useSSL=false", container.username, container.password),
43+
Thread.currentThread().getContextClassLoader(),
44+
new MySQLDatabase(),
45+
new Module(plugin.pluginId, plugin.versions.asJava)
46+
)
47+
} finally {
48+
container.finished()
49+
}
5650
}
5751
}
5852

59-
test("Migration PostgreSQL", ExternalDBTest) {
60-
val runtime = PostgresStarter.getDefaultInstance()
61-
val config = new PostgresConfig(
62-
PRODUCTION,
63-
new Net("localhost", 5432),
64-
new Storage("gitbucket"),
65-
new Timeout(),
66-
new Credentials("sa", "sa")
67-
)
68-
69-
val exec = runtime.prepare(config)
70-
val process = exec.start()
53+
Seq("11", "10").foreach { tag =>
54+
test(s"Migration PostgreSQL $tag", ExternalDBTest) {
55+
val container = PostgreSQLContainer(s"postgres:$tag")
7156

72-
try {
73-
new Solidbase().migrate(
74-
DriverManager.getConnection("jdbc:postgresql://localhost:5432/gitbucket", "sa", "sa"),
75-
Thread.currentThread().getContextClassLoader(),
76-
new PostgresDatabase(),
77-
new Module(plugin.pluginId, plugin.versions.asJava)
78-
)
79-
} finally {
80-
process.stop()
57+
container.starting()
58+
try {
59+
new Solidbase().migrate(
60+
DriverManager.getConnection(container.jdbcUrl, container.username, container.password),
61+
Thread.currentThread().getContextClassLoader(),
62+
new PostgresDatabase(),
63+
new Module(plugin.pluginId, plugin.versions.asJava)
64+
)
65+
} finally {
66+
container.finished()
67+
}
8168
}
8269
}
70+
8371
}

0 commit comments

Comments
 (0)