diff --git a/BUILD b/BUILD index 390af81bbe5e..8b8f30bdd5dd 100644 --- a/BUILD +++ b/BUILD @@ -271,22 +271,3 @@ da_haskell_repl( "//language-support/ts/codegen:daml2js", ], ) - -string_flag( - name = "oracle_testing", - build_setting_default = "no", -) - -config_setting( - name = "oracle_available", - flag_values = { - ":oracle_testing": "yes", - }, -) - -config_setting( - name = "oracle_unavailable", - flag_values = { - ":oracle_testing": "no", - }, -) diff --git a/WORKSPACE b/WORKSPACE index c0a9c3386e6c..127bd5386c95 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -56,6 +56,10 @@ load("//bazel_tools:build_environment.bzl", "build_environment") build_environment(name = "build_environment") +load("//bazel_tools:oracle.bzl", "oracle_configure") + +oracle_configure(name = "oracle") + load("//bazel_tools:scala_version.bzl", "scala_version_configure") scala_version_configure(name = "scala_version") diff --git a/bazel_tools/oracle.bzl b/bazel_tools/oracle.bzl new file mode 100644 index 000000000000..9a520b64ebf8 --- /dev/null +++ b/bazel_tools/oracle.bzl @@ -0,0 +1,28 @@ +# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +def _impl(ctx): + # Generates an empty BUILD file, because we do not need to build anything. + ctx.file( + "BUILD", + content = """exports_files(["index.bzl"])""", + executable = False, + ) + + testing = ctx.os.environ.get("DAML_ORACLE_TESTING", default = "false") == "true" + + ctx.file( + "index.bzl", + content = """ +oracle_testing = {testing} +""".format( + testing = testing, + ), + executable = False, + ) + +oracle_configure = repository_rule( + environ = ["DAML_ORACLE_TESTING"], + implementation = _impl, + attrs = {}, +) diff --git a/ci/build.yml b/ci/build.yml index ea5ebf272611..ddd324805faf 100644 --- a/ci/build.yml +++ b/ci/build.yml @@ -238,7 +238,7 @@ jobs: sleep 1 done # Actually run some tests - bazel test --//:oracle_testing=yes \ + DAML_ORACLE_TESTING=true bazel test \ --test_env ORACLE_USERNAME=system --test_env ORACLE_PORT --test_env ORACLE_PWD \ //ledger-service/http-json-oracle/... \ //triggers/service:test-oracle \ diff --git a/ledger-service/http-json-oracle/BUILD.bazel b/ledger-service/http-json-oracle/BUILD.bazel index 800fe91d586c..0ad66f46f9ce 100644 --- a/ledger-service/http-json-oracle/BUILD.bazel +++ b/ledger-service/http-json-oracle/BUILD.bazel @@ -1,6 +1,8 @@ # Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +load("@oracle//:index.bzl", "oracle_testing") +load("@scala_version//:index.bzl", "scala_version_suffix") load( "//bazel_tools:scala.bzl", "da_scala_binary", @@ -8,7 +10,6 @@ load( "da_scala_test", "lf_scalacopts", ) -load("@scala_version//:index.bzl", "scala_version_suffix") hj_scalacopts = lf_scalacopts + [ "-P:wartremover:traverser:org.wartremover.warts.NonUnitStatements", @@ -37,10 +38,7 @@ da_scala_test( "@maven//:org_scalaz_scalaz_core", ], scalacopts = hj_scalacopts, - target_compatible_with = select({ - "//:oracle_available": [], - "//conditions:default": ["@platforms//:incompatible"], - }), + tags = [] if oracle_testing else ["manual"], runtime_deps = [ "@maven//:com_oracle_database_jdbc_ojdbc8", ], diff --git a/ledger/participant-integration-api/BUILD.bazel b/ledger/participant-integration-api/BUILD.bazel index df99303cb310..6f820f135e22 100644 --- a/ledger/participant-integration-api/BUILD.bazel +++ b/ledger/participant-integration-api/BUILD.bazel @@ -1,18 +1,20 @@ # Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +load("@oracle//:index.bzl", "oracle_testing") load("@os_info//:os_info.bzl", "is_windows") -load("//rules_daml:daml.bzl", "daml_compile") +load("@scala_version//:index.bzl", "scala_major_version_suffix") load( "//bazel_tools:scala.bzl", "da_scala_binary", "da_scala_library", + "da_scala_test", "da_scala_test_suite", "scaladoc_jar", "silencer_plugin", ) load("//bazel_tools:pom_file.bzl", "pom_file") -load("@scala_version//:index.bzl", "scala_major_version_suffix") +load("//rules_daml:daml.bzl", "daml_compile") compile_deps = [ "//daml-lf/archive:daml_lf_archive_reader", @@ -200,80 +202,6 @@ da_scala_library( ], ) -test_deps = [ - ":participant-integration-api", - ":participant-integration-api-tests-lib", - "//bazel_tools/runfiles:scala_runfiles", - "//daml-lf/archive:daml_lf_archive_reader", - "//daml-lf/archive:daml_lf_dev_archive_proto_java", - "//daml-lf/data", - "//daml-lf/engine", - "//daml-lf/interpreter", - "//daml-lf/language", - "//daml-lf/transaction", - "//daml-lf/transaction:value_proto_java", - "//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-state", - "//ledger/participant-state-index", - "//ledger/test-common", - "//ledger/test-common:dar-files-stable-lib", - "//libs-scala/contextualized-logging", - "//libs-scala/concurrent", - "//libs-scala/grpc-utils", - "//libs-scala/ports", - "//libs-scala/oracle-testing", - "//libs-scala/postgresql-testing", - "//libs-scala/resources", - "//libs-scala/resources-akka", - "//libs-scala/resources-grpc", - "//libs-scala/timer-utils", - "@maven//:ch_qos_logback_logback_classic", - "@maven//:ch_qos_logback_logback_core", - "@maven//:commons_io_commons_io", - "@maven//:com_github_ben_manes_caffeine_caffeine", - "@maven//:io_dropwizard_metrics_metrics_core", - "@maven//:io_grpc_grpc_netty", - "@maven//:io_grpc_grpc_services", - "@maven//:io_netty_netty_common", - "@maven//:io_netty_netty_handler", - "@maven//:io_netty_netty_transport", - "@maven//:org_awaitility_awaitility", - "@maven//:org_flywaydb_flyway_core", - "@maven//:org_mockito_mockito_core", - "@maven//:org_reactivestreams_reactive_streams", - "@maven//:org_slf4j_slf4j_api", - "@maven//:com_zaxxer_HikariCP", -] - -scala_test_deps = [ - "@maven//:com_typesafe_akka_akka_actor", - "@maven//:com_typesafe_akka_akka_stream", - "@maven//:com_typesafe_akka_akka_stream_testkit", - "@maven//:com_typesafe_akka_akka_testkit", - "@maven//:org_mockito_mockito_scala", - "@maven//:org_scalacheck_scalacheck", - "@maven//:org_scalactic_scalactic", - "@maven//:org_scalatest_scalatest", - "@maven//:org_scalatestplus_scalacheck_1_14", - "@maven//:org_scalaz_scalaz_core", -] - openssl_executable = "@openssl_dev_env//:bin/openssl" if not is_windows else "@openssl_dev_env//:usr/bin/openssl.exe" da_scala_test_suite( @@ -295,11 +223,73 @@ da_scala_test_suite( "-Djava.security.debug=\"certpath ocsp\"", # This facilitates debugging of the OCSP checks mechanism ], resources = glob(["src/test/resources/**/*"]), - scala_deps = scala_test_deps, - deps = test_deps, + scala_deps = [ + "@maven//:com_typesafe_akka_akka_actor", + "@maven//:com_typesafe_akka_akka_stream", + "@maven//:com_typesafe_akka_akka_stream_testkit", + "@maven//:org_mockito_mockito_scala", + "@maven//:org_scalacheck_scalacheck", + "@maven//:org_scalactic_scalactic", + "@maven//:org_scalatest_scalatest", + "@maven//:org_scalatestplus_scalacheck_1_14", + "@maven//:org_scalaz_scalaz_core", + ], + deps = [ + ":participant-integration-api", + ":participant-integration-api-tests-lib", + "//bazel_tools/runfiles:scala_runfiles", + "//daml-lf/archive:daml_lf_archive_reader", + "//daml-lf/archive:daml_lf_dev_archive_proto_java", + "//daml-lf/data", + "//daml-lf/engine", + "//daml-lf/language", + "//daml-lf/transaction", + "//daml-lf/transaction:value_proto_java", + "//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-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-state", + "//ledger/participant-state-index", + "//ledger/test-common", + "//ledger/test-common:dar-files-stable-lib", + "//libs-scala/concurrent", + "//libs-scala/contextualized-logging", + "//libs-scala/grpc-utils", + "//libs-scala/ports", + "//libs-scala/postgresql-testing", + "//libs-scala/resources", + "//libs-scala/resources-akka", + "//libs-scala/resources-grpc", + "@maven//:ch_qos_logback_logback_classic", + "@maven//:com_github_ben_manes_caffeine_caffeine", + "@maven//:com_zaxxer_HikariCP", + "@maven//:commons_io_commons_io", + "@maven//:io_dropwizard_metrics_metrics_core", + "@maven//:io_grpc_grpc_netty", + "@maven//:io_netty_netty_handler", + "@maven//:io_netty_netty_transport", + "@maven//:org_flywaydb_flyway_core", + "@maven//:org_mockito_mockito_core", + "@maven//:org_reactivestreams_reactive_streams", + "@maven//:org_slf4j_slf4j_api", + ], ) -da_scala_test_suite( +# The "manual" test tag doesn't seem to work with `da_scala_test_suite`. +da_scala_test( name = "participant-integration-api-tests-oracle", size = "large", srcs = glob(["src/test/suite/**/*Oracle*.scala"]), @@ -312,15 +302,40 @@ da_scala_test_suite( "-Djava.security.debug=\"certpath ocsp\"", # This facilitates debugging of the OCSP checks mechanism ], resources = glob(["src/test/resources/**/*"]), - scala_deps = scala_test_deps, - target_compatible_with = select({ - "//:oracle_available": [], - "//conditions:default": ["@platforms//:incompatible"], - }), + scala_deps = [ + "@maven//:com_typesafe_akka_akka_actor", + "@maven//:com_typesafe_akka_akka_stream", + "@maven//:org_scalacheck_scalacheck", + "@maven//:org_scalactic_scalactic", + "@maven//:org_scalatest_scalatest", + ], + tags = [] if oracle_testing else ["manual"], runtime_deps = [ "@maven//:com_oracle_database_jdbc_ojdbc8", ], - deps = test_deps, + deps = [ + ":participant-integration-api", + ":participant-integration-api-tests-lib", + "//daml-lf/archive:daml_lf_archive_reader", + "//daml-lf/archive:daml_lf_dev_archive_proto_java", + "//daml-lf/data", + "//daml-lf/transaction", + "//daml-lf/transaction-test-lib", + "//language-support/scala/bindings", + "//ledger-api/rs-grpc-bridge", + "//ledger-api/testing-utils", + "//ledger/ledger-api-common", + "//ledger/ledger-api-domain", + "//ledger/ledger-api-health", + "//ledger/ledger-resources", + "//ledger/participant-state", + "//ledger/participant-state-index", + "//libs-scala/contextualized-logging", + "//libs-scala/oracle-testing", + "//libs-scala/ports", + "//libs-scala/resources", + "@maven//:org_slf4j_slf4j_api", + ], ) exports_files(["src/main/resources/logback.xml"]) diff --git a/triggers/service/BUILD.bazel b/triggers/service/BUILD.bazel index f77b14c7425e..d18d5fb58934 100644 --- a/triggers/service/BUILD.bazel +++ b/triggers/service/BUILD.bazel @@ -1,6 +1,9 @@ # Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +load("@oracle//:index.bzl", "oracle_testing") +load("@build_environment//:configuration.bzl", "sdk_version") +load("@os_info//:os_info.bzl", "is_windows") load( "//bazel_tools:scala.bzl", "da_scala_binary", @@ -8,8 +11,6 @@ load( "da_scala_test", "da_scala_test_suite", ) -load("@build_environment//:configuration.bzl", "sdk_version") -load("@os_info//:os_info.bzl", "is_windows") tsvc_main_scalacopts = [ "-P:wartremover:traverser:org.wartremover.warts.%s" % wart @@ -194,63 +195,82 @@ da_scala_library( ], ) -test_deps = [ - ":trigger-service", - "//ledger-api/testing-utils", - "//ledger-api/rs-grpc-bridge", - ":trigger-service-tests", - "//daml-lf/archive:daml_lf_archive_reader", - "//daml-lf/archive:daml_lf_dev_archive_proto_java", - "//daml-lf/data", - "//language-support/scala/bindings-akka", - "//ledger-service/jwt", - "//ledger/ledger-api-auth", - "//ledger/ledger-api-common", - "//ledger/ledger-resources", - "//ledger/sandbox-classic", - "//ledger/sandbox-common", - "//libs-scala/adjustable-clock", - "//libs-scala/flyway-testing", - "//libs-scala/oracle-testing", - "//libs-scala/ports", - "//libs-scala/postgresql-testing", - "//libs-scala/resources", - "//triggers/service/auth:oauth2-test-server", - "@maven//:eu_rekawek_toxiproxy_toxiproxy_java_2_1_3", - "@maven//:org_flywaydb_flyway_core", - "//ledger-service/cli-opts", -] - -scala_test_deps = [ - "@maven//:io_spray_spray_json", - "@maven//:com_typesafe_akka_akka_http_core", - "@maven//:org_scalatest_scalatest", - "@maven//:org_scalaz_scalaz_core", - "@maven//:com_github_scopt_scopt", -] - da_scala_test_suite( name = "test", srcs = glob( ["src/test-suite/scala/**/*.scala"], exclude = ["**/*Oracle*"], ), - scala_deps = scala_test_deps, - deps = test_deps, + scala_deps = [ + "@maven//:io_spray_spray_json", + "@maven//:com_typesafe_akka_akka_http_core", + "@maven//:org_scalatest_scalatest", + "@maven//:org_scalaz_scalaz_core", + "@maven//:com_github_scopt_scopt", + ], + deps = [ + ":trigger-service", + ":trigger-service-tests", + "//daml-lf/archive:daml_lf_archive_reader", + "//daml-lf/archive:daml_lf_dev_archive_proto_java", + "//daml-lf/data", + "//language-support/scala/bindings-akka", + "//ledger-api/rs-grpc-bridge", + "//ledger-api/testing-utils", + "//ledger-service/cli-opts", + "//ledger-service/jwt", + "//ledger/ledger-api-auth", + "//ledger/ledger-api-common", + "//ledger/ledger-resources", + "//ledger/sandbox-classic", + "//ledger/sandbox-common", + "//libs-scala/adjustable-clock", + "//libs-scala/flyway-testing", + "//libs-scala/ports", + "//libs-scala/postgresql-testing", + "//libs-scala/resources", + "//triggers/service/auth:oauth2-test-server", + "@maven//:eu_rekawek_toxiproxy_toxiproxy_java_2_1_3", + "@maven//:org_flywaydb_flyway_core", + ], ) -da_scala_test_suite( +# The "manual" test tag doesn't seem to work with `da_scala_test_suite`. +da_scala_test( name = "test-oracle", srcs = glob(["src/test-suite/scala/**/*Oracle*.scala"]), - scala_deps = scala_test_deps, - target_compatible_with = select({ - "//:oracle_available": [], - "//conditions:default": ["@platforms//:incompatible"], - }), + scala_deps = [ + "@maven//:io_spray_spray_json", + "@maven//:com_typesafe_akka_akka_http_core", + "@maven//:org_scalatest_scalatest", + "@maven//:org_scalaz_scalaz_core", + ], + tags = [] if oracle_testing else ["manual"], runtime_deps = [ "@maven//:com_oracle_database_jdbc_ojdbc8", ], - deps = test_deps, + deps = [ + ":trigger-service", + ":trigger-service-tests", + "//daml-lf/archive:daml_lf_archive_reader", + "//daml-lf/archive:daml_lf_dev_archive_proto_java", + "//daml-lf/data", + "//language-support/scala/bindings-akka", + "//ledger-api/rs-grpc-bridge", + "//ledger-api/testing-utils", + "//ledger-service/jwt", + "//ledger/ledger-api-auth", + "//ledger/ledger-api-common", + "//ledger/ledger-resources", + "//ledger/sandbox-classic", + "//ledger/sandbox-common", + "//libs-scala/adjustable-clock", + "//libs-scala/oracle-testing", + "//libs-scala/ports", + "//libs-scala/resources", + "//triggers/service/auth:oauth2-test-server", + "@maven//:eu_rekawek_toxiproxy_toxiproxy_java_2_1_3", + ], ) genrule(