Skip to content

Commit

Permalink
Allocate parties sequentially in script export tests (#11389)
Browse files Browse the repository at this point in the history
* Allocate parties sequentially in script export tests

We’ve seen a few timeouts so this seems at least worth a try.

changelog_begin
changelog_end

* Extend logging to ease debugging

changelog_begin
changelog_end
  • Loading branch information
cocreature committed Oct 26, 2021
1 parent 1309c2f commit 8d17882
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
Expand Up @@ -16,6 +16,7 @@ da_scala_library(
"//ledger/test-common:dar-files",
],
scala_deps = [
"@maven//:com_typesafe_scala_logging_scala_logging",
"@maven//:com_typesafe_akka_akka_actor",
"@maven//:com_typesafe_akka_akka_stream",
"@maven//:io_spray_spray_json",
Expand Down Expand Up @@ -58,6 +59,7 @@ da_scala_library(
da_scala_test_suite(
name = "reproduces-transactions",
srcs = glob(["test-suite/scala/com/daml/script/export/*.scala"]),
resources = ["test-suite/resources/logback-test.xml"],
scala_deps = [
"@maven//:com_typesafe_akka_akka_actor",
"@maven//:com_typesafe_akka_akka_stream",
Expand All @@ -66,6 +68,7 @@ da_scala_test_suite(
"@maven//:org_scalatest_scalatest_freespec",
"@maven//:org_scalatest_scalatest_matchers_core",
"@maven//:org_scalatest_scalatest_shouldmatchers",
"@maven//:com_typesafe_scala_logging_scala_logging",
"@maven//:org_scalaz_scalaz_core",
],
deps = [
Expand Down
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%replace(, context: %marker){', context: $', ''}%n</pattern>
</encoder>
</appender>

<logger name="io.grpc.netty" level="WARN" />
<logger name="metrics" level="INFO" />

<root level="DEBUG">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
Expand Up @@ -34,10 +34,8 @@ import com.daml.SdkVersion
import com.daml.fs.Utils.deleteRecursively
import com.daml.ledger.api.tls.TlsConfiguration
import com.daml.lf.engine.script.ledgerinteraction.{GrpcLedgerClient, ScriptTimeMode}
import com.typesafe.scalalogging.StrictLogging
import scalaz.syntax.tag._
import scalaz.std.scalaFuture._
import scalaz.std.list._
import scalaz.syntax.traverse._
import spray.json._

import scala.concurrent.Future
Expand All @@ -53,7 +51,9 @@ trait ReproducesTransactions
with BeforeAndAfterEach
with SuiteResourceManagementAroundAll
with SandboxNextFixture
with StrictLogging
with TestCommands {

private val appId = domain.ApplicationId("script-export")
private val clientConfiguration = LedgerClientConfiguration(
applicationId = appId.unwrap,
Expand Down Expand Up @@ -106,9 +106,19 @@ trait ReproducesTransactions
.runWith(Sink.seq)

private def allocateParties(client: LedgerClient, numParties: Int): Future[List[Ref.Party]] =
List
.range(0, numParties)
.traverse(_ => client.partyManagementClient.allocateParty(None, None).map(_.party))
for {
_ <- Future { logger.debug("Allocating parties") }
ps <- List
.range(0, numParties)
// Allocate parties sequentially to avoid timeouts on CI.
.foldLeft[Future[List[Ref.Party]]](Future.successful(Nil)) { case (acc, _) =>
for {
ps <- acc
p <- client.partyManagementClient.allocateParty(None, None).map(_.party)
} yield ps :+ p
}
_ = logger.debug("Allocated parties")
} yield ps

private val ledgerBegin = LedgerOffset(
LedgerOffset.Value.Boundary(LedgerOffset.LedgerBoundary.LEDGER_BEGIN)
Expand Down Expand Up @@ -215,6 +225,9 @@ trait ReproducesTransactions
private def testIou: (LedgerClient, Seq[Ref.Party]) => Future[Unit] = {
case (client, Seq(p1, p2)) =>
for {
_ <- Future {
logger.debug("Starting testIou")
}
t0 <- submit(
client,
p1,
Expand Down

0 comments on commit 8d17882

Please sign in to comment.