daml/ledger/sandbox/BUILD.bazel
Samir Talwar 7013c1619f
sandbox: When testing the reset service, wait for the ledger config. (#7975)
* Suppress debug and trace logging for Sandbox tests.

* participant-integration-api: Don't submit config after shutting down.

* sandbox: When testing the reset service, wait for the ledger config.

If we don't wait for the ledger configuration, we could potentially ask
for completions before the server is fully ready.

* sandbox-common: Reduce the number of reset attempts in testing.

Now we're also checking for ledger configuration, the time for a reset
to be "accepted" is longer, so 5 tries in 30 seconds is a bit flaky.
Reducing to 4 seems reasonable.

* sandbox: Stop marking the reset service tests as flaky.

I don't have conclusive proof that they're no longer flaky, but I'm
fairly confident. We can revert this commit if they turn out to still
need some attention.

CHANGELOG_BEGIN
CHANGELOG_END

* sandbox-common: Check the configuration shows up in reset service tests.

* sandbox-common: Factor out logback-test.xml.
2020-11-17 13:28:44 +00:00

265 lines
9.0 KiB
Python

# Copyright (c) 2020 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")
load("//ledger/ledger-api-test-tool:conformance.bzl", "server_conformance_test")
load("@os_info//:os_info.bzl", "is_windows")
load("@build_environment//:configuration.bzl", "mvn_version")
da_scala_library(
name = "sandbox",
srcs = glob(["src/main/scala/**/*.scala"]),
# 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 = [
"@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",
],
deps = [
"//daml-lf/archive:daml_lf_archive_reader",
"//daml-lf/archive:daml_lf_dev_archive_java_proto",
"//daml-lf/data",
"//daml-lf/engine",
"//daml-lf/transaction",
"//language-support/scala/bindings",
"//ledger/caching",
"//ledger/ledger-api-auth",
"//ledger/ledger-api-common",
"//ledger/ledger-api-domain",
"//ledger/ledger-api-health",
"//ledger/ledger-on-sql",
"//ledger/ledger-resources",
"//ledger/metrics",
"//ledger/participant-integration-api",
"//ledger/participant-state",
"//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_github_scopt_scopt_2_12",
"@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",
],
)
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
$(execpath //bazel_tools/sh:mktgz) $@ -C sandbox-tarball sandbox
""".format(mvn = mvn_version),
tools = ["//bazel_tools/sh:mktgz"],
visibility = ["//visibility:public"],
)
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/ledger-resources",
"//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",
],
)
da_scala_test_suite(
name = "sandbox-tests",
srcs = glob(["src/test/suite/**/*.scala"]),
data = [
"//ledger/test-common:model-tests.dar",
"//ledger/test-common/test-certificates",
],
resources = glob(["src/test/resources/**/*"]),
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/ledger-api-auth",
"//ledger/ledger-api-client",
"//ledger/ledger-api-common",
"//ledger/ledger-api-common:ledger-api-common-scala-tests-lib",
"//ledger/ledger-api-domain",
"//ledger/ledger-api-health",
"//ledger/ledger-resources",
"//ledger/ledger-resources:ledger-resources-test-lib",
"//ledger/metrics",
"//ledger/participant-integration-api",
"//ledger/participant-integration-api:participant-integration-api-tests-lib",
"//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/concurrent",
"//libs-scala/contextualized-logging",
"//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",
],
)
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",
],
)