mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
ledger-api-test-tool cmd line option to skip dar upload (#7732)
CHANGELOG_BEGIN - [ledger-api-test-tool] Introduced new cmd line argument skip-dal-upload see `docs <https://docs.daml.com/tools/ledger-api-test-tool/index.html>`__. CHANGELOG_END
This commit is contained in:
parent
92020aa868
commit
0de3b5a6bf
@ -69,6 +69,7 @@ Use the following command line flags to select which tests to run:
|
||||
- ``--include``: only run the tests that match the argument
|
||||
- ``--exclude``: do not run the tests that match the argument
|
||||
- ``--perf-tests``: list performance tests to run; cannot be combined with normal tests
|
||||
- ``--skip-dar-upload``: skip upload of DAR files into ledger. DAR files should be uploaded manually before the tests.
|
||||
|
||||
Include and exclude are matched as prefixes, e.g. ``--exclude=SemanticTests``
|
||||
will exclude all tests whose name starts with ``SemanticTests``. Test names
|
||||
|
@ -202,6 +202,11 @@ object Cli {
|
||||
.action((interval, c) => c.copy(ledgerClockGranularityMs = interval))
|
||||
.text("Specify the largest interval in ms that you will see between clock ticks on the ledger under test. The default is 10000ms")
|
||||
|
||||
opt[Unit]("skip-dar-upload")
|
||||
.optional()
|
||||
.action((_, c) => c.copy(uploadDars = false))
|
||||
.text("Skip DARs upload into ledger before running tests")
|
||||
|
||||
help("help").text("Prints this usage text")
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ final case class Config(
|
||||
shuffleParticipants: Boolean,
|
||||
partyAllocation: PartyAllocationConfiguration,
|
||||
ledgerClockGranularityMs: Int,
|
||||
uploadDars: Boolean,
|
||||
)
|
||||
|
||||
object Config {
|
||||
@ -48,5 +49,6 @@ object Config {
|
||||
shuffleParticipants = false,
|
||||
partyAllocation = PartyAllocationConfiguration.ClosedWorldWaitingForAllParticipants,
|
||||
ledgerClockGranularityMs = 10000,
|
||||
uploadDars = true,
|
||||
)
|
||||
}
|
||||
|
@ -187,5 +187,6 @@ object LedgerApiTestTool {
|
||||
identifierSuffix,
|
||||
config.timeoutScaleFactor,
|
||||
concurrencyOverride.getOrElse(config.concurrentTestRuns),
|
||||
uploadDars = config.uploadDars,
|
||||
)
|
||||
}
|
||||
|
@ -11,7 +11,10 @@ import akka.stream.Materializer
|
||||
import akka.stream.scaladsl.{Sink, Source}
|
||||
import com.daml.ledger.api.testtool.infrastructure.LedgerTestCasesRunner._
|
||||
import com.daml.ledger.api.testtool.infrastructure.Result.Retired
|
||||
import com.daml.ledger.api.testtool.infrastructure.participant.ParticipantSessionManager
|
||||
import com.daml.ledger.api.testtool.infrastructure.participant.{
|
||||
ParticipantSessionManager,
|
||||
ParticipantTestContext
|
||||
}
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
import scala.concurrent.duration.{Duration, DurationInt}
|
||||
@ -39,6 +42,7 @@ final class LedgerTestCasesRunner(
|
||||
identifierSuffix: String,
|
||||
suiteTimeoutScale: Double,
|
||||
concurrentTestRuns: Int,
|
||||
uploadDars: Boolean,
|
||||
) {
|
||||
private[this] val verifyRequirements: Try[Unit] =
|
||||
Try {
|
||||
@ -112,28 +116,34 @@ final class LedgerTestCasesRunner(
|
||||
): Future[Either[Result.Failure, Result.Success]] =
|
||||
result(start(test, session))
|
||||
|
||||
private def uploadDarsIfRequired(participantSessionManager: ParticipantSessionManager)(
|
||||
implicit ec: ExecutionContext): Future[Unit] =
|
||||
if (uploadDars) {
|
||||
def uploadDar(context: ParticipantTestContext, name: String): Future[Unit] = {
|
||||
logger.info(s"""Uploading DAR "$name"...""")
|
||||
context.uploadDarFile(Dars.read(name)).andThen {
|
||||
case _ => logger.info(s"""Uploaded DAR "$name".""")
|
||||
}
|
||||
}
|
||||
|
||||
Future
|
||||
.sequence(participantSessionManager.allSessions.map { session =>
|
||||
for {
|
||||
context <- session.createInitContext("upload-dars", identifierSuffix)
|
||||
_ <- Future.sequence(Dars.resources.map(uploadDar(context, _)))
|
||||
} yield ()
|
||||
})
|
||||
.map(_ => ())
|
||||
} else {
|
||||
Future.successful(logger.info("DAR files upload skipped."))
|
||||
}
|
||||
|
||||
private def run(completionCallback: Try[Vector[LedgerTestSummary]] => Unit): Unit = {
|
||||
|
||||
val system: ActorSystem = ActorSystem(classOf[LedgerTestCasesRunner].getSimpleName)
|
||||
implicit val materializer: Materializer = Materializer(system)
|
||||
implicit val executionContext: ExecutionContext = materializer.executionContext
|
||||
|
||||
def uploadDars(participantSessionManager: ParticipantSessionManager): Future[Unit] =
|
||||
Future
|
||||
.sequence(participantSessionManager.allSessions.map { session =>
|
||||
for {
|
||||
context <- session.createInitContext("upload-dars", identifierSuffix)
|
||||
_ <- Future.sequence(Dars.resources.map { name =>
|
||||
logger.info("Uploading DAR \"{}\"...", name)
|
||||
context.uploadDarFile(Dars.read(name)).andThen {
|
||||
case _ =>
|
||||
logger.info("Uploaded DAR \"{}\".", name)
|
||||
}
|
||||
})
|
||||
} yield ()
|
||||
})
|
||||
.map(_ => ())
|
||||
|
||||
def runTestCases(
|
||||
ledgerSession: LedgerSession,
|
||||
testCases: Vector[LedgerTestCase],
|
||||
@ -156,7 +166,7 @@ final class LedgerTestCasesRunner(
|
||||
val ledgerSession = LedgerSession(participantSessionManager, config.shuffleParticipants)
|
||||
val testResults =
|
||||
for {
|
||||
_ <- uploadDars(participantSessionManager)
|
||||
_ <- uploadDarsIfRequired(participantSessionManager)
|
||||
concurrentTestResults <- runTestCases(
|
||||
ledgerSession,
|
||||
concurrentTestCases,
|
||||
|
Loading…
Reference in New Issue
Block a user