# Copyright (c) 2019 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( "//rules_daml:daml.bzl", "daml_compile", ) load("//bazel_tools:pom_file.bzl", "pom_file") load("@os_info//:os_info.bzl", "is_darwin") load( "//bazel_tools/client_server_test:client_server_test.bzl", "client_server_test", ) compileDependencies = [ # this has to come first other as somehow a different instance of grpc-core.jar "//3rdparty/jvm/io/grpc:grpc_services", "//daml-lf/scenario-interpreter", "//daml-lf/transaction", "//daml-lf/engine", "//daml-lf/data", "//daml-lf/lfpackage", "//daml-lf/archive:daml_lf_java_proto", "//daml-lf/archive:daml_lf_archive_scala", "//daml-lf/interpreter", "//daml-lf/transaction/src/main/protobuf:value_java_proto", "//daml-lf/transaction/src/main/protobuf:transaction_java_proto", "//ledger-api/rs-grpc-bridge", "//ledger-api/rs-grpc-akka", "//ledger/ledger-api-akka", "//ledger/ledger-api-scala-logging", "//language-support/scala/bindings", "//ledger/ledger-api-domain:ledger-api-domain", "//ledger/ledger-api-common:ledger-api-common", "//ledger/ledger-api-client:ledger-api-client", "//ledger/participant-state", "//ledger/participant-state-index:participant-state-index-v2", "//3rdparty/jvm/com/typesafe/scala_logging:scala_logging", "//3rdparty/jvm/org/slf4j:slf4j_api", "//3rdparty/jvm/org/scalaz:scalaz_core", "//3rdparty/jvm/org/scalaz:scalaz_concurrent", "//3rdparty/jvm/io/netty:netty_codec_http2", "//3rdparty/jvm/io/netty:netty_tcnative_boringssl_static", "//3rdparty/jvm/io/grpc:grpc_netty", "//3rdparty/jvm/io/netty:netty_handler", "//3rdparty/jvm/com/github/scopt:scopt", "//3rdparty/jvm/com/typesafe/akka:akka_stream", "//3rdparty/jvm/com/google/guava:guava", "//3rdparty/jvm/org/postgresql:postgresql", "//3rdparty/jvm/com/zaxxer:HikariCP", "//3rdparty/jvm/org/flywaydb:flyway_core", "//3rdparty/jvm/com/typesafe/play:anorm", "//3rdparty/jvm/com/typesafe/play:anorm_akka", "//3rdparty/jvm/io/dropwizard/metrics:metrics_core", "//3rdparty/jvm/io/dropwizard/metrics:metrics_jmx", ] da_scala_library( name = "sandbox", srcs = glob(["src/main/scala/**/*.scala"]), resources = glob( ["src/main/resources/**/*"], # Do not include logback.xml into the library: let the user # of the sandbox-as-a-library decide how to log. exclude = ["src/main/resources/logback.xml"], ) + [ "//:COMPONENT-VERSION", ], tags = ["maven_coordinates=com.digitalasset.platform:sandbox:__VERSION__"], visibility = [ "//visibility:public", ], runtime_deps = [ "//3rdparty/jvm/ch/qos/logback:logback_classic", "//3rdparty/jvm/ch/qos/logback:logback_core", ], deps = compileDependencies, ) da_scala_binary( name = "sandbox-binary", main_class = "com.digitalasset.platform.sandbox.SandboxMain", resources = ["src/main/resources/logback.xml"], visibility = ["//visibility:public"], deps = [ ":sandbox", ], ) genrule( name = "sandbox-tarball", srcs = [ ":sandbox-binary_deploy.jar", "//:component-version", ], outs = ["sandbox-tarball.tar.gz"], cmd = """ VERSION=$$(cat $(location //:component-version)) mkdir -p sandbox-tarball/sandbox cp -L $(location :sandbox-binary_deploy.jar) sandbox-tarball/sandbox/sandbox-$$VERSION.jar out=$$(realpath $@) cd sandbox-tarball tar zcf $$out sandbox """, visibility = ["//visibility:public"], ) # The sole purpose of this rule is to get the sandbox.jar with version 0.0.0. genrule( name = "sandbox-head-tarball", srcs = [":sandbox-binary_deploy.jar"], outs = ["sandbox-head-tarball.tar.gz"], cmd = """ mkdir -p sandbox-head-tarball/sandbox cp -L $(location :sandbox-binary_deploy.jar) sandbox-head-tarball/sandbox/sandbox-0.0.0.jar out=$$(realpath $@) cd sandbox-head-tarball tar zcf $$out sandbox """, visibility = ["//visibility:public"], ) daml_compile( name = "Test", main_src = "src/test/resources/damls/Test.daml", target = "1.dev", visibility = ["//visibility:public"], ) #TODO: generate dynamic BuildInfo.scala testDependencies = [ ":sandbox", "//ledger/test-common:test-common", "//ledger-api/testing-utils", "//3rdparty/jvm/org/scalatest:scalatest", "//3rdparty/jvm/org/scalacheck:scalacheck", "//3rdparty/jvm/org/awaitility:awaitility", "//3rdparty/jvm/commons_io:commons_io", ] + compileDependencies da_scala_library( name = "sandbox-scala-tests-lib", srcs = glob(["src/test/lib/**/*.scala"]), visibility = ["//visibility:public"], deps = testDependencies, ) da_scala_test_suite( name = "sandbox-scala-tests", srcs = glob( ["src/test/suite/**/*.scala"], ), data = [ "//ledger/sandbox:Test.dar", ], resources = glob(["src/test/resources/**/*"]), deps = [ ":sandbox-scala-tests-lib", ] + testDependencies, ) client_server_test( name = "conformance-test-static-time", timeout = "short", client = "//ledger/ledger-api-test-tool:ledger-api-test-tool", client_args = [ "--all-tests", ], data = [ "//ledger/ledger-api-integration-tests:SemanticTests.dar", "//ledger/sandbox:Test.dar", ], server = "//ledger/sandbox:sandbox-binary", server_args = [ "-s", "ledger/ledger-api-integration-tests/SemanticTests.dar", "ledger/sandbox/Test.dar", ], tags = [ "dont-run-on-darwin", # NOTE(JM): As this test is somewhat heavy and has timeouts, run it without competition to avoid flakyness. "exclusive", ], ) client_server_test( name = "conformance-test-wall-clock", timeout = "short", client = "//ledger/ledger-api-test-tool:ledger-api-test-tool", client_args = [ "--all-tests", "--exclude SemanticTests", ], data = [ "//ledger/ledger-api-integration-tests:SemanticTests.dar", "//ledger/sandbox:Test.dar", ], server = "//ledger/sandbox:sandbox-binary", server_args = [ "-w", "ledger/ledger-api-integration-tests/SemanticTests.dar", "ledger/sandbox/Test.dar", ], tags = [ "dont-run-on-darwin", # NOTE(JM): As this test is somewhat heavy and has timeouts, run it without competition to avoid flakyness. "exclusive", ], )