Skip to content

Commit

Permalink
Moves CommandCompletionIT to Ledger API Test Tool (digital-asset#3901)
Browse files Browse the repository at this point in the history
* Moves CommandCompletionIT to Ledger API Test Tool

Closes digital-asset#2841

Also refactors test observers into a single API and unifies the existing implementations of the DirectExecutionContext

* Allow explicit offsets to get checkpoints

* Raise checkpoint test timeout

* Consolidate checkpoint tests in a single test case

* Fix compilation issues

* Exclude command submission/completion tests for rev-v2

* Drop test not relevant for Ledger API implementations

* Fix compilation errors
  • Loading branch information
stefanobaghino-da authored Dec 20, 2019
1 parent 11681c6 commit 7020ed3
Show file tree
Hide file tree
Showing 95 changed files with 282 additions and 511 deletions.
1 change: 1 addition & 0 deletions ledger-api/rs-grpc-akka/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ da_scala_library(
],
deps = [
"//ledger-api/rs-grpc-bridge",
"//libs-scala/direct-execution-context",
"@maven//:com_typesafe_akka_akka_actor_2_12",
"@maven//:com_typesafe_akka_akka_slf4j_2_12",
"@maven//:com_typesafe_akka_akka_stream_2_12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.digitalasset.grpc.adapter.RunnableSequencingActor.ShutdownRequest
import scala.concurrent.duration.FiniteDuration
import scala.concurrent.{ExecutionContext, Future}
import scala.util.control.NonFatal
import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext

/**
* Implements serial execution semantics by forwarding the Runnables it receives to an underlying actor.
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions ledger-api/testing-utils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ da_scala_library(
"//ledger-api/grpc-definitions:ledger-api-scalapb",
"//ledger-api/rs-grpc-akka",
"//ledger-api/rs-grpc-bridge",
"//libs-scala/direct-execution-context",
"//libs-scala/grpc-utils",
"@maven//:com_google_guava_guava",
"@maven//:com_typesafe_akka_akka_actor_2_12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package com.digitalasset.ledger.api.testing.utils

import java.util.concurrent.{Executors, ScheduledExecutorService, TimeUnit}

import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import org.scalatest._
import org.scalatest.concurrent.{AsyncTimeLimitedTests, ScaledTimeSpans}
import org.scalatest.exceptions.TestCanceledException
Expand Down
1 change: 1 addition & 0 deletions ledger/ledger-api-auth/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ledger_api_auth_deps = [
"//ledger/ledger-api-domain",
"//ledger/ledger-api-scala-logging:ledger-api-scala-logging-base",
"//ledger/ledger-api-scala-logging",
"//libs-scala/direct-execution-context",
"@maven//:com_auth0_java_jwt",
"@maven//:com_github_scopt_scopt_2_12",
"@maven//:com_typesafe_akka_akka_actor_2_12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.digitalasset.ledger.api.auth.services

import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.auth.Authorizer
import com.digitalasset.ledger.api.v1.active_contracts_service.ActiveContractsServiceGrpc.ActiveContractsService
import com.digitalasset.ledger.api.v1.active_contracts_service.{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.digitalasset.ledger.api.auth.services

import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.auth.Authorizer
import com.digitalasset.ledger.api.v1.command_completion_service.CommandCompletionServiceGrpc.CommandCompletionService
import com.digitalasset.ledger.api.v1.command_completion_service._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.digitalasset.ledger.api.auth.services

import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.auth.Authorizer
import com.digitalasset.ledger.api.v1.command_service.CommandServiceGrpc.CommandService
import com.digitalasset.ledger.api.v1.command_service._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.digitalasset.ledger.api.auth.services

import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.auth.Authorizer
import com.digitalasset.ledger.api.v1.command_submission_service.CommandSubmissionServiceGrpc.CommandSubmissionService
import com.digitalasset.ledger.api.v1.command_submission_service._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.digitalasset.ledger.api.auth.services

import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.auth.Authorizer
import com.digitalasset.ledger.api.v1.admin.config_management_service.ConfigManagementServiceGrpc.ConfigManagementService
import com.digitalasset.ledger.api.v1.admin.config_management_service._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.digitalasset.ledger.api.auth.services

import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.auth.Authorizer
import com.digitalasset.ledger.api.v1.ledger_configuration_service.LedgerConfigurationServiceGrpc.LedgerConfigurationService
import com.digitalasset.ledger.api.v1.ledger_configuration_service._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.digitalasset.ledger.api.auth.services

import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.auth.Authorizer
import com.digitalasset.ledger.api.v1.ledger_identity_service.{
GetLedgerIdentityRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.digitalasset.ledger.api.auth.services

import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.auth.Authorizer
import com.digitalasset.ledger.api.v1.admin.package_management_service.PackageManagementServiceGrpc.PackageManagementService
import com.digitalasset.ledger.api.v1.admin.package_management_service._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.digitalasset.ledger.api.auth.services

import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.auth.Authorizer
import com.digitalasset.ledger.api.v1.package_service.PackageServiceGrpc.PackageService
import com.digitalasset.ledger.api.v1.package_service._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.digitalasset.ledger.api.auth.services

import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.auth.Authorizer
import com.digitalasset.ledger.api.v1.admin.party_management_service.PartyManagementServiceGrpc.PartyManagementService
import com.digitalasset.ledger.api.v1.admin.party_management_service._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.digitalasset.ledger.api.auth.services

import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.auth.Authorizer
import com.digitalasset.ledger.api.v1.testing.time_service.TimeServiceGrpc.TimeService
import com.digitalasset.ledger.api.v1.testing.time_service._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.digitalasset.ledger.api.auth.services

import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.auth.Authorizer
import com.digitalasset.ledger.api.v1.transaction_service
import com.digitalasset.ledger.api.v1.transaction_service.TransactionServiceGrpc.TransactionService
Expand Down
3 changes: 3 additions & 0 deletions ledger/ledger-api-client/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ da_scala_library(
"//ledger/ledger-api-auth-client",
"//ledger/ledger-api-domain",
"//ledger/participant-state",
"//libs-scala/direct-execution-context",
"//libs-scala/grpc-utils",
"@maven//:com_typesafe_akka_akka_actor_2_12",
"@maven//:com_typesafe_akka_akka_stream_2_12",
Expand All @@ -40,6 +41,7 @@ da_scala_test_suite(
"//ledger-api/rs-grpc-akka",
"//ledger-api/rs-grpc-bridge",
"//ledger-api/testing-utils",
"//libs-scala/direct-execution-context",
"@maven//:com_typesafe_akka_akka_actor_2_12",
"@maven//:com_typesafe_akka_akka_stream_2_12",
"@maven//:com_typesafe_akka_akka_stream_testkit_2_12",
Expand Down Expand Up @@ -69,6 +71,7 @@ da_scala_test_suite(
"//ledger/sandbox",
"//ledger/sandbox:sandbox-scala-tests-lib",
"//ledger/test-common",
"//libs-scala/direct-execution-context",
"@maven//:ch_qos_logback_logback_classic",
"@maven//:com_typesafe_akka_akka_actor_2_12",
"@maven//:com_typesafe_akka_akka_stream_2_12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import com.digitalasset.ledger.client.configuration.CommandClientConfiguration
import com.digitalasset.ledger.client.services.commands.{CommandClient, CompletionStreamElement}
import com.digitalasset.ledger.client.services.testing.time.StaticTime
import com.digitalasset.platform.common.LedgerIdMode
import com.digitalasset.platform.common.util.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.platform.participant.util.ValueConversions._
import com.digitalasset.platform.sandbox.config.SandboxConfig
import com.digitalasset.platform.sandbox.services.{SandboxFixture, TestCommands}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package com.digitalasset.ledger.client.services.commands

import akka.NotUsed
import akka.stream.scaladsl.Flow
import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.v1.command_submission_service.SubmitRequest
import com.digitalasset.util.Ctx
import com.google.protobuf.empty.Empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.digitalasset.ledger.client.services.identity

import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.domain.LedgerId
import com.digitalasset.ledger.api.v1.ledger_identity_service.GetLedgerIdentityRequest
import com.digitalasset.ledger.api.v1.ledger_identity_service.LedgerIdentityServiceGrpc.LedgerIdentityServiceStub
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.digitalasset.api.util.{TimeProvider, TimestampConversion}
import com.digitalasset.api.util.TimestampConversion._
import com.digitalasset.grpc.adapter.ExecutionSequencerFactory
import com.digitalasset.grpc.adapter.client.akka.ClientAdapter
import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.v1.testing.time_service.{GetTimeRequest, SetTimeRequest}
import com.digitalasset.ledger.api.v1.testing.time_service.TimeServiceGrpc.{
TimeService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import akka.stream.testkit.javadsl.TestSink
import akka.stream.testkit.scaladsl.TestSource
import akka.stream.testkit.{TestPublisher, TestSubscriber}
import com.digitalasset.api.util.TimestampConversion._
import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.testing.utils.AkkaBeforeAndAfterAll
import com.digitalasset.ledger.api.v1.command_completion_service.Checkpoint
import com.digitalasset.ledger.api.v1.command_submission_service._
Expand Down
2 changes: 2 additions & 0 deletions ledger/ledger-api-common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ da_scala_library(
"//ledger/ledger-api-scala-logging:ledger-api-scala-logging-base",
"//ledger/participant-state",
"//ledger/participant-state-index",
"//libs-scala/direct-execution-context",
"@maven//:com_github_blemale_scaffeine_2_12",
"@maven//:com_github_ghik_silencer_lib_2_12",
"@maven//:com_google_guava_guava",
Expand Down Expand Up @@ -73,6 +74,7 @@ testDependencies = [
"//ledger/participant-state",
"//daml-lf/archive:daml_lf_archive_reader",
"//ledger/ledger-api-client:ledger-api-client",
"//libs-scala/direct-execution-context",
"//libs-scala/grpc-utils",
"@maven//:org_scalatest_scalatest_2_12",
"@maven//:org_awaitility_awaitility",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import akka.NotUsed
import akka.stream._
import akka.stream.scaladsl.{Source, SourceQueueWithComplete}
import com.digitalasset.platform.akkastreams.dispatcher.SignalDispatcher.Signal
import com.digitalasset.platform.common.util.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import org.slf4j.LoggerFactory

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package com.digitalasset.platform.akkastreams.dispatcher

import akka.NotUsed
import akka.stream.scaladsl.Source
import com.digitalasset.platform.common.util.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext

import scala.concurrent.Future

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.digitalasset.ledger.api.v1.command_completion_service._
import com.digitalasset.ledger.api.v1.completion.Completion
import com.digitalasset.ledger.api.v1.ledger_offset.LedgerOffset
import com.digitalasset.ledger.api.validation.{CompletionServiceRequestValidator, PartyNameChecker}
import com.digitalasset.platform.common.util.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.platform.server.api.services.domain.CommandCompletionService
import com.google.rpc.status.Status
import io.grpc.Status.Code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.digitalasset.ledger.api.v1.command_service.CommandServiceGrpc.Command
import com.digitalasset.ledger.api.v1.command_service._
import com.digitalasset.ledger.api.validation.{CommandsValidator, SubmitAndWaitRequestValidator}
import com.digitalasset.platform.api.grpc.GrpcApiService
import com.digitalasset.platform.common.util.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.platform.server.api.ProxyCloseable
import com.google.protobuf.empty.Empty
import io.grpc.ServerServiceDefinition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import com.digitalasset.ledger.api.v1.command_submission_service.{
}
import com.digitalasset.ledger.api.validation.{CommandsValidator, SubmitRequestValidator}
import com.digitalasset.platform.api.grpc.GrpcApiService
import com.digitalasset.platform.common.util.DirectExecutionContext
import com.digitalasset.platform.common.util.DirectExecutionContext.implicitEC
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.platform.server.api.ProxyCloseable
import com.digitalasset.platform.server.api.services.domain.CommandSubmissionService
import com.google.protobuf.empty.Empty
Expand All @@ -38,7 +37,9 @@ class GrpcCommandSubmissionService(
override def submit(request: ApiSubmitRequest): Future[Empty] =
validator
.validate(request)
.fold(Future.failed, service.submit(_).map(_ => Empty.defaultInstance))
.fold(
Future.failed,
service.submit(_).map(_ => Empty.defaultInstance)(DirectExecutionContext))

override def bindService(): ServerServiceDefinition =
CommandSubmissionServiceGrpc.bindService(this, DirectExecutionContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import akka.NotUsed
import akka.stream.Materializer
import akka.stream.scaladsl.Source
import com.digitalasset.grpc.adapter.ExecutionSequencerFactory
import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.health.HealthChecks
import com.digitalasset.platform.api.grpc.GrpcApiService
import com.digitalasset.platform.server.api.DropRepeated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import com.digitalasset.ledger.api.v1.transaction_service._
import com.digitalasset.ledger.api.validation.TransactionServiceRequestValidator.Result
import com.digitalasset.ledger.api.validation.{PartyNameChecker, TransactionServiceRequestValidator}
import com.digitalasset.platform.api.grpc.GrpcApiService
import com.digitalasset.platform.common.util.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.platform.participant.util.LfEngineToApi
import com.digitalasset.platform.server.api.services.domain.TransactionService
import com.digitalasset.platform.server.api.validation.{ErrorFactories, FieldValidations}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.digitalasset.platform.server.api.validation

import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.domain.LedgerId
import com.digitalasset.ledger.api.v1.active_contracts_service.ActiveContractsServiceGrpc.ActiveContractsService
import com.digitalasset.ledger.api.v1.active_contracts_service.{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.digitalasset.ledger.api.domain.LedgerId
import com.digitalasset.ledger.api.v1.command_completion_service.CommandCompletionServiceGrpc.CommandCompletionService
import com.digitalasset.ledger.api.v1.command_completion_service._
import com.digitalasset.platform.api.grpc.GrpcApiService
import com.digitalasset.platform.common.util.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.platform.server.api.ProxyCloseable
import io.grpc.ServerServiceDefinition
import io.grpc.stub.StreamObserver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.digitalasset.platform.server.api.validation

import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.domain.LedgerId
import com.digitalasset.ledger.api.v1.ledger_configuration_service.LedgerConfigurationServiceGrpc.LedgerConfigurationService
import com.digitalasset.ledger.api.v1.ledger_configuration_service.{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.digitalasset.platform.server.api.validation

import com.digitalasset.grpc.adapter.utils.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.ledger.api.domain.LedgerId
import com.digitalasset.ledger.api.v1.package_service.PackageServiceGrpc.PackageService
import com.digitalasset.ledger.api.v1.package_service._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.digitalasset.ledger.api.v1.command_service.SubmitAndWaitRequest
import com.digitalasset.ledger.api.v1.command_submission_service.SubmitRequest
import com.digitalasset.ledger.api.v1.completion.Completion
import com.digitalasset.ledger.client.services.commands.CommandTrackerFlow.Materialized
import com.digitalasset.platform.common.util.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.platform.server.api.ApiException
import com.digitalasset.util.Ctx
import com.google.rpc.code.Code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.util.concurrent.atomic.AtomicReference
import com.digitalasset.ledger.api.v1.command_service.SubmitAndWaitRequest
import com.digitalasset.ledger.api.v1.completion.Completion
import com.digitalasset.platform.common.logging.NamedLoggerFactory
import com.digitalasset.platform.common.util.DirectExecutionContext
import com.digitalasset.dec.DirectExecutionContext
import com.digitalasset.platform.server.services.command.TrackerMap.{AsyncResource, Key}
import com.github.ghik.silencer.silent

Expand Down
Loading

0 comments on commit 7020ed3

Please sign in to comment.