cassandra com.datastax.driver.core.controlconnection$1 onconnectionexception异常

doinxwow  于 2021-06-14  发布在  Cassandra
关注(0)|答案(0)|浏览(264)

我正在使用cassandra 3.11.3和lagom 1.4.7。我为impl编写了集成测试用例,但面临controlconnection异常。以下是测试文件:

class BookingServiceImplIntegrationTest extends AsyncWordSpec with Matchers with BeforeAndAfterAll {

  private val server = ServiceTest.startServer(ServiceTest.defaultSetup.withCassandra(true)) { ctx =>
    new BookingApplication(ctx) with LocalServiceLocator {
      override def additionalConfiguration: AdditionalConfiguration =
        super.additionalConfiguration ++ Configuration.from(Map(
          "cassandra-query-journal.eventual-consistency-delay" -> "0"
        ))
    }
  }

  val bookingService: BookingService = server.serviceClient.implement[BookingService]

  import server.materializer

  override def afterAll: Unit = server.stop()

  "The Booking service" should {

    "allow add bookings" in {
      for {
        created <- addBooking(BookingDetails)
        retrieved <- retrieveBookings(created)
      } yield {
        created should ===(retrieved)
      }
    }
  }

  def awaitSuccess[T](maxDuration: FiniteDuration = 10.seconds, checkEvery: FiniteDuration = 100.milliseconds)(block: => Future[T]): Future[T] = {
    val checkUntil = System.currentTimeMillis() + maxDuration.toMillis

    def doCheck(): Future[T] = {
      block.recoverWith {
        case recheck if checkUntil > System.currentTimeMillis() =>
          val timeout = Promise[T]()
          server.application.actorSystem.scheduler.scheduleOnce(checkEvery) {
            timeout.completeWith(doCheck())
          }(server.executionContext)
          timeout.future
      }
    }

    doCheck()
  }

运行此测试文件时遇到异常:

请建议如何解决!!提前谢谢

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题