Commit Graph

541 Commits

Author SHA1 Message Date
Ognjen Maric
589f710313
Prohibit contract IDs in contract keys and add key maintainers to exercises (#4048)
Prohibit contract IDs in contract keys and add key maintainers to exercises

CHANGELOG_BEGIN

- [DAML-LF] Prohibit contract IDs in contract keys completely. Previously, creating keys containing absolute (but not relative) contract IDs was allowed, but `lookupByKey` on such a key would crash. 

CHANGELOG_END

Co-authored-by: Remy <remy.haemmerle@daml.com>
Co-authored-by: Stephen Compall <scompall@nocandysw.com>
2020-01-20 16:36:38 +01:00
Moritz Kiefer
f77e326e0b Generate stable DA.Time.Types module as DAML-LF 1.6 (#4095)
This was accidentally set to 1.7 before for no reason. Note that this
simply meant that we did not use the stable module when compiling with
--target=1.6 since we filter out newer stable packages.

Nevertheless, I’ve also added a test that verifies that we do not
accidentally introduce dependencies on packages in newer LF versions.

changelog_begin
changelog_end
2020-01-17 18:05:39 +00:00
Samir Talwar
4f12e9be9e Make sure the RecoveringIndexer terminates. (#4034)
* sandbox: Tidy up the RecoveringIndexerSpec a little.

* sandbox: Move the JdbcLedgerDao owner constructor to its object.

* sandbox/damlonx: Make sure the RecoveringIndexer terminates.

Previously, if there was a failure and a termination at the same time,
we could recover after terminating, which means we'd end up in a weird
state. This makes sure we stop correctly.

Unfortunately, I couldn't find a good place to put these tests apart
from in reference-v2, as they need to depend on both _kvutils_ and
_sandbox_. Perhaps they belong in their own Bazel package.

This might address #3945; it's hard to say.

CHANGELOG_BEGIN
- [Indexer] Potentially fix a bug when recovering from failure.
CHANGELOG_END

* reference-v2: Address a race condition in the IndexerIT assertions.

* sandbox: Make sure the RecoveringIndexer can stop during a restart.

* reference-v2: Use Mockito to simulate errors in IndexerIT.

* sandbox: When the RecoveringIndexer is stopped, stop quickly.

* reference-v2: Make sure each test has its own metrics registry.

* Replace TestNamedLoggerFactory with in-memory appender

* sandbox: Test RecoveringIndexerSpec with a mock logger.

Using a real logger was causing massive stack traces in all other tests
that didn't have `RecoveringIndexerSpec$Appender` available, and adding
the appender programmatically didn't work for some reason.

The mock gives much nicer error messages on failure, too.

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
2020-01-17 14:54:05 +00:00
Stefano Baghino
522555fb69
Replace TestNamedLoggerFactory with in-memory appender (#4071)
CHANGELOG_BEGIN
CHANGELOG_END
2020-01-16 17:07:31 +01:00
Samir Talwar
b96e54f640 libs-scala/resources: Move Resource and friends to their own package. (#4066)
* libs-scala/resources: Move `Resource` and friends to their own package.

CHANGELOG_BEGIN
- [Ledger API Server] Publish the resource management code as a library
  under ``com.digitalasset:resources``.
CHANGELOG_END

* libs-scala/resources: Add to the artifacts list.

* libs-scala/resources: Factor out the test helpers into test/lib.

* libs-scala/resources-akka: Make the Akka resources an optional dep.
2020-01-16 14:13:18 +00:00
Brian Healey
a5490658ac
EC256 rather than EC512 algo (#4019)
* EC256 rather than EC512 algo
CHANGELOG_BEGIN
[Ledger API Authorization]Support EC256 algorithm for JWT rather than EC512
CHANGELOG_END

* support both 256 and 512 ECDSA algo

Signed-off-by: Brian Healey <brian.healey@digitalasset.com>

* scalafmt

* correct comment, avoid unnecessary private def

Signed-off-by: Brian Healey <brian.healey@digitalasset.com>

* correct BAZEL formatter
2020-01-16 08:55:55 -05:00
Stefano Baghino
5231bab423
Introduce ContextualizedLogger and LoggingContext (#4046)
* Introduce ContextualizedLogger and LoggingContext

A ContextualizedLogger is a wrapper around an Slf4j logger. It uses
call-by-name parameters to only construct logging lines when necessary.
The underlying context can be used by invoking withoutContext.

More interestingly, every call to one of its logging methods requires
the presence of an implicit LoggingContext.

A LoggingContext is a way of definining a set of pairs that a
ContextualizedLogger can log without the need of it being specified for
every call.

A new context can be created with newLoggingContext and, given an
implicit LoggingContext, pairs can be added or overwritten using
withEnrichedLoggingContext.

Pairs in the context will be appended to each event logged by a
ContextualizedLogger in the following form:

some text logged explicitly (context: {key1=value1, key2=value2)

If the underlying Logger is configured to use the Logstash encoder the
keys and values in the LoggingContext will also be added to the logging
event encoded in JSON format.

CHANGELOG_BEGIN
CHANGELOG_END

* Apply suggestion in https://github.com/digital-asset/daml/pull/4046#pullrequestreview-343224692

Thanks to @SamirTalwar

Co-Authored-By: Samir Talwar <samir.talwar@digitalasset.com>

* Address https://github.com/digital-asset/daml/pull/4046#discussion_r366874330

Co-authored-by: Samir Talwar <samir@noodlesandwich.com>
2020-01-16 13:05:40 +01:00
Samir Talwar
cb3392fa54 A simplified KVUtils ledger, implemented on SQL with JDBC. (#3940)
* ledger-on-sql: Implement a ledger using the simplified kvutils on JDBC.

This tests against H2; PostgreSQL coming soon.

No changelog because we're not shipping this yet.

CHANGELOG_BEGIN
CHANGELOG_END

* kvutils/app: Extract ledger construction into a trait.

* ledger-on-sql: Run the conformance tests against H2.

* ledger-on-sql: Use H2-specific queries to perform actions atomically.

* ledger-on-sql: Extract queries to `Queries` and `H2Queries`.

* ledger-on-sql: SQLite can't have more than one connection at a time.

* ledger-on-sql: Run conformance tests against SQLite.

* ledger-on-sql: Fix error message if the JDBC URL is missing.

Co-Authored-By: Gerolf Seitz <gerolf.seitz@digitalasset.com>

* kvutils/app: Rename LedgerConstructor to LedgerFactory.

* ledger-on-sql: Don't release connections early.

* ledger-on-sql: Rename `withConnection` so it's more meaningful.

* ledger-on-sql: Use a sequential log entry ID.

* ledger-on-sql: Disable H2 conformance tests.

Until we can figure out why some fail.

Co-authored-by: Gerolf Seitz <gerolf.seitz@digitalasset.com>
2020-01-16 12:02:16 +00:00
Gerolf Seitz
eafeca34a8
Fix bug that can cause the transaction stream to not terminate. (#4053)
Fixes #3984.

CHANGELOG_BEGIN
[Sandbox] Fix bug that can cause the transaction stream to not terminate.
  See `issue #3984 <https://github.com/digital-asset/daml/issues/3984>`__.
CHANGELOG_END

The bug is that the ledger end gets updated without writing any ledger entries,
for example when uploading packages or in case of duplicate commands.

The termination of the stream (i.e. the comparison of offsets) only happened
on actual ledger entries. If there are none, then the stream just waits for the next
entry to be written.

This change moves the stream termination/completion to BEFORE potential entries
are loaded. The stream knows that after a certain offset has been reached, that it can
be terminated/completed.
2020-01-15 15:11:15 +01:00
Samir Talwar
536d6a3f94 A simplified KVUtils ledger, implemented on a POSIX filesystem. (#3933)
* kvutils, etc: Remove duplicate copyright notices.

* ledger-on-posix-filesystem: Implement a simplified KV ledger on FS.

CHANGELOG_BEGIN

- A simple KVUtils-based ledger that runs against a POSIX filesystem.
  Intended as a reference implementation for testing and documentation.

CHANGELOG_END

* ledger-on-posix-filesystem: Make it runnable.

* ledger-on-posix-filesystem: Chunk long state paths for macOS.

macOS only supports file names of up to 255 characters.

* ledger-on-posix-filesystem: Run conformance tests.

The lock is temporarily implemented as an in-memory mutex.

* ledger-on-posix-filesystem: Move the paths into the class.

* ledger-on-posix-filesystem: Lock using the file system.

We use the movement of a directory as an atomic operation.

* ledger-on-posix-filesystem: Use a sequential log entry ID.

* ledger-on-posix-filesystem: Check exception types using patterns.

* ledger-on-posix-filesystem: Test that state key collisions can't happen.

* ledger-on-posix-filesystem: Document the various directories.

* ledger-on-posix-filesystem: Use a *persistent* sequential log entry ID.

Because this is a persistent store. Duh.

* ledger-on-posix-filesystem: Don't worry about using Futures.

It's a global lock anyway.
2020-01-15 14:08:18 +00:00
Stefano Baghino
89f0deda7d
Fix command client integration test flakiness (#4050)
CHANGELOG_BEGIN
CHANGELOG_END
2020-01-15 10:19:19 +01:00
Stefano Baghino
f5b0cf90a4 Drop unused PollingUtils (#4044)
CHANGELOG_BEGIN
CHANGELOG_END
2020-01-14 16:52:32 +00:00
Robert Autenrieth
81815838a3
Check lookup by key nodes (#3834)
* Factor out common values

* Validate LookupByKey nodes

Fixes #3543

CHANGELOG_BEGIN
- [Sandbox] Validate LookupByKey transaction nodes.
  See `issue #3543 <https://github.com/digital-asset/daml/issues/3543>`_.
CHANGELOG_END

* Add failing tests

* LookupByKey validation should not respect privacy

* lookupByKey should use stakeholders, not divulgees

Fixes #2311

CHANGELOG_BEGIN
- [Ledger API] lookupByKey now requires the submitter to be a stakeholder on the referenced contract.
  See `issue #2311 <https://github.com/digital-asset/daml/issues/2311>`_.
CHANGELOG_END

* Adapt tests to new behavior
2020-01-14 14:07:24 +01:00
Martin Huschenbett
099d653373
Allow submitMustFail in scenarios when initializing sandbox (#4036)
Our users seem to stumble over this problem over and over again. Since there's
no technical reason to ban `submitMustFail` during sandbix initialization, we
can also allow for it.

CHANGELOG_BEGIN

- [Sandbox] Allow ``submitMustFail`` in scenarios used for sandbox initialization.

CHANGELOG_END
2020-01-14 12:47:49 +01:00
Miklos
c88d418acc
Sequential log entry ID for InMemoryLedgerReaderWriter (#4012)
CHANGELOG_BEGIN
CHANGELOG_END
2020-01-13 16:35:26 +01:00
Samir Talwar
6bc00da1e2 kvutils: Add a Runner for the simplified KVUtils API. (#3930)
* Initial version of simplified transaction reader/writer API.

* Code tidying.

* Ran ./fmt.sh

* Added verification of pre-declared vs. actual state updates to example.

* kvutils: Run `scalafmt`.

* kvutils: Move ParticipantStateIntegrationSpecBase to src/test/lib.

* kvutils: Clean up warnings in ParticipantStateIntegrationSpecBase.

* ledger-on-memory: Move InMemoryLedgerReaderWriter to its own package.

* ledger-on-memory: Add a Main class with a simple configuration.

* reference-v2/ledger-on-memory: Wait for DARs to upload.

* ledger-on-memory: Run conformance tests.

* kvutils/app: Extract the in-memory ledger `Main` class into a Runner.

* reference-v2: Move InMemoryKVParticipantState out of kvutils.

It's not used elsewhere.

* kvutils/app: Fix some of the config help text.

* kvutils/app: Don't register the archive files twice.

CHANGELOG_BEGIN

- [kvutils/app] A simple way to run KVUtils-based participants.
- [ledger-in-memory] Split out the simple in-memory ledger, previously
  part of kvutils, into its own JAR.

CHANGELOG_END

* Revert "kvutils/app: Don't register the archive files twice."

This reverts commit 2489ae6964.

Turns out we need this for preloading, which is a useful optimization.

Co-authored-by: Miklos <57664299+miklos-da@users.noreply.github.com>
2020-01-13 09:51:07 +00:00
Miklos
1124931f78
Simplified participant-side reader/writer APIs (#3923)
Initial version of simplified participant-side reader/writer APIs.
2020-01-10 12:20:32 +01:00
Gerolf Seitz
779913f8d5
Fix Sandbox CLI help text for the -a option (#4000)
CHANGELOG_BEGIN
[Sandbox] Fix the Sandbox command line help text to reflect the recent
  change that the default address is ``localhost`` (``127.0.0.1`` or
  ``::1``)
CHANGELOG_END
2020-01-10 10:54:09 +01:00
Stefano Baghino
12d7ad809b Move all Api...Service classes to Sandbox package (#3995)
This is done to restrict the usage of NamedLoggerFactory and most usages of MetricsRegistry
to a single Bazel package, thus allowing a possible replacement to not have to become a
dependency of multiple packages.

CHANGELOG_BEGIN
CHANGELOG_END
2020-01-09 14:28:09 +00:00
Brian Healey
95fbf5c921
ECDA512 algorithm support (#3953)
* ECDA512 algorithm support

* ECDA512

* happy day test for ECDA512 algorithm

* failure test for wrong key for ECDA512 algorithm

* add ability to use EC cert file

* update docs

* scalafmt

* Correct documentation

CHANGELOG_BEGIN
[Ledger API Authorization] Support elliptic curve algorithm for JWT verification
CHANGELOG_END

Signed-off-by: Brian Healey <brian.healey@digitalasset.com>

* correct docs warning
2020-01-09 07:25:04 -05:00
David Padbury
3575319005
db: loosen transaction persistence check (#3970)
Currently there is a constraint on the postgres `ledger_entries` table
ensuring that submitter, application_id and command_id are set on
transactions being persisted. These fields are coming from the submitter
info that will be empty when the transaction accepted event is received
on a participant which is not hosting the submitter.

This change updates the check to ensure that all of these fields are
set OR none of them are.

The same change has been made to the H2 migrations with the addition of
correcting the `is not null` check (was previously using `!= null`).

For postgres, as the check is just loosening the existing constraint of all fields
requiring a value I think there is no risk that the new constraint will fail
to apply to existing data. For H2 as the original constraint was
incorrect there is a possibility that existing data may be incorrect -
however as the same component is responsible for writing to H2 and postgres
I will assume the data was correctly persisted regardless of the constraint.
Plus as H2 is typically only used for ephemeral tests, there is
likely no existing data to migrate.

CHANGELOG_BEGIN

- [Sandbox] Loosens database schema to allow persistence of transaction
  ledger entries where no submitter info is present (typically when the
  submitter is hosted by another participant node).

CHANGELOG_END
2020-01-08 12:16:04 -06:00
Jussi Mäki
b8891891a8 Allow omitting submitter info in kvutils transaction log entries (#3966)
* Do not assume submitter info is present in the message

* Make kvutils conversion utilities public

Required for implementing extensions on top of kvutils.

* Make kvutils.Conversions private to com.daml.ledger.participant.state

* Add test case for allowing optional submitter info

* Add changelog markers

CHANGELOG_BEGIN
CHANGELOG_END
2020-01-08 14:21:33 +00:00
Moritz Kiefer
a8b4a84b08
Move most of the remaining serializable types to stable LF packages (#3964)
* Move most of the remaining serializable types to stable LF packages

The only serializable types left in DAML stdlib after this PR are the
following:

- DA.Upgrade:MetaEquiv
- DA.Random:Minstd
- DA.Next.Set:Set
- DA.Next.Map:Map
- DA.Generics:MetaSel0
- DA.Generics:MetaData0
- DA.Generics:DecidedStrictness
- DA.Generics:SourceStrictness
- DA.Generics:SourceUnpackedness
- DA.Generics:Associativity
- DA.Generics:Infix0
- DA.Generics:Fixity
- DA.Generics:K1
- DA.Generics:Par1
- DA.Generics:U1
- DA.Internal.Prelude:Optional

Ignoring the Generics stuff which isn’t very urgent imho and the
Upgrade stuff which is probably going to change significantly anyway,
this leaves us with the weird Random module, the wrappers around
TextMap which will go away anyway and DA.Internal.Prelude:Optional
which shouldn’t exist in the first place (I’ll address that in a
separate PR).

CHANGELOG_BEGIN

- [DAML Compiler] Move more types from daml-stdlib to standalone LF
packages. The module names for the types have also changed
slightly. This only matters over the Ledger API when you specify the
module name explicitly. In DAML you should continue to use the
existing module names.

  - The types from ``DA.Semigroup` are now in a separate package under
  ``DA.Semigroup.Types``
  - The types from ``DA.Monoid` are now in a separate package under
  ``DA.Monoid.Types``
  - The types from ``DA.Time` are now in a separate package under
  ``DA.Time.Types``
  - The types from ``DA.Validation` are now in a separate package
  under ``DA.Validation.Types``
  - The types from ``DA.Logic` are now in a separate package under
  ``DA.Logic.Types``
  - The types from `DA.Date` are now in a separate package under
  `DA.Date.Types`.
  - The `Down` type from `DA.Internal.Prelude` is now in a separate
  package under `DA.Internal.Down`.

CHANGELOG_end

* Fix serializability of RelTime

* fix daml-docs

* Fix tests
2020-01-07 18:25:23 +01:00
Samir Talwar
bbf3fc679d ledger-api-health: Move the values to the companion object. (#3929)
These need to be accessible as `HealthStatus.(un)?healthy` in Java. I
accidentally made them instance methods, which makes life inconvenient.
2020-01-07 11:31:53 +01:00
daravep
b49733b64f Expose address config option in StandloneApiServer (#3906)
* Expose address config option in StandaloneApiServer

Before this PR, it was not possible to set the ledger-api-server
address and so it defaulted to localhost. Now, there is a configuration
variable address in the ApiServerConfig.

* Bind to the loopback address by default instead of the public interface.

CHANGELOG_BEGIN

- [daml-on-x-server] Made ledger api server to bind to localhost by
  default instead to the public interface for security reasons.

CHANGELOG_END
2020-01-07 10:30:31 +01:00
Andreas Herrmann
f33e79c787
Remove unused dependencies to da_scala_library (#3938)
* Inline all scala_library dependencies

* Run //:buildifier-fix

* TMP scala_library_suite --> scala_library

* da_scala_library: Enable unused dependency checker

* scala_library: Enable unused dependency checker

* //daml-lf/data:data

* //daml-lf/engine:engine

* //ledger-api/rs-grpc-akka:rs-grpc-akka

* //ledger/participant-state:participant-state

* //ledger/ledger-api-client:ledger-api-client

* //scala-protoc-plugins/scala-logging:scala-logging-lib

* //ledger/ledger-api-scala-logging:ledger-api-scala-logging

* //ledger/ledger-api-common:ledger-api-common

* //ledger-service/utils:utils

* //ledger-service/jwt:jwt

* //ledger/ledger-api-auth:ledger-api-auth

* //extractor:extractor

* //daml-assistant/scala-daml-project-config:scala-daml-project-config

* //language-support/codegen-common:codegen-common

* //language-support/scala/codegen:codegen

* //language-support/codegen-main:codegen-main-lib

* //ledger-service/db-backend:db-backend

* //ledger-service/http-json:http-json

* //daml-lf/scenario-interpreter:scenario-interpreter

* //ledger/sandbox:sandbox

* //navigator/backend:navigator-library

* //daml-assistant/daml-sdk:sdk-lib

* //daml-lf/data-scalacheck:data-scalacheck

* //daml-script/test:test-lib

* //ledger/ledger-api-common:ledger-api-common-scala-tests-lib

* //ledger/test-common:test-common

* //ledger/sandbox:sandbox-scala-tests-lib

* //extractor:extractor-scala-tests-lib

* //language-support/java/bindings:bindings-java-tests-lib

* //language-support/java/bindings-rxjava:bindings-java-tests-lib

* //language-support/scala/bindings-akka-testing:bindings-akka-testing

* //language-support/scala/codegen-testing:codegen-testing

* //language-support/scala/codegen-sample-app:daml-lf-codegen-sample-app

* //language-support/scala/codegen-sample-app:daml-lf-codegen-sample-app-testing

* //language-support/scala/codegen-testing:codegen-testing-testing

* //ledger-api/sample-service:sample-service

* //ledger-api/rs-grpc-akka:rs-grpc-akka-tests-lib

* //ledger/ledger-api-test-tool:ledger-api-test-tool-lib

* //ledger/ledger-api-test-tool:ledger-api-test-tool-tests

* //ledger/participant-state/kvutils:kvutils

* //ledger/sandbox:ledger-api-server

* //ledger/sandbox-perf:sandbox-perf-lib

* //navigator/backend:navigator-tests-library

* UNDO scala_library_suite --> scala_library

This reverts commit ab3eb1ae23139e2ec431ab4551fbb0371e0354e1.

Co-authored-by: Andreas Herrmann <andreash87@gmx.ch>
2020-01-06 18:14:21 +01:00
Remy
4e5b967a96
SQL Sanbox: Bit more tests for KeyHasher (#3864)
add a bit more tests in order to  test KeyHasher stability
2020-01-06 15:37:00 +01:00
Andreas Herrmann
43bbfeaee6
Remove unused dependencies to da_scala_binary (#3937)
* Inline all scala_binary dependencies

* Run //:buildifier-fix

* da_scala_binary: Enable unused dependency checker

* //compiler/scenario-service/server:scenario-service-raw

* //language-support/scala/codegen:codegen-main

* //daml-lf/encoder:encoder_binary

* //daml-lf/repl:repl

* //language-support/codegen-main:codegen-main

* //language-support/scala/examples:quickstart-scala-bin

* //ledger-api/rs-grpc-akka:rs-grpc-akka-perf

* //ledger-service/jwt:jwt-bin

* //ledger/api-server-damlonx/reference-v2:reference-v2

* //ledger/api-server-damlonx/reference-v2:ephemeral-postgres-reference-server

* //ledger/ledger-api-auth:ledger-api-auth-bin

* //ledger/ledger-api-test-tool:ledger-api-test-tool

* //ledger/participant-state/kvutils/tools:integrity-check

* //navigator/integration-test:navigatortest-jar

* Run //:buildifier-fix

Co-authored-by: Andreas Herrmann <andreash87@gmx.ch>
2020-01-06 13:58:56 +01:00
Andreas Herrmann
6e25d10fe2
daml test-script (#3918)
* Start on daml test-scripts

* Run all `Script a` as test cases

* LedgerClient: Expose PackageManagementClient

To enable DAR uploads

* Upload the DAR to the ledger

* Start sandbox if no ledger specified

* Format daml test-script

* Fix deprecation warning on ActorMaterializer

* Add test-case //daml-script/tests:test_daml_script_test_runner

* Add daml test-script command

CHANGELOG_BEGIN

- [DAML Script - Experimental] Allow running DAML scripts as test-cases.
  Executing ``daml test-script --dar mydar.dar`` will execute all
  definitions matching the type ``Script a`` as test-cases.
  See `#3687 <https://github.com/digital-asset/daml/issues/3687>`__.

CHANGELOG_END

* daml-test-script enable logging

* Remove outdated TODO comment

* daml script-test More elaborate test-caseo

Compare to expected output and add failing test-case

* daml test-script Don't abort on test-failure

Before the test runner would abort on the first failed test-case. This
occasionally introduce additional test-failures if the sandbox was
torn down half-way through execution.

* ./fmt.sh

Co-authored-by: Andreas Herrmann <andreash87@gmx.ch>
2020-01-03 15:01:36 +01:00
Gary Verhaegen
878429e3bf
update copyright notices to 2020 (#3939)
copyright update 2020

* update template
* run script: `dade-copyright-headers update .`
* update script
* manual adjustments
* exclude frozen proto files from further header checks (by adding NO_AUTO_COPYRIGHT files)
2020-01-02 21:21:13 +01:00
Andreas Herrmann
9fbb787062 Remove unused dependencies to da_scala_test(_suite) (#3925)
* Remove unused scala.bzl imports

* override_targets org.scalatest.scalatest_2.12

Otherwise, rules_scala implicitly adds a different version to scala_test
than other packages transitively depending on scalatest. This causes
unused dependency checker to raise an error.

* Handle rules_scala scalatest in pom_file.bzl

* Inline all scala_test dependencies

So that `unused_dependency_checker = "error"` can be applied to them.

* Run //:buildifier-fix

* TMP scala_test_suite --> scala_test

* da_scala_test: Enable unused dependency checker

* //navigator/backend:navigator-scala-tests

* //ledger/sandbox:sandbox-scala-tests

* //ledger/participant-state/kvutils:kvutils-tests

* //ledger/participant-state:participant-state-tests

* //ledger/ledger-api-scala-logging:ledger-api-scala-logging-test

* //ledger/ledger-api-common:ledger-api-common-scala-tests

* //ledger/ledger-api-client:ledger-api-client-tests

* //ledger/ledger-api-auth:ledger-api-auth-scala-tests

* //ledger-service/lf-value-json:tests

* //ledger-service/jwt:tests

* //ledger-service/http-json:tests

* //ledger-api/rs-grpc-akka:rs-grpc-akka-tests

* //language-support/scala/codegen-sample-app:tests

* //language-support/scala/codegen-sample-app:ScalaCodeGenIT

* //language-support/scala/codegen:tests

* //language-support/scala/bindings-akka:tests

* //language-support/java/codegen:test

* //language-support/java/codegen:ledger-tests

* //language-support/java/bindings-rxjava:bindings-java-tests

* //language-support/codegen-common:test

* //extractor:extractor-scala-tests

* //daml-lf/scenario-interpreter:scenario-interpreter_tests

* //daml-lf/language:language-test

* //daml-lf/interface:tests

* //daml-lf/engine:tests

* //daml-lf/encoder:tests

* //daml-lf/archive:daml_lf_archive_reader_tests

* //daml-assistant/scala-daml-project-config:scala-daml-project-config-tests

* UNDO scala_test_suite --> scala_test

This reverts commit 13ed47ba725e944533ca1157a070cb8dc30569ac.

Co-authored-by: Andreas Herrmann <andreash87@gmx.ch>
2019-12-30 13:49:59 +00:00
Samir Talwar
1794d8a2fd Sandbox: Manage resources and close them properly on failure. (#3871)
* sandbox: Create a monadic `ResourceOwner` to manage resources.

* sandbox: Rewrite `ResourceOwner` to be async.

* sandbox: Make sure failed resources are closed immediately.

* sandbox: Better naming in `Open`.

* sandbox: Rename `Open` to `Resource`, and open/close to acquire/release.

* sandbox: Convert `() => AutoCloseable` into `ResourceOwner`.

* sandbox: Refactor the LedgerApiServer in terms of resources.

* sandbox: Explicitly convert `() => AutoCloseable` to `ResourceOwner`.

Explicit > Implicit, right?

* sandbox: Create helpers for converting things to ResourceOwners.

Because I tried to start using them and there was so much code being
written at once.

* sandbox: Simplify construction of JdbcLedgerDao.

* sandbox: Releasing resources should be idempotent.

In that we should only do it once.

* sandbox: Fix the ResetService by closing the API services _first_.

They need to be shut down before the gRPC server.

* sandbox: Don't try and shut down PostgreSQL twice in tests.

* sandbox: Actually run the assertions in ResourceOwnerSpec.

Facepalm.

* sandbox: Test `Resource.sequence` more rigorously.

* sandbox: Move the helpers around `Resource` into `Resource.apply`.

* sandbox: Convert LedgerApiServer resource owners to classes.

* sandbox: Make `ResourceOwner` a monad too, delegating to `Resource`.

* sandbox: Turn `LedgerApiServer` into a ResourceOwner.

* sandbox: Simplify the public signature of `Resource.apply`.

* sandbox: Use ResourceOwners to simplify DB resource management.

This is one hell of a change. Sorry.

* sandbox: Try not to nest `Await.result` calls.

Causes issues when running in a `DirectExecutionContext`.

* sandbox: Turn index subscriptions into resources.

* sandbox: Fix warnings in RecoveringIndexerSpec.

* sandbox: Always release before recovering the indexer.

* sandbox: Add `flatten` and `transformWith` to `Resource`.

* sandbox: If releasing twice in parallel, the second should wait.

* sandbox: If the indexer recovers, clean up the old subscription.

* sandbox: Convert StandaloneIndexerServer into a resource owner.

* sandbox: Convert StandaloneApiServer into a resource owner.

* reference-v2: Rewrite ReferenceServer in terms of resources.

CHANGELOG_BEGIN

- [Reference v2] On an exception, shut down everything and crash.
  Previously, the server would stay in a half-running state.

CHANGELOG_END

* sandbox: Rewrite SandboxServer in terms of resources.

* sandbox: Write the port file in a Future.

* sandbox: JdbcIndexer no longer needs to manage the actorSystem.

* sandbox: Shut down the LedgerApiServer when closing the Sandbox.

* sandbox: Rename `Resource.pure` to `Resource.successful`.

* sandbox: Rename `Resource.sequence_` to `sequenceIgnoringValues`.

* sandbox: Delete `CloseableResource`.

It's only used in once place. Just inline it.

* sandbox: `LedgerDao` no longer needs to be closeable.

* sandbox: Delete implicit materializers where they're not used.

* http-json: Wait for the Sandbox to start in tests.

* sandbox: Convert `scheduleHeartbeats` into a ResourceOwner.

* reference-v2: Explain why we steal ownership of the actor system.

* sandbox: Document why we only release resources once.

* sandbox: Add clues to ResourceOwnerSpec.

* http-json: Fix HttpServiceTestFixture to pass auth service through.

* codegen-sample-app: In ScalaCodeGenIT, wait for the server to  start.
2019-12-22 15:05:55 +00:00
Stefano Baghino
48d2fa1e1a Nuke //ledger/ledger-api-integration-tests (#3919) 2019-12-20 15:44:28 +00:00
Stefano Baghino
7020ed3b15
Moves CommandCompletionIT to Ledger API Test Tool (#3901)
* Moves CommandCompletionIT to Ledger API Test Tool

Closes #2841

Also refactors test observers into a single API and unifies the existing implementations of the DirectExecutionContext

* Allow explicit offsets to get checkpoints

* Raise checkpoint test timeout

* Consolidate checkpoint tests in a single test case

* Fix compilation issues

* Exclude command submission/completion tests for rev-v2

* Drop test not relevant for Ledger API implementations

* Fix compilation errors
2019-12-20 15:55:23 +01:00
Stefano Baghino
822ce28e75
Port command/transaction checks to Ledger API Test Tool (#3917)
Closes #2842
Closes #2843

The separation between high-level and low-level is not particularly meaningful, as the low-level variant issues commands with a component used by the high-level variant.
The separation aims at performing integration tests at two different levels but this can be addressed by a single suite of integration tests and relying on unit testing for individual components.

The first two tests:

- 'having many transactions all of them has a unique event id' reads transactions from an empty ledger and doesn't really test anything, so this has been dropped because the uniqueness of event identifiers is already more than covered by many tests in the 'TransactionService' suite.
- 'handle bad Decimals correctly' ensures the ledger api rejects unrepresentable decimals and it have been re-implemented as 'Reject unrepresentable numeric values' in the 'CommandService' suite.

The other tests are about command-and-exercise:

- 'process valid commands with workflow ids successfully' -> 'Implement create-and-exercise correctly'
- 'fail for invalid create arguments' -> 'Fail create-and-exercise on bad create arguments'
- 'fail for invalid choice arguments' -> 'Fail create-and-exercise on bad choice arguments'
- 'fail for an invalid choice' -> 'Fail create-and-exercise on invalid choice'
2019-12-20 13:24:55 +01:00
Stefano Baghino
6ece2b4147
Port backpressure tests to Sandbox integration tests (#3910)
Closes #2847
2019-12-20 13:22:18 +01:00
Brian Healey
9f13a2fb10 Upgrade to Akka 2.6.1, akka-http 10.1.11 and Scala 2.12.10 (#3903)
* Upgrade to Akka 2.6.1, akka-http 10.1.11 and Scala 2.12.10

Akka 2.6.1 Upgrade Changes
- Materializer in place of ActorMaterializer
- Source.future instead of Source.fromFuture
- The Scheduler.schedule method has been deprecated in favor of selecting scheduleWithFixedDelay or scheduleAtFixedRate
- onDownstreamFinish(cause: Throwable)
- ActorAttributes.supervisionStrategy(...) in place of ActorMaterializerSettings.withSupervisionStrategy

See https://doc.akka.io/docs/akka/current/project/migration-guide-2.5.x-2.6.x.html

* Akka 2.6.1 Upgrade Changes
- onDownstreamFinish(cause: Throwable)

See https://doc.akka.io/docs/akka/current/project/migration-guide-2.5.x-2.6.x.html

* code review: remove unnecessary supervision strategy
2019-12-19 18:00:59 +00:00
Samir Talwar
752e15bfb7 Sandbox: Test RecoveringIndexer logs, and stop dumping them to STDERR. (#3891)
* sandbox: Fix warnings in RecoveringIndexerSpec.

* sandbox: Test RecoveringIndexer logs, and stop dumping them to STDERR.

Printing logs during test execution is really annoying. This stubs the
logger factory with a TestNamedLoggerFactory which captures them in a
list instead, for testing purposes.

* sandbox: Remove unnecessary comments from {,Simple}NamedLoggerFactory.

* ledger-api-common: Remove unused parts of the NamedLoggerFactory.
2019-12-19 15:39:05 +00:00
Stefano Baghino
9f16d2de43 Fix WallClockTimeIT sandbox configuration (#3907)
Using the default configuration as a base for this test meant binding on 6865 instead of using dynamic port binding, which could cause flaky errors if some other test is occupying the port
2019-12-19 14:06:05 +00:00
Moritz Kiefer
c48b0ee289 Move Any wrappers and Archive to stable packages (#3890)
* Move Any wrappers and Archive to stable packages

There are no actual API or functionality changes in this PR but the
logic for locating the stable packages has slightly changed since the
Any wrappers package only makes sense for LF 1.7. To address this, we
simply filter out stable packages for newer LF versions since it
doesn’t make sense to depend on those anyway.

CHANGELOG_BEGIN

- [DAML Compiler] Move ``Archive`` type to a separate DALF.

CHANGELOG_END

* More comments

* Fix java codegen tests

* fix more tests

* Force cache reset on Windows

* Revert "Force cache reset on Windows"

This reverts commit 9f2b7d70b2.
2019-12-19 01:26:38 +00:00
mziolekda
7b882e3767
clean up kv metric names (#3888)
* clean up kv metric names

* rename metrics committing->committer

* replace camel-case with prometheus-friendly underscore
2019-12-18 14:27:07 +01:00
Stefano Baghino
af90d634fd Add CommandSubmissionCompletion suite to test tool (#3885) 2019-12-18 09:45:21 +00:00
mziolekda
2fd8372f44
fix indexer crash on duplicate submission (#3847)
* fix indexer crash on duplicate submission

* deduplicate submissions

* few formatting changes

* address review comments

* add pruning comment to dedup value
2019-12-18 09:14:49 +01:00
Moritz Kiefer
4ad3a22c90
Bump timeout in CommandClientIT (#3879)
This test suite was introduced in #3870 and seems to be extremely
flaky both locally (I get about 16/20 failures) and on CI.

The error is

  - should return completions of commands that are submitted after subscription *** FAILED *** (4 seconds, 945 milliseconds)
    Set() did not contain all elements of List("5104", "5100", "5105", "5109", "5103", "5106", "5107", "5102", "5108", "5101") (CommandClientIT.scala:330)

After bumping the timeout, I don’t get any failures locally.

Happy to choose another timeout, I have no clue what a sensible value
is here.
2019-12-18 09:11:47 +01:00
Stefano Baghino
f864ac955b
Port FailingCommandsIT to the Ledger API Test Tool (#3877)
* Port FailingCommandsIT to the Ledger API Test Tool

Closes #2850

The FailingCommandsIT suite contains tests for mismatching ledger
identifier (which is already abundantly covered by the Ledger API Test
Tool) and for bad labels in contract creation, both via submit and
submitAndWait.

Some of the tests previously part of the CommandService Ledger API Test
Tool suite have been moved to a new home in CommandSubmissionCompletion
to reflect the fact that those use the submission/completion workflow
instead of leveraging the submit-and-wait alternatives.

There are also suites that for some reason cover subsequent invocations
of the same services but I'm not sure of the meaning of those and I
would drop them, unless we have a good explanation for those.

* Optimize imports
2019-12-18 09:11:02 +01:00
Stefano Baghino
3ef2b2181d
Move CommandStaticTimeIT to Sandbox integration tests (#3874)
* Move CommandStaticTimeIT to Sandbox integration tests

Closes #2848

* Address https://github.com/digital-asset/daml/pull/3874#discussion_r358803654

* Address https://github.com/digital-asset/daml/pull/3874#discussion_r358802902
2019-12-17 17:01:46 +01:00
Stefano Baghino
699fef1f3a
Move Scala Ledger API client integration tests (#3870)
* Move Scala Ledger API client integration tests

Closes #2845

The Scala Ledger API client tests belong to the
//ledger/ledger-api-client package.

* Reduce noise coming from tests
2019-12-17 16:11:27 +01:00
Stefano Baghino
db711d40f3
Remove dead ledger-api-integration-tests code (#3866) 2019-12-16 18:01:42 +01:00
Samir Talwar
71e8c20127 Sandbox: Fix warnings in SandboxServer. (#3853)
* sandbox: Move SandboxServer's helper classes to the companion object.

And make them `private`, `final`, and non-`case`.

* sandbox: Drop SandboxServer.apply and just call the constructor.

* sandbox: Move the SandboxServer#SandboxState class into the object.

Leave the `resetAndRestartServer` method behind, though.
2019-12-14 20:52:03 +00:00
Stefano Baghino
3ca7ed49dd Remove warts: ExplicitImplicitTypes (#3851)
* Remove warts: ExplicitImplicitTypes

* Fix compilation errors
2019-12-13 18:33:49 +00:00