gpt4 book ai didi

docker - SBT测试在CI服务器上的运行速度非常慢

转载 作者:行者123 更新时间:2023-12-02 19:35:47 25 4
gpt4 key购买 nike

我在Bitbucket上设置了CI管道并运行

sbt "project api" "testOnly core.entities.UserSpec"

它可以在我的笔记本电脑上顺利运行,耗时约2秒钟。但是,当我尝试在CI服务器上运行它时,大约需要4分钟才能运行一半的测试。

UserSpec是用Spec2编写的,它没有任何数据库或繁重的计算。这是大多数测试的样子:
def addCredential_nonConfirmedEmail_notAllowed = {
val emailAddress: EmailAddress = Fixture.emailAddress("unconfirmed")
val user: User = Fixture.user().copy(emailAddresses = Set(emailAddress))
val result = user.addCredential(emailAddress, Fixture.password())

val exception = result.failed.get.asInstanceOf[DomainException]
exception.code mustEqual DomainExceptionType.Validation
exception.message mustEqual "Email address must be confirmed before it can be used as part of credential"
}

CI使用“bigtruedata / sbt:0.13.15-2.11.11”镜像在docker上运行。
为了解决这个问题,我用墙砸了两天。首先,我指责CI并尝试使用:
  • gitlab ci
  • 巫师

  • 仍然没有运气。

    你能帮我这个忙吗?这是我的sbt设置的样子
    val projectSettings = Seq(
    version := "1.0-SNAPSHOT",
    scalaVersion := "2.11.11",
    resolvers ++= Dependencies.resolvers,
    fork in Test := false,
    parallelExecution in Test := false)

    最佳答案

    终于,我找到了罪魁祸首!是我,不是CI,docker或SBT。

    我在测试中有Fixture.password()方法,该方法使用val salt = BCrypt.gensalt(10, SecureRandom.getInstanceStrong)中的SecureRandom.getInstanceStrong。如果根据this reference没有足够的随机性,它将阻塞线程。删除SecureRandom.getInstanceStrong后,它现在照常工作。

    在使用它之前,我应该已经了解了Random和SecureRandom之间的区别,并因此浪费了3天。艰苦学习:-D

    关于docker - SBT测试在CI服务器上的运行速度非常慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45316456/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com