Jenkins 上的 Grails 集成测试 运行
Grails integrations tests run on Jenkins
我正在尝试将 Grails 应用程序(版本 2.2.2)部署到 Jenkins(版本 1.638)。它运行 clean
、test-app -Dgrails.env=XXX
和 war
命令。
clean
和 war
效果很好。对于 test-app -Dgrails.env=XXX
,单元测试部分工作正常,每个测试用例都通过了。但是,大多数集成测试用例都失败了。控制器中的domain 类 似乎无法获取数据。换句话说,get()
或 list()
方法没有 return 更正记录。我假设数据库连接正确,因为控制台输出没有抱怨连接问题。集成测试在具有相同数据源的本地计算机上运行良好。
测试错误如下代码,size()
一直为0,是controller集成测试。 results
由控制器中域 类 的 get()
、list()
或 createCriteria().list{}
方法 return 编辑。
results.size() == 9
| | |
[] 0 false
下面是DataSource.groovy中的代码。 testCI
和 testCI2
我都试过了。两种设置都没有帮助。老实说,我对 pool properties
了解不多。我刚刚复制了它。
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
environments {
testCI {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:mysql://localhost:3306/build_db" // For non network testing
driverClassName = "com.mysql.jdbc.Driver"
username ="build"
password = "build"
pooled=true
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
}
testCI2 {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:mysql://localhost:3306/build_db" // For non network testing
driverClassName = "com.mysql.jdbc.Driver"
username ="build"
password = "build"
}
}
}
最奇怪的部分是,在我将新提交推送到 git 存储库后,集成测试有时运行良好。不过并不经常。
有没有人对此有任何想法?非常感谢!!
IIRC,单元测试 运行 基于内存的 GORM 表示。
对于集成测试,您需要一个真实的(来自您的示例,MySQL)数据库。
MySQL 是否安装在 Jenkins 服务器上——当您的集成测试 运行.
时,它是本地主机
我正在尝试将 Grails 应用程序(版本 2.2.2)部署到 Jenkins(版本 1.638)。它运行 clean
、test-app -Dgrails.env=XXX
和 war
命令。
clean
和 war
效果很好。对于 test-app -Dgrails.env=XXX
,单元测试部分工作正常,每个测试用例都通过了。但是,大多数集成测试用例都失败了。控制器中的domain 类 似乎无法获取数据。换句话说,get()
或 list()
方法没有 return 更正记录。我假设数据库连接正确,因为控制台输出没有抱怨连接问题。集成测试在具有相同数据源的本地计算机上运行良好。
测试错误如下代码,size()
一直为0,是controller集成测试。 results
由控制器中域 类 的 get()
、list()
或 createCriteria().list{}
方法 return 编辑。
results.size() == 9
| | |
[] 0 false
下面是DataSource.groovy中的代码。 testCI
和 testCI2
我都试过了。两种设置都没有帮助。老实说,我对 pool properties
了解不多。我刚刚复制了它。
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
environments {
testCI {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:mysql://localhost:3306/build_db" // For non network testing
driverClassName = "com.mysql.jdbc.Driver"
username ="build"
password = "build"
pooled=true
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
}
testCI2 {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:mysql://localhost:3306/build_db" // For non network testing
driverClassName = "com.mysql.jdbc.Driver"
username ="build"
password = "build"
}
}
}
最奇怪的部分是,在我将新提交推送到 git 存储库后,集成测试有时运行良好。不过并不经常。
有没有人对此有任何想法?非常感谢!!
IIRC,单元测试 运行 基于内存的 GORM 表示。
对于集成测试,您需要一个真实的(来自您的示例,MySQL)数据库。
MySQL 是否安装在 Jenkins 服务器上——当您的集成测试 运行.
时,它是本地主机