mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-19 16:57:40 +03:00
[ledger-api-test-tool] - Add ability to disable tests based on ledger features [kvl-1218] (#12185)
changelog_begin changelog_end
This commit is contained in:
parent
2a71b69cef
commit
453fd64d05
@ -4,7 +4,7 @@
|
||||
package com.daml.ledger.api.testtool.infrastructure
|
||||
|
||||
import com.daml.ledger.api.testtool.infrastructure.Allocation.{ParticipantAllocation, Participants}
|
||||
import com.daml.ledger.api.testtool.infrastructure.participant.ParticipantTestContext
|
||||
import com.daml.ledger.api.testtool.infrastructure.participant.{Features, ParticipantTestContext}
|
||||
import com.daml.lf.data.Ref
|
||||
|
||||
import scala.concurrent.{ExecutionContext, Future}
|
||||
@ -24,6 +24,8 @@ sealed class LedgerTestCase(
|
||||
val timeoutScale: Double,
|
||||
val runConcurrently: Boolean,
|
||||
val repeated: Int = 1,
|
||||
val enabled: Features => Boolean,
|
||||
val disabledReason: String,
|
||||
participants: ParticipantAllocation,
|
||||
runTestCase: ExecutionContext => Seq[ParticipantTestContext] => Participants => Future[Unit],
|
||||
) {
|
||||
|
@ -3,12 +3,14 @@
|
||||
|
||||
package com.daml.ledger.api.testtool.infrastructure
|
||||
|
||||
import java.util.concurrent.{ExecutionException, TimeoutException}
|
||||
import java.util.{Timer, TimerTask}
|
||||
|
||||
import akka.actor.ActorSystem
|
||||
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.PartyAllocationConfiguration.ClosedWorldWaitingForAllParticipants
|
||||
import com.daml.ledger.api.testtool.infrastructure.Result
|
||||
import com.daml.ledger.api.testtool.infrastructure.participant.{
|
||||
ParticipantSession,
|
||||
ParticipantTestContext,
|
||||
@ -17,8 +19,6 @@ import com.daml.ledger.api.tls.TlsConfiguration
|
||||
import io.grpc.ClientInterceptor
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
import java.util.concurrent.{ExecutionException, TimeoutException}
|
||||
import java.util.{Timer, TimerTask}
|
||||
import scala.concurrent.duration.{Duration, DurationInt}
|
||||
import scala.concurrent.{ExecutionContext, Future, Promise}
|
||||
import scala.util.Try
|
||||
@ -202,9 +202,23 @@ final class LedgerTestCasesRunner(
|
||||
materializer: Materializer,
|
||||
executionContext: ExecutionContext,
|
||||
): Future[Vector[LedgerTestSummary]] = {
|
||||
val (concurrentTestCases, sequentialTestCases) = testCases.partition(_.runConcurrently)
|
||||
ParticipantSession(partyAllocation, participants, maxConnectionAttempts, commandInterceptors)
|
||||
.flatMap { sessions: Vector[ParticipantSession] =>
|
||||
// All the participants should support the same features (for testing at least)
|
||||
val ledgerFeatures = sessions.head.features
|
||||
val (enabledTestCases, disabledTestCases) = testCases
|
||||
.partition(_.enabled(ledgerFeatures))
|
||||
val excludedTestResults = disabledTestCases
|
||||
.map(testCase =>
|
||||
LedgerTestSummary(
|
||||
testCase.suite.name,
|
||||
testCase.name,
|
||||
testCase.description,
|
||||
Right(Result.Excluded(testCase.disabledReason)),
|
||||
)
|
||||
)
|
||||
val (concurrentTestCases, sequentialTestCases) =
|
||||
enabledTestCases.partition(_.runConcurrently)
|
||||
val ledgerSession = LedgerSession(
|
||||
sessions,
|
||||
shuffleParticipants,
|
||||
@ -223,7 +237,7 @@ final class LedgerTestCasesRunner(
|
||||
sequentialTestCases,
|
||||
concurrency = 1,
|
||||
)(materializer, materializer.executionContext)
|
||||
} yield concurrentTestResults ++ sequentialTestResults
|
||||
} yield concurrentTestResults ++ sequentialTestResults ++ excludedTestResults
|
||||
|
||||
testResults.recover {
|
||||
case NonFatal(e) if !e.isInstanceOf[Errors.FrameworkException] =>
|
||||
|
@ -4,7 +4,7 @@
|
||||
package com.daml.ledger.api.testtool.infrastructure
|
||||
|
||||
import com.daml.ledger.api.testtool.infrastructure.Allocation.{ParticipantAllocation, Participants}
|
||||
import com.daml.ledger.api.testtool.infrastructure.participant.ParticipantTestContext
|
||||
import com.daml.ledger.api.testtool.infrastructure.participant.{Features, ParticipantTestContext}
|
||||
import com.daml.lf.data.Ref
|
||||
|
||||
import scala.collection.mutable.ListBuffer
|
||||
@ -22,6 +22,8 @@ private[testtool] abstract class LedgerTestSuite {
|
||||
timeoutScale: Double = 1.0,
|
||||
runConcurrently: Boolean = true,
|
||||
repeated: Int = 1,
|
||||
enabled: Features => Boolean = _ => true,
|
||||
disabledReason: String = "No reason",
|
||||
)(testCase: ExecutionContext => PartialFunction[Participants, Future[Unit]]): Unit = {
|
||||
testGivenAllParticipants(
|
||||
shortIdentifier,
|
||||
@ -30,6 +32,8 @@ private[testtool] abstract class LedgerTestSuite {
|
||||
timeoutScale,
|
||||
runConcurrently,
|
||||
repeated,
|
||||
enabled,
|
||||
disabledReason,
|
||||
)((ec: ExecutionContext) => (_: Seq[ParticipantTestContext]) => testCase(ec))
|
||||
}
|
||||
|
||||
@ -40,6 +44,8 @@ private[testtool] abstract class LedgerTestSuite {
|
||||
timeoutScale: Double = 1.0,
|
||||
runConcurrently: Boolean = true,
|
||||
repeated: Int = 1,
|
||||
enabled: Features => Boolean = _ => true,
|
||||
disabledReason: String = "No reason",
|
||||
)(
|
||||
testCase: ExecutionContext => Seq[ParticipantTestContext] => PartialFunction[
|
||||
Participants,
|
||||
@ -55,6 +61,8 @@ private[testtool] abstract class LedgerTestSuite {
|
||||
timeoutScale,
|
||||
runConcurrently,
|
||||
repeated,
|
||||
enabled,
|
||||
disabledReason,
|
||||
participants,
|
||||
testCase,
|
||||
)
|
||||
|
@ -13,7 +13,6 @@ import com.daml.ledger.api.testtool.infrastructure.{
|
||||
Identification,
|
||||
LedgerServices,
|
||||
PartyAllocationConfiguration,
|
||||
Result,
|
||||
}
|
||||
import com.daml.ledger.api.tls.TlsConfiguration
|
||||
import com.daml.ledger.api.v1.active_contracts_service.{
|
||||
@ -143,10 +142,6 @@ private[testtool] final class ParticipantTestContext private[participant] (
|
||||
|
||||
override def toString: String = s"participant $endpointId"
|
||||
|
||||
/** Skips test if user management feature is not supported */
|
||||
def mustSupportUserManagement(): Unit =
|
||||
if (!features.userManagement) throw Result.Excluded("requires user management feature")
|
||||
|
||||
/** Gets the absolute offset of the ledger end at a point in time. Use [[end]] if you need
|
||||
* a reference to the moving end of the ledger.
|
||||
*/
|
||||
|
@ -41,9 +41,9 @@ final class UserManagementServiceIT extends LedgerTestSuite {
|
||||
"UserManagementCreateUserInvalidArguments",
|
||||
"Test argument validation for UserManagement#CreateUser",
|
||||
allocate(NoParties),
|
||||
enabled = _.userManagement,
|
||||
disabledReason = "requires user management feature",
|
||||
)(implicit ec => { case Participants(Participant(ledger)) =>
|
||||
ledger.mustSupportUserManagement()
|
||||
|
||||
val userId = UUID.randomUUID.toString
|
||||
|
||||
def createAndCheck(
|
||||
@ -91,9 +91,9 @@ final class UserManagementServiceIT extends LedgerTestSuite {
|
||||
"UserManagementGetUserInvalidArguments",
|
||||
"Test argument validation for UserManagement#GetUser",
|
||||
allocate(NoParties),
|
||||
enabled = _.userManagement,
|
||||
disabledReason = "requires user management feature",
|
||||
)(implicit ec => { case Participants(Participant(ledger)) =>
|
||||
ledger.mustSupportUserManagement()
|
||||
|
||||
def getAndCheck(problem: String, userId: String, errorCode: ErrorCode): Future[Unit] =
|
||||
for {
|
||||
error <- ledger.userManagement
|
||||
@ -111,9 +111,9 @@ final class UserManagementServiceIT extends LedgerTestSuite {
|
||||
"TestAllUserManagementRpcs",
|
||||
"Exercise every rpc once with success and once with a failure",
|
||||
allocate(NoParties),
|
||||
enabled = _.userManagement,
|
||||
disabledReason = "requires user management feature",
|
||||
)(implicit ec => { case Participants(Participant(ledger)) =>
|
||||
ledger.mustSupportUserManagement()
|
||||
|
||||
for {
|
||||
// TODO: actually exercise all RPCs
|
||||
createResult <- ledger.userManagement.createUser(CreateUserRequest(Some(User("a", "b")), Nil))
|
||||
|
Loading…
Reference in New Issue
Block a user