Skip to content

Commit

Permalink
Switch to an environment variable for enabling Oracle tests. (#9511)
Browse files Browse the repository at this point in the history
* participant-integration-api: Build Oracle tests, but don't run them.

CHANGELOG_BEGIN
CHANGELOG_END

* triggers: Switch to an environment variable for enabling Oracle tests.

* http-json: Switch to an environment variable for enabling Oracle tests.

* Disable running Oracle tests by default, not building them.

* triggers/service: Remove unused test dependencies.
  • Loading branch information
SamirTalwar authored Apr 27, 2021
1 parent e39c20e commit 8cd3658
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 156 deletions.
19 changes: 0 additions & 19 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
)
4 changes: 4 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
28 changes: 28 additions & 0 deletions bazel_tools/oracle.bzl
Original file line number Diff line number Diff line change
@@ -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 = {},
)
2 changes: 1 addition & 1 deletion ci/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
8 changes: 3 additions & 5 deletions ledger-service/http-json-oracle/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# 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",
"da_scala_library",
"da_scala_test",
"lf_scalacopts",
)
load("@scala_version//:index.bzl", "scala_version_suffix")

hj_scalacopts = lf_scalacopts + [
"-P:wartremover:traverser:org.wartremover.warts.NonUnitStatements",
Expand Down Expand Up @@ -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",
],
Expand Down
185 changes: 100 additions & 85 deletions ledger/participant-integration-api/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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(
Expand All @@ -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"]),
Expand All @@ -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"])
Expand Down
Loading

0 comments on commit 8cd3658

Please sign in to comment.