Gitlab CI gradle测试测试数据库错误

huangapple 未分类评论54阅读模式
英文:

Gitlab CI gradle test test database error

问题

以下是我的 .gitlab-ci.yml 文件内容:

  1. image: java:8
  2. stages:
  3. - build
  4. - test
  5. - deploy
  6. build project:
  7. stage: build
  8. script:
  9. - ./gradlew build -x test
  10. artifacts:
  11. expire_in: 1 hour
  12. paths:
  13. - build/libs/*.jar
  14. test project:
  15. stage: test
  16. script:
  17. - ./gradlew test

以下是用于测试位置的应用程序属性,位于 src/test/resources/application-test.properties 文件中:

  1. server.port=8085
  2. spring.application.name=Project Test
  3. spring.jpa.hibernate.ddl-auto=none
  4. spring.datasource.url=jdbc:h2:mem:testdb
  5. spring.datasource.username=sa
  6. spring.datasource.password=
  7. spring.h2.console.enabled=false
  8. spring.jpa.show-sql=true
  9. ## Liquibase 迁移
  10. spring.liquibase.change-log=classpath:db/migrations/db.changelog-master.xml

但流水线始终在测试阶段失败,显示以下错误:

  1. > Task :test
  2. MedcareApplicationTests > contextLoads() FAILED
  3. java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:132
  4. Caused by: org.springframework.beans.factory.BeanCreationException at AbstractAutowireCapableBeanFactory.java:1796
  5. Caused by: liquibase.exception.DatabaseException at SpringLiquibase.java:316
  6. Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException at SQLError.java:174
  7. Caused by: com.mysql.cj.exceptions.CJCommunicationsException at NativeConstructorAccessorImpl.java:-2
  8. Caused by: java.net.ConnectException at PlainSocketImpl.java:-2

我还尝试了使用 MySQL 测试数据库,但没有成功。我无法查看报告,因为我认为报告是在容器内部生成的。我一整天都卡在这个问题上了,非常感谢任何帮助或提示。

英文:

Following is my .gitlab-ci.yml.

  1. image: java:8
  2. stages:
  3. - build
  4. - test
  5. - deploy
  6. build project:
  7. stage: build
  8. script:
  9. - ./gradlew build -x test
  10. artifacts:
  11. expire_in: 1 hour
  12. paths:
  13. - build/libs/*.jar
  14. test project:
  15. stage: test
  16. script:
  17. - ./gradlew test

And following is my application properties for testing location in src/test/resources/application-test.properties

  1. server.port=8085
  2. spring.application.name=Project Test
  3. spring.jpa.hibernate.ddl-auto=none
  4. spring.datasource.url=jdbc:h2:mem:testdb
  5. spring.datasource.username=sa
  6. spring.datasource.password=
  7. spring.h2.console.enabled=false
  8. spring.jpa.show-sql=true
  9. ## Liquibase migration
  10. spring.liquibase.change-log=classpath:db/migrations/db.changelog-master.xml

But pipeline always fails on test stage with following error:

  1. > Task :test
  2. MedcareApplicationTests > contextLoads() FAILED
  3. java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:132
  4. Caused by: org.springframework.beans.factory.BeanCreationException at AbstractAutowireCapableBeanFactory.java:1796
  5. Caused by: liquibase.exception.DatabaseException at SpringLiquibase.java:316
  6. Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException at SQLError.java:174
  7. Caused by: com.mysql.cj.exceptions.CJCommunicationsException at NativeConstructorAccessorImpl.java:-2
  8. Caused by: java.net.ConnectException at PlainSocketImpl.java:-2

I tried with Mysql test database too, but no luck.
I'm unable to see reports because it's generated inside container, I think. Stuck on these whole day, any help or hint is appreciated.

huangapple
  • 本文由 发表于 2020年4月8日 23:26:15
  • 转载请务必保留本文链接:https://java.coder-hub.com/61104307.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定