Skip to content

Commit

Permalink
add support for Canton EE available to JSON API (digital-asset#17034)
Browse files Browse the repository at this point in the history
Co-authored-by: Gary Verhaegen <gary.verhaegen@digitalasset.com>
  • Loading branch information
remyhaemmerle-da and garyverhaegen-da authored Jun 29, 2023
1 parent e09d8e7 commit 9e0493c
Show file tree
Hide file tree
Showing 21 changed files with 196 additions and 110 deletions.
3 changes: 2 additions & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ NOTICES @garyverhaegen-da @dasormeter
/compiler/ @basvangijzel-DA @remyhaemmerle-da @akrmn @dylant-da @samuel-williams-da
/libs-haskell/ @basvangijzel-DA @remyhaemmerle-da @akrmn @dylant-da @samuel-williams-da
/ghc-lib/ @basvangijzel-DA @remyhaemmerle-da @akrmn @dylant-da @samuel-williams-da
/canton/ @garyverhaegen-da @remyhaemmerle-da

# Runtime
/daml-lf/ @remyhaemmerle-da
Expand All @@ -50,7 +51,7 @@ NOTICES @garyverhaegen-da @dasormeter
/ledger-test-tool/ @digital-asset/kv-participant @digital-asset/kv-committer

# Conformance test on canton
/ledger-test-tool/ledger-api-test-tool-on-canton @remyhaemmerle-da @rgugliel-da
/ledger-test-tool/ledger-api-test-tool-on-canton @remyhaemmerle-da @rgugliel-da @digital-asset/kv-participant @digital-asset/kv-committer

# Ecosystems
/language-support/hs/ @nickchapman-da @remyhaemmerle-da
Expand Down
6 changes: 4 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ bazel build //... `
`-`-experimental_profile_include_target_label `
`-`-build_event_json_file build-events.json `
`-`-build_event_publish_all_actions `
`-`-experimental_execution_log_file ${ARTIFACT_DIRS}/logs/build_execution_windows.log
`-`-experimental_execution_log_file ${ARTIFACT_DIRS}/logs/build_execution_windows.log `
`-`-build_tag_filters=-canton-ee

bazel shutdown

Expand All @@ -84,5 +85,6 @@ if ($env:SKIP_TESTS -ceq "False") {
`-`-experimental_profile_include_target_label `
`-`-build_event_json_file test-events.json `
`-`-build_event_publish_all_actions `
`-`-experimental_execution_log_file ${ARTIFACT_DIRS}/logs/test_execution_windows.log
`-`-experimental_execution_log_file ${ARTIFACT_DIRS}/logs/test_execution_windows.log `
`-`-test_tag_filters=-canton-ee
}
21 changes: 14 additions & 7 deletions canton/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ java_import(
visibility = ["//visibility:public"],
)

java_import(
name = "lib-ee",
jars = [":canton-lib-ee.jar"],
tags = ["canton-ee"],
visibility = ["//visibility:public"],
)

genrule(
name = "canton-lib-ee",
# We don't use the else branch but we need a resolvable value
Expand Down Expand Up @@ -113,3 +106,17 @@ cp **/lib/*.jar $@
],
visibility = ["//visibility:public"],
)

java_import(
name = "lib-ee",
jars = [":canton-lib-ee.jar"],
tags = ["canton-ee"],
)

java_binary(
name = "canton-ee",
main_class = "com.digitalasset.canton.CantonEnterpriseApp",
tags = ["canton-ee"],
visibility = ["//ledger-service:__subpackages__"],
runtime_deps = ["//canton:lib-ee"],
)
1 change: 1 addition & 0 deletions canton/it-lib/src/main/com/daml/CantonConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ object CantonConfig {
}

final case class CantonConfig(
jarPath: Path = CantonRunner.cantonPath,
authSecret: Option[String] = None,
devMode: Boolean = false,
nParticipants: Int = 1,
Expand Down
3 changes: 3 additions & 0 deletions canton/it-lib/src/main/com/daml/CantonFixture.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ trait CantonFixtureWithResource[A]
protected lazy val tlsEnable: Boolean = false
protected lazy val enableDisclosedContracts: Boolean = false
protected lazy val applicationId: ApplicationId = ApplicationId(getClass.getName)
protected lazy val cantonJar: Path =
if (devMode) CantonRunner.cantonPath else CantonRunner.cantonPatchPath

// This flag setup some behavior to ease debugging tests.
// If `true`
Expand Down Expand Up @@ -94,6 +96,7 @@ trait CantonFixtureWithResource[A]
}

lazy val config = CantonConfig(
jarPath = cantonJar,
authSecret = authSecret,
devMode = devMode,
nParticipants = nParticipants,
Expand Down
7 changes: 3 additions & 4 deletions canton/it-lib/src/main/com/daml/CantonRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ object CantonRunner {
private[integrationtest] def toJson(s: String): String = JsString(s).toString()
private[integrationtest] def toJson(path: Path): String = toJson(path.toString)

private lazy val cantonPath =
lazy val cantonPath =
Paths.get(rlocation("canton/canton_deploy.jar"))
private lazy val cantonPatchPath =
lazy val cantonPatchPath =
Paths.get(rlocation("canton/canton-patched_deploy.jar"))

case class CantonFiles(
Expand Down Expand Up @@ -64,7 +64,6 @@ object CantonRunner {
Vector.fill(config.nParticipants)(LockedFreePort.find() -> LockedFreePort.find())
val domainPublicApi = LockedFreePort.find()
val domainAdminApi = LockedFreePort.find()
val jarPath = if (config.devMode) cantonPatchPath else cantonPath
val exe = if (sys.props("os.name").toLowerCase.contains("windows")) ".exe" else ""
val java = s"${System.getenv("JAVA_HOME")}/bin/java${exe}"
val (timeType, clockType) = config.timeProviderType match {
Expand Down Expand Up @@ -144,7 +143,7 @@ object CantonRunner {
Process(
java ::
"-jar" ::
jarPath.toString ::
config.jarPath.toString ::
"daemon" ::
"--auto-connect-local" ::
"-c" ::
Expand Down
3 changes: 3 additions & 0 deletions ci/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ jobs:
# Actually run some tests
# Note: Oracle tests all run sequentially because they all access the same Oracle instance,
# and we sometimes observe transient connection issues when running tests in parallel.
export ARTIFACTORY_AUTH=$(echo -n "$ARTIFACTORY_USERNAME:$ARTIFACTORY_PASSWORD" | base64 -w0)
bazel test \
--config=oracle \
--test_strategy=exclusive \
Expand All @@ -262,6 +263,8 @@ jobs:
env:
DOCKER_LOGIN: $(DOCKER_LOGIN)
DOCKER_PASSWORD: $(DOCKER_PASSWORD)
ARTIFACTORY_USERNAME: $(ARTIFACTORY_USERNAME)
ARTIFACTORY_PASSWORD: $(ARTIFACTORY_PASSWORD)
displayName: 'Build'
condition: and(succeeded(), eq(variables['System.PullRequest.IsFork'], 'False'))
Expand Down
7 changes: 5 additions & 2 deletions ledger-service/http-json-oracle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ da_scala_library(
"@maven//:org_scalaz_scalaz_core",
],
scalacopts = hj_scalacopts,
tags = oracle_tags,
tags = oracle_tags + ["canton-ee"],
runtime_deps = [
"@maven//:com_oracle_database_jdbc_ojdbc8",
],
Expand Down Expand Up @@ -90,7 +90,10 @@ da_scala_test_suite(
"@maven//:org_scalaz_scalaz_core",
],
scalacopts = hj_scalacopts,
tags = oracle_tags,
tags = oracle_tags + [
"cpu:6",
"canton-ee",
],
runtime_deps = [
"@maven//:com_oracle_database_jdbc_ojdbc8",
],
Expand Down
3 changes: 2 additions & 1 deletion ledger-service/http-json-perf/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ perf_runtime_deps = {
"@maven//:org_scalaz_scalaz_core",
],
scalacopts = hj_scalacopts,
tags = ["maven_coordinates=com.daml:http-json-perf-{}:__VERSION__".format(edition)],
tags = ["maven_coordinates=com.daml:http-json-perf-{}:__VERSION__".format(edition)] + (["canton-ee"] if edition == "ee" else []),
visibility = ["//visibility:public"],
runtime_deps = [
"@maven//:ch_qos_logback_logback_classic",
Expand Down Expand Up @@ -117,6 +117,7 @@ daml_compile(
"@maven//:org_scalaz_scalaz_core",
],
scalacopts = hj_scalacopts,
tags = ["canton-ee"] if edition == "ee" else [],
visibility = ["//visibility:public"],
runtime_deps = [
"@maven//:ch_qos_logback_logback_classic",
Expand Down
8 changes: 6 additions & 2 deletions ledger-service/http-json-testing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ load("//ledger-service/utils:scalaopts.bzl", "hj_scalacopts")
[
da_scala_library(
name = "{}".format(edition),
srcs = glob(["src/main/scala/**/*.scala"]),
srcs = glob(
["src/main/scala/**/*.scala"],
exclude = ["src/main/scala/**/CE.scala"] if edition == "ee" else ["src/main/scala/**/EE.scala"],
),
data = ["//canton:canton-ee_deploy.jar"] if edition == "ee" else [],
plugins = [
kind_projector_plugin,
],
Expand All @@ -28,7 +32,7 @@ load("//ledger-service/utils:scalaopts.bzl", "hj_scalacopts")
"@maven//:org_typelevel_cats_effect",
],
scalacopts = hj_scalacopts,
tags = ["maven_coordinates=com.daml:http-json-testing:__VERSION__"],
tags = ["maven_coordinates=com.daml:http-json-testing:__VERSION__"] + (["canton-ee"] if edition == "ee" else []),
visibility = ["//visibility:public"],
runtime_deps = [
"@maven//:ch_qos_logback_logback_classic",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) 2023 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package com.daml.http

import com.daml.integrationtest.CantonRunner

import java.nio.file.Path

object Edition {
lazy val cantonJar: Path = CantonRunner.cantonPath
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) 2023 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package com.daml.http

import com.daml.bazeltools.BazelRunfiles.rlocation

import java.nio.file.{Path, Paths}

object Edition {
lazy val cantonJar: Path = Paths.get(rlocation("canton/canton-ee_deploy.jar"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ object HttpServiceTestFixture extends LazyLogging with Assertions with Inside {
implicit val resourceContext: ResourceContext = ResourceContext(ec)
val cantonTmpDir = Files.createTempDirectory("CantonFixture")
val config = CantonConfig(
jarPath = Edition.cantonJar,
authSecret = None,
devMode = false,
nParticipants = 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// Copyright (c) 2023 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package com.daml.http.util
package com.daml.http
package util

import com.daml.http.HttpServiceTestFixture.UseTls
import com.daml.integrationtest.CantonFixture
import com.daml.integrationtest.{CantonFixture}
import com.daml.ledger.api.domain.LedgerId
import com.daml.ledger.client.withoutledgerid.{LedgerClient => DamlLedgerClient}
import com.daml.ports.Port
Expand All @@ -21,6 +22,7 @@ trait SandboxTestLedger extends CantonFixture {

def useTls: UseTls

final override protected lazy val cantonJar = Edition.cantonJar
override lazy protected val darFiles = packageFiles.map(_.toPath)
override lazy protected val tlsEnable = useTls
override lazy protected val enableDisclosedContracts: Boolean = true
Expand Down
12 changes: 11 additions & 1 deletion ledger-service/http-json/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ daml_compile(
"@maven//:org_typelevel_cats_kernel",
],
scalacopts = hj_scalacopts,
tags = ["cpu:6"] + (["canton-ee"] if edition == "ee" else []),
visibility = ["//test-evidence:__pkg__"] if edition == "ce" else None,
deps = [
":http-json-{}".format(edition),
Expand Down Expand Up @@ -326,6 +327,7 @@ alias(
"@maven//:org_typelevel_cats_free",
"@maven//:org_typelevel_cats_kernel",
],
tags = ["canton-ee"] if edition == "ee" else [],
visibility = ["//ledger-service:__subpackages__"],
deps = [
":http-json-{}".format(edition),
Expand Down Expand Up @@ -405,6 +407,7 @@ alias(
"@maven//:org_scalaz_scalaz_core",
],
scalacopts = hj_scalacopts,
tags = ["canton-ee"] if edition == "ee" else [],
visibility = ["//test-evidence:__pkg__"] if edition == "ce" else None,
deps = [
":http-json-{}".format(edition),
Expand Down Expand Up @@ -484,6 +487,7 @@ alias(
"@maven//:org_typelevel_cats_kernel",
],
scalacopts = hj_scalacopts,
tags = ["cpu:6"] + (["canton-ee"] if edition == "ee" else []),
visibility = ["//test-evidence:__pkg__"] if edition == "ce" else None,
deps = [
":http-json-{}".format(edition),
Expand Down Expand Up @@ -537,7 +541,11 @@ test_suite(
[
da_scala_library(
name = "failure-tests-lib-{}".format(edition),
srcs = glob(["src/failurelib/scala/**/*.scala"]),
srcs = glob(
["src/failurelib/scala/**/*.scala"],
exclude = ["src/failurelib/scala/**/CE.scala"] if edition == "ee" else ["src/failurelib/scala/**/EE.scala"],
),
data = ["//canton:canton-ee_deploy.jar"] if edition == "ee" else [],
plugins = [
kind_projector_plugin,
],
Expand All @@ -556,6 +564,7 @@ test_suite(
"@maven//:org_typelevel_cats_effect",
],
scalacopts = hj_scalacopts,
tags = ["canton-ee"] if edition == "ee" else [],
visibility = ["//test-evidence:__pkg__"] if edition == "ce" else None,
deps = [
":http-json-{}".format(edition),
Expand Down Expand Up @@ -622,6 +631,7 @@ test_suite(
"@maven//:org_scalaz_scalaz_core",
],
scalacopts = hj_scalacopts,
tags = ["cpu:6"] + (["canton-ee"] if edition == "ee" else []),
visibility = ["//test-evidence:__pkg__"] if edition == "ce" else None,
deps = [
":http-json-{}".format(edition),
Expand Down
12 changes: 12 additions & 0 deletions ledger-service/http-json/src/failurelib/scala/http/CE.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) 2023 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package com.daml.http

import com.daml.integrationtest.CantonRunner

import java.nio.file.Path

object Edition {
lazy val cantonJar: Path = CantonRunner.cantonPath
}
12 changes: 12 additions & 0 deletions ledger-service/http-json/src/failurelib/scala/http/EE.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) 2023 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package com.daml.http

import com.daml.bazeltools.BazelRunfiles.rlocation

import java.nio.file.{Path, Paths}

object Edition {
lazy val cantonJar: Path = Paths.get(rlocation("canton/canton-ee_deploy.jar"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ abstract class FailureTests
import HttpServiceTestFixture.{jwtForParties => _, _}
import WebsocketTestFixture._

final override protected lazy val cantonJar = Edition.cantonJar
protected override final def testId = getClass.getSimpleName

private def headersWithParties(actAs: List[domain.Party]) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.daml.http

import com.daml.bazeltools.BazelRunfiles
import com.daml.bazeltools.BazelRunfiles.rlocation
import com.daml.integrationtest.CantonFixtureWithResource
import com.daml.ledger.api.domain.LedgerId
import com.daml.ledger.resources.{Resource, ResourceContext, ResourceOwner}
Expand Down Expand Up @@ -51,9 +51,9 @@ trait ToxicSandboxFixture
def start(): Future[(Port, ToxiproxyClient, Proxy, Process)] = {
val toxiproxyExe =
if (!isWindows)
BazelRunfiles.rlocation("external/toxiproxy_dev_env/bin/toxiproxy-server")
rlocation("external/toxiproxy_dev_env/bin/toxiproxy-server")
else
BazelRunfiles.rlocation(
rlocation(
"external/toxiproxy_dev_env/toxiproxy-server-windows-amd64.exe"
)
for {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import org.scalatest.OptionValues._

import scala.concurrent.{ExecutionContext, Future}

final class AuthorizationTest
class AuthorizationTest
extends AsyncFlatSpec
with BeforeAndAfterAll
with Matchers
Expand Down
Loading

0 comments on commit 9e0493c

Please sign in to comment.