daml/ledger/ledger-on-sql/BUILD.bazel
Remy d17dd7e5f1
Ledger API test tool: test against legacy and preview version. (#8913)
* Ledger API test tool: test against legacy and preview version.

+ use dictionary instead of alias to map version keywords to LF version 

CHANGELOG_BEGIN
CHANGELOG_END
2021-02-23 09:19:17 +01:00

327 lines
11 KiB
Python

# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
load(
"//bazel_tools:scala.bzl",
"da_scala_binary",
"da_scala_library",
"da_scala_test_suite",
"silencer_plugin",
)
load("//ledger/ledger-api-test-tool:conformance.bzl", "conformance_test")
supported_databases = [
{
"name": "h2-memory",
"runtime_deps": [
"@maven//:com_h2database_h2",
],
"conformance_test_tags": [
"manual",
],
"conformance_test_server_args": [
"--jdbc-url=jdbc:h2:mem:daml-on-sql-conformance-test",
],
"conformance_test_tool_args": [
"--concurrent-test-runs=2",
"--timeout-scale-factor=4",
],
},
{
"name": "h2-file",
"runtime_deps": [
"@maven//:com_h2database_h2",
],
"conformance_test_tags": [
"manual",
],
"conformance_test_server_main": "com.daml.ledger.on.sql.MainWithEphemeralDirectory",
"conformance_test_server_args": [
"--jdbc-url=jdbc:h2:%DIR/test",
],
"conformance_test_tool_args": [
"--concurrent-test-runs=2",
"--timeout-scale-factor=4",
],
},
{
"name": "postgresql",
"runtime_deps": [
"@maven//:org_postgresql_postgresql",
],
"conformance_test_server_main": "com.daml.ledger.on.sql.MainWithEphemeralPostgresql",
},
{
"name": "sqlite-memory",
"runtime_deps": [
"@maven//:org_xerial_sqlite_jdbc",
],
"conformance_test_server_args": [
"--jdbc-url=jdbc:sqlite:file:daml-on-sql-conformance-test?mode=memory&cache=shared",
],
},
{
"name": "sqlite-file",
"runtime_deps": [
"@maven//:org_xerial_sqlite_jdbc",
],
"conformance_test_server_main": "com.daml.ledger.on.sql.MainWithEphemeralDirectory",
"conformance_test_server_args": [
"--jdbc-url=jdbc:sqlite:%DIR/test.sqlite",
],
},
]
all_database_runtime_deps = {dep: None for db in supported_databases for dep in db["runtime_deps"]}.keys()
da_scala_library(
name = "ledger-on-sql",
srcs = glob(["src/main/scala/**/*.scala"]),
plugins = [silencer_plugin],
resources = glob(["src/main/resources/**/*"]),
scala_deps = [
"@maven//:com_typesafe_akka_akka_actor",
"@maven//:com_typesafe_akka_akka_stream",
"@maven//:org_playframework_anorm_anorm",
"@maven//:org_playframework_anorm_anorm_tokenizer",
"@maven//:org_scalaz_scalaz_core",
],
scalacopts = [
"-P:silencer:lineContentFilters=import scala.collection.compat",
],
tags = ["maven_coordinates=com.daml:ledger-on-sql:__VERSION__"],
visibility = [
"//visibility:public",
],
deps = [
"//daml-lf/data",
"//daml-lf/engine",
"//daml-lf/transaction",
"//language-support/scala/bindings",
"//ledger/caching",
"//ledger/ledger-api-common",
"//ledger/ledger-api-domain",
"//ledger/ledger-api-health",
"//ledger/ledger-resources",
"//ledger/metrics",
"//ledger/participant-state",
"//ledger/participant-state/kvutils",
"//libs-scala/concurrent",
"//libs-scala/contextualized-logging",
"//libs-scala/resources",
"//libs-scala/resources-akka",
"//libs-scala/resources-grpc",
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:com_zaxxer_HikariCP",
"@maven//:io_dropwizard_metrics_metrics_core",
"@maven//:org_flywaydb_flyway_core",
],
)
da_scala_library(
name = "ledger-on-sql-app",
srcs = glob(["src/app/scala/**/*.scala"]),
resources = glob(["src/app/resources/**/*"]),
scala_deps = [
"@maven//:com_github_scopt_scopt",
"@maven//:com_typesafe_akka_akka_actor",
"@maven//:com_typesafe_akka_akka_stream",
],
visibility = ["//visibility:public"],
deps = [
":ledger-on-sql",
"//daml-lf/data",
"//daml-lf/engine",
"//language-support/scala/bindings",
"//ledger/caching",
"//ledger/ledger-api-auth",
"//ledger/ledger-api-health",
"//ledger/ledger-resources",
"//ledger/metrics",
"//ledger/participant-integration-api",
"//ledger/participant-state",
"//ledger/participant-state/kvutils",
"//ledger/participant-state/kvutils/app",
"//libs-scala/contextualized-logging",
"//libs-scala/ports",
"//libs-scala/resources",
],
)
da_scala_binary(
name = "app",
main_class = "com.daml.ledger.on.sql.Main",
visibility = ["//visibility:public"],
runtime_deps = [
"@maven//:ch_qos_logback_logback_classic",
"@maven//:ch_qos_logback_logback_core",
] + all_database_runtime_deps,
deps = [
":ledger-on-sql-app",
],
)
da_scala_library(
name = "ledger-on-sql-test-lib",
srcs = glob(["src/test/lib/scala/**/*.scala"]),
scala_deps = [
"@maven//:com_github_scopt_scopt",
"@maven//:com_typesafe_akka_akka_actor",
"@maven//:com_typesafe_akka_akka_stream",
"@maven//:org_scalactic_scalactic",
"@maven//:org_scalatest_scalatest",
],
visibility = [
"//visibility:public",
],
deps = [
":ledger-on-sql",
":ledger-on-sql-app",
"//daml-lf/data",
"//daml-lf/engine",
"//language-support/scala/bindings",
"//ledger-api/rs-grpc-bridge",
"//ledger-api/testing-utils",
"//ledger/caching",
"//ledger/ledger-api-auth",
"//ledger/ledger-api-health",
"//ledger/ledger-resources",
"//ledger/ledger-resources:ledger-resources-test-lib",
"//ledger/metrics",
"//ledger/participant-integration-api",
"//ledger/participant-state",
"//ledger/participant-state/kvutils",
"//ledger/participant-state/kvutils:kvutils-tests-lib",
"//ledger/participant-state/kvutils/app",
"//libs-scala/contextualized-logging",
"//libs-scala/ports",
"//libs-scala/postgresql-testing",
"//libs-scala/resources",
],
)
da_scala_test_suite(
name = "ledger-on-sql-tests",
srcs = glob(["src/test/suite/**/*.scala"]),
data = [
"//ledger/test-common:model-tests-stable.dar",
],
resources = glob(["src/test/resources/*"]),
scala_deps = [
"@maven//:com_typesafe_akka_akka_actor",
"@maven//:com_typesafe_akka_akka_stream",
"@maven//:org_scala_lang_modules_scala_java8_compat",
"@maven//:org_scalactic_scalactic",
"@maven//:org_scalatest_scalatest",
],
runtime_deps = [
"@maven//:ch_qos_logback_logback_classic",
"@maven//:ch_qos_logback_logback_core",
] + all_database_runtime_deps,
deps = [
":ledger-on-sql",
":ledger-on-sql-test-lib",
"//daml-lf/data",
"//daml-lf/engine",
"//ledger-api/rs-grpc-bridge",
"//ledger-api/testing-utils",
"//ledger/ledger-api-common",
"//ledger/ledger-api-health",
"//ledger/ledger-resources",
"//ledger/ledger-resources:ledger-resources-test-lib",
"//ledger/metrics",
"//ledger/participant-integration-api",
"//ledger/participant-state",
"//ledger/participant-state/kvutils",
"//ledger/participant-state/kvutils:kvutils-tests-lib",
"//libs-scala/contextualized-logging",
"//libs-scala/flyway-testing",
"//libs-scala/postgresql-testing",
"//libs-scala/resources",
"@maven//:io_dropwizard_metrics_metrics_core",
"@maven//:org_flywaydb_flyway_core",
],
)
[
conformance_test(
name = "conformance-test-{}".format(db["name"]),
lf_versions = [
"stable",
"latest",
"preview",
],
ports = [6865],
server = ":conformance-test-{}-bin".format(db["name"]),
server_args = [
"--contract-id-seeding=testing-weak",
"--participant participant-id=conformance-test,port=6865",
] + db.get("conformance_test_server_args", []),
tags = db.get("conformance_test_tags", []),
test_tool_args = db.get("conformance_test_tool_args", []) + [
"--verbose",
],
)
for db in supported_databases
]
[
(
da_scala_binary(
name = "conformance-test-{}-bin".format(db["name"]),
main_class = db.get("conformance_test_server_main", "com.daml.ledger.on.sql.Main"),
visibility = ["//visibility:public"],
runtime_deps = db.get("runtime_deps", []),
deps = [
":ledger-on-sql",
":ledger-on-sql-test-lib",
],
),
conformance_test(
name = "conformance-test-participant-pruning-{}".format(db["name"]),
ports = [6865],
server = ":conformance-test-{}-bin".format(db["name"]),
server_args = [
"--contract-id-seeding=testing-weak",
"--participant participant-id=conformance-test,port=6865",
] + db.get("conformance_test_server_args", []),
tags = db.get("conformance_test_tags", []),
test_tool_args = db.get("conformance_test_tool_args", []) + [
"--verbose",
"--include=ParticipantPruningIT",
],
),
conformance_test(
name = "conformance-test-multi-party-submission-{}".format(db["name"]),
ports = [6865],
server = ":conformance-test-{}-bin".format(db["name"]),
server_args = [
"--contract-id-seeding=testing-weak",
"--participant participant-id=conformance-test,port=6865",
] + db.get("conformance_test_server_args", []),
tags = db.get("conformance_test_tags", []),
test_tool_args = db.get("conformance_test_tool_args", []) + [
"--verbose",
"--include=MultiPartySubmissionIT",
],
),
conformance_test(
name = "benchmark-performance-envelope-{}".format(db["name"]),
ports = [6865],
server = ":conformance-test-{}-bin".format(db["name"]),
server_args = [
"--contract-id-seeding=testing-weak",
"--participant participant-id=example,port=6865",
] + db.get("conformance_test_server_args", []),
tags = db.get("benchmark_performance_envelope_tags", []),
test_tool_args = db.get("benchmark_performance_envelope_tags", []) + [
"--verbose",
"--perf-tests=PerformanceEnvelope.Throughput.TwentyOPS",
"--perf-tests=PerformanceEnvelope.Latency.1000ms",
"--perf-tests=PerformanceEnvelope.TransactionSize.1000KB",
],
),
)
for db in supported_databases
]