Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ledger API: Add healthcheck endpoints. #3573

Merged
merged 25 commits into from
Nov 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
62784ca
ledger: Delete ledger/API.md.
SamirTalwar Nov 19, 2019
5cd1d2a
grpc-definitions: Delete health_service.proto
SamirTalwar Nov 19, 2019
f5d33dd
sandbox: Fix warnings in ApiServices flagged by IntelliJ.
SamirTalwar Nov 19, 2019
2a74761
sandbox: Implement a dummy grpc.health.v1.Health.Check endpoint.
SamirTalwar Nov 19, 2019
105f5da
sandbox: Implement a dummy grpc.health.v1.Health.Watch endpoint.
SamirTalwar Nov 19, 2019
3f5cfd7
sandbox: Drop repeated elements from grpc.health.v1.Health.Watch.
SamirTalwar Nov 20, 2019
b00dbf5
sandbox: Wrap the HealthService in basic tests.
SamirTalwar Nov 20, 2019
3cc71be
sandbox: Stop streaming the server health too.
SamirTalwar Nov 20, 2019
2b9d8df
ledger-api-test-tool: Health check tests.
SamirTalwar Nov 21, 2019
c5fea5d
Add a changelog entry for the health check endpoints.
SamirTalwar Nov 21, 2019
6bd46e6
ledger-api-integration-tests: Increment the number of services.
SamirTalwar Nov 21, 2019
0533fc9
Apply suggestions from code review
SamirTalwar Nov 21, 2019
90bfb63
sandbox: Use `AkkaBeforeAndAfterAll` in the HealthServiceSpec.
SamirTalwar Nov 21, 2019
f296630
sandbox: Change `dropRepeated` to `DropRepeated()`.
SamirTalwar Nov 21, 2019
f202dc2
test-common: Use `Delayed.by` in `TimeBoundObserver`.
SamirTalwar Nov 21, 2019
594c34d
test-common: Close the source when `TimeBoundObserver` completes.
SamirTalwar Nov 21, 2019
a3fc679
Merge branch 'master' into ledger/sandbox/healthchecks
SamirTalwar Nov 21, 2019
ba65e23
./fmt.sh
SamirTalwar Nov 21, 2019
bcfd74b
sandbox: Inline `HealthService.suppress`.
SamirTalwar Nov 21, 2019
5c86af6
sandbox: Increase the timeout for HealthServiceSpec.
SamirTalwar Nov 21, 2019
2b8c879
sandbox: Reimplement HealthService using the Scala protobuf types.
SamirTalwar Nov 21, 2019
4447076
sandbox: Generate an Akka-compatible trait for the health service.
SamirTalwar Nov 22, 2019
a0df5d9
ledger-api-common: Move the HealthService here.
SamirTalwar Nov 22, 2019
8658fda
rs-grpc-testing-utils: Publish to Maven.
SamirTalwar Nov 22, 2019
4848f40
rs-grpc-testing-utils: Add Maven coordinates.
SamirTalwar Nov 22, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ledger-api-common: Move the HealthService here.
  • Loading branch information
SamirTalwar committed Nov 22, 2019
commit a0df5d9ee453064f509ce2a8dbe61c28a41cff2f
5 changes: 4 additions & 1 deletion ledger/ledger-api-common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ testDependencies = [
"//daml-lf/language",
"//daml-lf/parser",
"//language-support/scala/bindings",
"//ledger-api/testing-utils",
"//ledger/ledger-api-akka",
"//ledger-api/rs-grpc-bridge",
"//ledger-api/rs-grpc-akka",
"//ledger-api/rs-grpc-testing-utils",
"//ledger-api/testing-utils",
"//ledger/ledger-api-domain:ledger-api-domain",
"//ledger/participant-state",
"//daml-lf/archive:daml_lf_archive_reader",
Expand All @@ -73,6 +75,7 @@ testDependencies = [
"@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",
"@maven//:com_typesafe_akka_akka_testkit_2_12",
"@maven//:com_typesafe_scala_logging_scala_logging_2_12",
"@maven//:org_reactivestreams_reactive_streams",
"@maven//:org_scalactic_scalactic_2_12",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2019 The DAML Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package com.digitalasset.platform.sandbox.health
package com.digitalasset.platform.server.api

import akka.stream.stage.{GraphStage, GraphStageLogic, InHandler, OutHandler}
import akka.stream.{Attributes, FlowShape, Inlet, Outlet}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// Copyright (c) 2019 The DAML Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package com.digitalasset.platform.sandbox.health
package com.digitalasset.platform.server.api.services.grpc

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.platform.api.grpc.GrpcApiService
import com.digitalasset.platform.server.api.DropRepeated
import io.grpc.ServerServiceDefinition
import io.grpc.health.v1.health.{
HealthAkkaGrpc,
Expand All @@ -20,7 +21,7 @@ import io.grpc.health.v1.health.{
import scala.concurrent.duration.DurationInt
import scala.concurrent.{ExecutionContext, Future}

class HealthService(
class GrpcHealthService(
implicit protected val esf: ExecutionSequencerFactory,
protected val mat: Materializer,
executionContext: ExecutionContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2019 The DAML Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package com.digitalasset.platform.sandbox.health
package com.digitalasset.platform.server.api

import akka.actor.ActorSystem
import akka.pattern.pipe
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
// Copyright (c) 2019 The DAML Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package com.digitalasset.platform.sandbox.health
package com.digitalasset.platform.server.api.services.grpc

import com.digitalasset.grpc.adapter.server.rs.MockServerCallStreamObserver
import com.digitalasset.ledger.api.testing.utils.AkkaBeforeAndAfterAll
import com.digitalasset.platform.sandbox.health.HealthServiceSpec._
import com.digitalasset.platform.server.api.services.grpc.GrpcHealthServiceSpec._
import io.grpc.health.v1.health.{HealthCheckRequest, HealthCheckResponse}
import org.scalatest.concurrent.Eventually
import org.scalatest.time.{Second, Span}
import org.scalatest.{Matchers, WordSpec}

import scala.concurrent.{Await, ExecutionContext}

object HealthServiceSpec {
object GrpcHealthServiceSpec {
private val request = HealthCheckRequest()

private val servingResponse = HealthCheckResponse(HealthCheckResponse.ServingStatus.SERVING)
}

final class HealthServiceSpec
final class GrpcHealthServiceSpec
extends WordSpec
with Matchers
with Eventually
Expand All @@ -32,7 +32,7 @@ final class HealthServiceSpec

"HealthService" should {
"check the current health" in {
val service = new HealthService()
val service = new GrpcHealthService()

val response = Await.result(service.check(request), patienceConfig.timeout)

Expand All @@ -41,7 +41,7 @@ final class HealthServiceSpec

"observe changes in health" in {
val responseObserver = new MockServerCallStreamObserver[HealthCheckResponse]
val service = new HealthService()
val service = new GrpcHealthService()

service.watch(request, responseObserver)
responseObserver.demandResponse()
Expand Down
2 changes: 0 additions & 2 deletions ledger/sandbox/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ compileDependencies = [
"//language-support/scala/bindings",
"//ledger-api/rs-grpc-akka",
"//ledger-api/rs-grpc-bridge",
"//ledger-api/rs-grpc-testing-utils",
"//ledger-service/jwt",
"//ledger/ledger-api-akka",
"//ledger/ledger-api-auth",
Expand Down Expand Up @@ -176,7 +175,6 @@ testDependencies = [
"//ledger/ledger-api-common:ledger-api-common-scala-tests-lib",
"//ledger/test-common:test-common",
"//ledger-api/testing-utils",
"@maven//:com_typesafe_akka_akka_testkit_2_12",
"@maven//:commons_io_commons_io",
"@maven//:org_awaitility_awaitility",
"@maven//:org_mockito_mockito_core",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import com.digitalasset.ledger.api.v1.command_completion_service.CompletionEndRe
import com.digitalasset.ledger.client.services.commands.CommandSubmissionFlow
import com.digitalasset.platform.common.logging.NamedLoggerFactory
import com.digitalasset.platform.sandbox.config.CommandConfiguration
import com.digitalasset.platform.sandbox.health.HealthService
import com.digitalasset.platform.sandbox.services._
import com.digitalasset.platform.sandbox.services.admin.{
ApiPackageManagementService,
ApiPartyManagementService
}
import com.digitalasset.platform.sandbox.services.transaction.ApiTransactionService
import com.digitalasset.platform.sandbox.stores.ledger.CommandExecutorImpl
import com.digitalasset.platform.server.api.services.grpc.GrpcHealthService
import com.digitalasset.platform.server.services.command.ApiCommandService
import com.digitalasset.platform.server.services.identity.ApiLedgerIdentityService
import com.digitalasset.platform.server.services.testing.{ApiTimeService, TimeServiceBackend}
Expand Down Expand Up @@ -162,7 +162,7 @@ object ApiServices {

val apiReflectionService = ProtoReflectionService.newInstance()

val apiHealthService = new HealthService
val apiHealthService = new GrpcHealthService

// Note: the command service uses the command submission, command completion, and transaction services internally.
// These connections do not use authorization, authorization wrappers are only added here to all exposed services.
Expand Down