daml/ledger/sandbox/BUILD.bazel
Robert Autenrieth 7ce9748066
Split sandbox code into separate packages (#6695)
* Move public code into daml-integration-api

CHANGELOG_BEGIN
[DAML Integration Kit]: Removed sandbox specific code from the API intended to be used by ledger integrations. Use the maven coordinates ``com.daml:participant-integration-api:VERSION`` instead of ``com.daml:ledger-api-server`` or ``com.daml:sandbox``.
CHANGELOG_END
2020-07-17 17:06:06 +02:00

312 lines
9.9 KiB
Python

# Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
load("//rules_daml:daml.bzl", "daml_compile")
load("//bazel_tools:scala.bzl", "da_scala_binary", "da_scala_library", "da_scala_test_suite")
load("//bazel_tools:pom_file.bzl", "pom_file")
load("//ledger/ledger-api-test-tool:conformance.bzl", "server_conformance_test")
load("@io_bazel_rules_docker//container:container.bzl", "container_image")
load("@io_bazel_rules_docker//java:image.bzl", "java_image")
load("@os_info//:os_info.bzl", "is_windows")
load("@build_environment//:configuration.bzl", "mvn_version")
compile_deps = [
"//daml-lf/archive:daml_lf_archive_reader",
"//daml-lf/archive:daml_lf_dev_archive_java_proto",
"//daml-lf/data",
"//daml-lf/engine",
"//language-support/scala/bindings",
"//ledger/caching",
"//ledger/participant-integration-api",
"//ledger/ledger-api-auth",
"//ledger/ledger-api-common",
"//ledger/ledger-api-domain",
"//ledger/ledger-api-health",
"//ledger/ledger-on-sql",
"//ledger/metrics",
"//ledger/participant-state",
"//ledger/participant-state-index",
"//ledger/participant-state-metrics",
"//ledger/participant-state/kvutils",
"//ledger/sandbox-common",
"//libs-scala/build-info",
"//libs-scala/contextualized-logging",
"//libs-scala/ports",
"//libs-scala/resources",
"//libs-scala/resources-akka",
"@maven//:ch_qos_logback_logback_classic",
"@maven//:com_typesafe_akka_akka_actor_2_12",
"@maven//:com_typesafe_akka_akka_stream_2_12",
"@maven//:com_typesafe_config",
"@maven//:org_scala_lang_modules_scala_java8_compat_2_12",
"@maven//:org_scalaz_scalaz_core_2_12",
"@maven//:org_slf4j_slf4j_api",
]
runtime_deps = [
"@maven//:ch_qos_logback_logback_classic",
"@maven//:ch_qos_logback_logback_core",
"@maven//:com_h2database_h2",
"@maven//:org_postgresql_postgresql",
"@maven//:org_xerial_sqlite_jdbc",
]
da_scala_library(
name = "sandbox",
srcs = glob(["src/main/scala/**/*.scala"]),
plugins = [
"@maven//:com_github_ghik_silencer_plugin_2_12_11",
],
# Do not include logback.xml into the library: let the user
# of the sandbox-as-a-library decide how to log.
resources = ["//ledger/sandbox-common:src/main/resources/banner.txt"],
tags = ["maven_coordinates=com.daml:sandbox:__VERSION__"],
visibility = [
"//visibility:public",
],
runtime_deps = runtime_deps,
deps = compile_deps + ["@maven//:com_github_ghik_silencer_lib_2_12_11"],
)
da_scala_binary(
name = "sandbox-binary",
main_class = "com.daml.platform.sandboxnext.Main",
resources = ["//ledger/sandbox-common:src/main/resources/logback.xml"],
visibility = ["//visibility:public"],
deps = [
":sandbox",
],
)
da_scala_binary(
name = "sandbox-ephemeral-postgresql",
main_class = "com.daml.platform.sandboxnext.persistence.MainWithEphemeralPostgresql",
resources = ["//ledger/sandbox-common:src/main/resources/logback.xml"],
visibility = ["//visibility:public"],
deps = [
":sandbox",
":sandbox-scala-tests-lib",
],
)
genrule(
name = "sandbox-tarball",
srcs = [
":sandbox-binary_deploy.jar",
],
outs = ["sandbox-tarball.tar.gz"],
cmd = """
mkdir -p sandbox-tarball/sandbox
cp -L $(location :sandbox-binary_deploy.jar) sandbox-tarball/sandbox/sandbox-{mvn}.jar
out=$$(realpath $@)
cd sandbox-tarball
tar c sandbox \\
--owner=0 --group=0 --numeric-owner --mtime=2000-01-01\\ 00:00Z --sort=name \\
| gzip -n > $$out
""".format(mvn = mvn_version),
visibility = ["//visibility:public"],
)
container_image(
name = "sandbox-image-base",
base = "@java_base//image",
cmd = None,
directory = "/usr/bin",
files = [
"@com_github_grpc_ecosystem_grpc_health_probe_binary//file",
],
) if not is_windows else None
java_image(
name = "sandbox-image",
base = ":sandbox-image-base",
main_class = "com.daml.platform.sandboxnext.Main",
resources = ["//ledger/sandbox-common:src/main/resources/logback.xml"],
visibility = ["//visibility:public"],
runtime_deps = [":sandbox"],
) if not is_windows else None
da_scala_library(
name = "sandbox-scala-tests-lib",
srcs = glob(["src/test/lib/**/*.scala"]),
visibility = ["//visibility:public"],
runtime_deps = [
"@maven//:com_h2database_h2",
"@maven//:com_typesafe_akka_akka_slf4j_2_12",
"@maven//:org_postgresql_postgresql",
],
deps = [
":sandbox",
"//daml-lf/data",
"//language-support/scala/bindings",
"//ledger-api/rs-grpc-bridge",
"//ledger-api/testing-utils",
"//ledger/caching",
"//ledger/ledger-api-auth",
"//ledger/ledger-api-common",
"//ledger/ledger-api-domain",
"//ledger/participant-integration-api",
"//ledger/participant-integration-api:participant-integration-api-tests-lib",
"//ledger/participant-state",
"//ledger/sandbox-common",
"//ledger/sandbox-common:sandbox-common-scala-tests-lib",
"//libs-scala/ports",
"//libs-scala/postgresql-testing",
"//libs-scala/resources",
"@maven//:ch_qos_logback_logback_classic",
"@maven//:com_typesafe_akka_akka_actor_2_12",
"@maven//:com_typesafe_akka_akka_stream_2_12",
"@maven//:org_scalactic_scalactic_2_12",
"@maven//:org_scalatest_scalatest_2_12",
"@maven//:org_scalaz_scalaz_core_2_12",
"@maven//:org_slf4j_slf4j_api",
],
)
test_deps = [
":sandbox",
":sandbox-scala-tests-lib",
"//bazel_tools/runfiles:scala_runfiles",
"//daml-lf/archive:daml_lf_archive_reader",
"//daml-lf/archive:daml_lf_dev_archive_java_proto",
"//daml-lf/data",
"//daml-lf/engine",
"//daml-lf/interpreter",
"//daml-lf/language",
"//daml-lf/transaction",
"//daml-lf/transaction-test-lib",
"//language-support/scala/bindings",
"//ledger-api/rs-grpc-akka",
"//ledger-api/rs-grpc-akka:rs-grpc-akka-tests-lib",
"//ledger-api/rs-grpc-bridge",
"//ledger-api/sample-service",
"//ledger-api/testing-utils",
"//ledger/caching",
"//ledger/participant-integration-api",
"//ledger/participant-integration-api:participant-integration-api-tests-lib",
"//ledger/ledger-api-auth",
"//ledger/ledger-api-common",
"//ledger/ledger-api-common:ledger-api-common-scala-tests-lib",
"//ledger/ledger-api-client",
"//ledger/ledger-api-domain",
"//ledger/ledger-api-health",
"//ledger/metrics",
"//ledger/participant-state",
"//ledger/participant-state-index",
"//ledger/participant-state-metrics",
"//ledger/sandbox-common",
"//ledger/sandbox-common:sandbox-common-scala-tests-lib",
"//ledger/test-common",
"//libs-scala/contextualized-logging",
"//libs-scala/direct-execution-context",
"//libs-scala/grpc-utils",
"//libs-scala/ports",
"//libs-scala/postgresql-testing",
"//libs-scala/resources",
"@maven//:ch_qos_logback_logback_classic",
"@maven//:ch_qos_logback_logback_core",
"@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_config",
"@maven//:commons_io_commons_io",
"@maven//:io_dropwizard_metrics_metrics_core",
"@maven//:io_grpc_grpc_services",
"@maven//:io_netty_netty_handler",
"@maven//:org_awaitility_awaitility",
"@maven//:org_flywaydb_flyway_core",
"@maven//:org_mockito_mockito_core",
"@maven//:org_mockito_mockito_scala_2_12",
"@maven//:org_reactivestreams_reactive_streams",
"@maven//:org_scalacheck_scalacheck_2_12",
"@maven//:org_scalactic_scalactic_2_12",
"@maven//:org_scalatest_scalatest_2_12",
"@maven//:org_scalaz_scalaz_core_2_12",
"@maven//:org_slf4j_slf4j_api",
]
da_scala_test_suite(
name = "sandbox-tests",
srcs = glob(
["src/test/suite/**/*.scala"],
exclude = ["src/test/suite/**/ResetService*IT.scala"],
),
data = [
"//ledger/test-common:model-tests.dar",
"//ledger/test-common/test-certificates",
],
resources = glob(["src/test/resources/**/*"]),
deps = test_deps,
)
da_scala_test_suite(
name = "sandbox-resetservice-tests",
srcs = glob(
["src/test/suite/**/ResetService*IT.scala"],
),
data = [
"//ledger/test-common:model-tests.dar",
"//ledger/test-common/test-certificates",
],
flaky = True,
resources = glob(["src/test/resources/**/*"]),
deps = test_deps,
)
NEXT_SERVERS = {
"memory": {
"binary": ":sandbox-binary",
"server_args": [
"--contract-id-seeding=testing-weak",
"--port=6865",
"--eager-package-loading",
],
},
"postgresql": {
"binary": ":sandbox-ephemeral-postgresql",
"server_args": [
"--contract-id-seeding=testing-weak",
"--port=6865",
"--eager-package-loading",
],
},
}
server_conformance_test(
name = "next-conformance-test-static-time",
server_args = [
"--static-time",
],
servers = NEXT_SERVERS,
test_tool_args = [
"--open-world",
"--exclude=ClosedWorldIT",
],
)
server_conformance_test(
name = "next-conformance-test-wall-clock-time",
server_args = [
"--wall-clock-time",
],
servers = NEXT_SERVERS,
test_tool_args = [
"--open-world",
"--exclude=ClosedWorldIT",
],
)
server_conformance_test(
name = "next-conformance-test-closed-world",
server_args = [
"--wall-clock-time",
"--implicit-party-allocation=false",
],
servers = NEXT_SERVERS,
test_tool_args = [
"--verbose",
"--include=ClosedWorldIT",
],
)