Fix flaky ApiConfigManagementServiceSpec test (#10922)

* Fix flaky ApiConfigManagementServiceSpec test.

CHANGELOG_BEGIN
CHANGELOG_END

* format code
This commit is contained in:
mziolekda 2021-09-17 08:49:35 +02:00 committed by GitHub
parent 50291ed61b
commit d01f8e1c35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,7 +38,8 @@ import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AsyncWordSpec
import scala.collection.immutable
import scala.concurrent.Future
import scala.concurrent.{Await, Future, Promise}
import scala.concurrent.duration.{Duration => ScalaDuration}
import scala.util.{Failure, Success}
class ApiConfigManagementServiceSpec
@ -321,16 +322,19 @@ object ApiConfigManagementServiceSpec {
val currentConfiguration =
new AtomicReference[Option[(LedgerOffset.Absolute, Configuration)]](None)
val indexService = new IndexConfigManagementService {
val indexService: IndexConfigManagementService = new IndexConfigManagementService {
private val atLeastOneConfig = Promise[Unit]()
private val source = configurationSource
.map { case (offset, submissionId, configuration) =>
val ledgerOffset =
LedgerOffset.Absolute(Ref.LedgerString.assertFromString(offset.toString))
currentConfiguration.set(Some(ledgerOffset -> configuration))
atLeastOneConfig.trySuccess(())
val entry = ConfigurationEntry.Accepted(submissionId, configuration)
ledgerOffset -> entry
}
.preMaterialize()
Await.result(atLeastOneConfig.future, ScalaDuration.Inf)
override def lookupConfiguration()(implicit
loggingContext: LoggingContext